blob: d0e9a75ad0f0fd59e52bb1eca0fb80c5e7a072f4 [file] [log] [blame]
Brian Silverman8fce7482020-01-05 13:18:21 -08001#!/bin/bash
2#---------------------------------------------------------------------------
3# Copyright (c) 2018 FIRST. All Rights Reserved.
4# Open Source Software - may be modified and shared by FRC teams. The code
5# must be accompanied by the FIRST BSD license file in the root directory of
6# the project.
7#----------------------------------------------------------------------------
8
9#----------------------------------------------------------------------------
10# Invoke gazebo, giving it the environment variables
11# it needs to find the FRC plugins and models.
12#----------------------------------------------------------------------------
13usage() {
14 echo $1: Invoke Gazebo for FRC
15 echo Usage:
16 echo " $1 name-of-world-file"
17}
18
19d=`dirname "$0"`
20fulldir=`(cd "$d"; pwd)`
21sharedir=/usr/share/frcgazebo
22if [ -d "$fulldir/../share" ] ; then
23 sharedir=`(cd "$fulldir/../share/frcgazebo"; pwd)`
24fi
25
26# While we wait for the frc gazebo models to have a proper
27# home, we require the user to make them accessible
28if [ ! -d "$sharedir" ] ; then
29 cravedir=`(cd "$fulldir/../"; pwd)`
30 echo Error: you must manually place the models and world into $cravedir/share/frcgazebo
31 exit 2
32fi
33
34libsdir=/invalid/directory
35if [ -d "$fulldir/../libs" ] ; then
36 libsdir=`(cd "$fulldir/../libs"; pwd)`
37fi
38
39# Use exactly the file they gave us, or find it in ../share/frcgazebo/worlds,
40# or find it there by adding a .world extension
41world="$1"
42if [ ! -f "$world" ] ; then
43 world="$sharedir/worlds/$1"
44fi
45if [ ! -f "$world" ] ; then
46 world="$sharedir/worlds/$1.world"
47fi
48
49if [ $# -ne 1 -o "x${1:0:1}" = "x-" ] ; then
50 usage `basename $0`
51 exit 1
52fi
53if [ ! -f "$world" ] ; then
54 echo Could not find $1 directly or in $sharedir/worlds
55 exit 2
56fi
57
58export GAZEBO_MODEL_PATH="$sharedir/models":$GAZEBO_MODEL_PATH
59for x in `find "$libsdir" -type d -name shared` ; do
60 export GAZEBO_PLUGIN_PATH="$x:$GAZEBO_PLUGIN_PATH"
61done
62
63gazebo "$world"