From 93c1ad3103af67d3dfdc808ef04bd78231bc0216 Mon Sep 17 00:00:00 2001 From: Jonas Vautherin Date: Thu, 14 Sep 2017 11:51:02 +0200 Subject: [PATCH] sitl: add possibility to not run gazebo when running make --- Tools/sitl_run.sh | 51 ++++++++++++++++++++++++++++------------------- 1 file changed, 30 insertions(+), 21 deletions(-) diff --git a/Tools/sitl_run.sh b/Tools/sitl_run.sh index d887be0f9e..4a516b8814 100755 --- a/Tools/sitl_run.sh +++ b/Tools/sitl_run.sh @@ -94,20 +94,23 @@ elif [ "$program" == "gazebo" ] && [ ! -n "$no_sim" ] then if [ -x "$(command -v gazebo)" ] then - # Set the plugin path so Gazebo finds our model and sim - source $src_path/Tools/setup_gazebo.bash ${src_path} ${build_path} + if [[ -z "$DONT_RUN" ]] + 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 & - SIM_PID=`echo $!` + gzserver --verbose ${src_path}/Tools/sitl_gazebo/worlds/${model}.world & + SIM_PID=`echo $!` - if [[ -n "$HEADLESS" ]]; then - echo "not running gazebo gui" - else - # 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 - sleep 3 - nice -n 20 gzclient --verbose & - GUI_PID=`echo $!` + if [[ -n "$HEADLESS" ]]; then + echo "not running gazebo gui" + else + # 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 + sleep 3 + nice -n 20 gzclient --verbose & + GUI_PID=`echo $!` + fi fi else 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 +if [[ -n "$DONT_RUN" ]] +then + echo "Not running simulation (\$DONT_RUN is set)." # Start Java simulator -if [ "$debugger" == "lldb" ] +elif [ "$debugger" == "lldb" ] then lldb -- $sitl_command elif [ "$debugger" == "gdb" ] @@ -153,14 +159,17 @@ else $sitl_command fi -if [ "$program" == "jmavsim" ] +if [[ -z "$DONT_RUN" ]] then - pkill -9 -P $SIM_PID - kill -9 $SIM_PID -elif [ "$program" == "gazebo" ] -then - kill -9 $SIM_PID - if [[ ! -n "$HEADLESS" ]]; then - kill -9 $GUI_PID + if [ "$program" == "jmavsim" ] + then + pkill -9 -P $SIM_PID + kill -9 $SIM_PID + elif [ "$program" == "gazebo" ] + then + kill -9 $SIM_PID + if [[ ! -n "$HEADLESS" ]]; then + kill -9 $GUI_PID + fi fi fi