sitl: add possibility to not run gazebo when running make

This commit is contained in:
Jonas Vautherin
2017-10-04 15:38:37 +02:00
committed by Lorenz Meier
parent dd98ed565e
commit 93c1ad3103
+30 -21
View File
@@ -94,20 +94,23 @@ elif [ "$program" == "gazebo" ] && [ ! -n "$no_sim" ]
then then
if [ -x "$(command -v gazebo)" ] if [ -x "$(command -v gazebo)" ]
then then
# Set the plugin path so Gazebo finds our model and sim if [[ -z "$DONT_RUN" ]]
source $src_path/Tools/setup_gazebo.bash ${src_path} ${build_path} then
# Set the plugin path so Gazebo finds our model and sim
source $src_path/Tools/setup_gazebo.bash ${src_path} ${build_path}
gzserver --verbose ${src_path}/Tools/sitl_gazebo/worlds/${model}.world & gzserver --verbose ${src_path}/Tools/sitl_gazebo/worlds/${model}.world &
SIM_PID=`echo $!` SIM_PID=`echo $!`
if [[ -n "$HEADLESS" ]]; then if [[ -n "$HEADLESS" ]]; then
echo "not running gazebo gui" echo "not running gazebo gui"
else else
# gzserver needs to be running to avoid a race. Since the launch # gzserver needs to be running to avoid a race. Since the launch
# is putting it into the background we need to avoid it by backing off # is putting it into the background we need to avoid it by backing off
sleep 3 sleep 3
nice -n 20 gzclient --verbose & nice -n 20 gzclient --verbose &
GUI_PID=`echo $!` GUI_PID=`echo $!`
fi
fi fi
else else
echo "You need to have gazebo simulator installed!" echo "You need to have gazebo simulator installed!"
@@ -124,8 +127,11 @@ sitl_command="$sudo_enabled $sitl_bin $no_pxh $chroot_enabled $src_path $src_pat
echo SITL COMMAND: $sitl_command echo SITL COMMAND: $sitl_command
if [[ -n "$DONT_RUN" ]]
then
echo "Not running simulation (\$DONT_RUN is set)."
# Start Java simulator # Start Java simulator
if [ "$debugger" == "lldb" ] elif [ "$debugger" == "lldb" ]
then then
lldb -- $sitl_command lldb -- $sitl_command
elif [ "$debugger" == "gdb" ] elif [ "$debugger" == "gdb" ]
@@ -153,14 +159,17 @@ else
$sitl_command $sitl_command
fi fi
if [ "$program" == "jmavsim" ] if [[ -z "$DONT_RUN" ]]
then then
pkill -9 -P $SIM_PID if [ "$program" == "jmavsim" ]
kill -9 $SIM_PID then
elif [ "$program" == "gazebo" ] pkill -9 -P $SIM_PID
then kill -9 $SIM_PID
kill -9 $SIM_PID elif [ "$program" == "gazebo" ]
if [[ ! -n "$HEADLESS" ]]; then then
kill -9 $GUI_PID kill -9 $SIM_PID
if [[ ! -n "$HEADLESS" ]]; then
kill -9 $GUI_PID
fi
fi fi
fi fi