Files
bizhang_-obav/Tools/sitl_run.sh

110 lines
2.7 KiB
Bash
Raw Normal View History

#!/bin/bash
2015-10-24 10:57:46 -04:00
rc_script=$1
debugger=$2
program=$3
model=$4
build_path=$5
2015-10-25 18:25:37 +01:00
curr_dir=`pwd`
2015-10-24 10:57:46 -04:00
echo SITL ARGS
echo rc_script: $rc_script
echo debugger: $debugger
echo program: $program
echo model: $model
2015-10-25 19:25:18 -04:00
echo build_path: $build_path
2015-10-24 10:57:46 -04:00
if [ "$model" == "" ] || [ "$model" == "none" ]
2015-10-24 10:57:46 -04:00
then
echo "empty model, setting iris as default"
model="iris"
fi
if [ "$#" != 5 ]
then
echo usage: sitl_run.sh rc_script debugger program model build_path
echo ""
2015-10-24 10:57:46 -04:00
exit 1
fi
# kill process names that might stil
# be running from last time
2015-10-25 19:25:18 -04:00
pkill gazebo
pkill mainapp
2015-10-25 12:33:48 -04:00
jmavsim_pid=`jps | grep Simulator | cut -d" " -f1`
if [ -n "$jmavsim_pid" ]
then
kill $jmavsim_pid
fi
2015-11-23 13:38:05 +01:00
set -e
2015-10-24 10:57:46 -04:00
cp Tools/posix_lldbinit $build_path/src/firmware/posix/.lldbinit
cp Tools/posix.gdbinit $build_path/src/firmware/posix/.gdbinit
2015-10-23 23:58:28 +02:00
SIM_PID=0
2015-10-30 16:33:19 +01:00
if [ "$program" == "jmavsim" ] && [ "$no_sim" == "" ]
2015-10-17 17:41:57 +02:00
then
cd Tools/jMAVSim
ant
nice -n -10 java -Djava.ext.dirs= -cp lib/*:out/production/jmavsim.jar me.drton.jmavsim.Simulator -udp 127.0.0.1:14560 &
2015-10-26 16:03:22 -04:00
SIM_PID=`echo $!`
2015-11-21 17:43:07 +01:00
elif [ "$program" == "gazebo" ] && [ "$no_sim" == "" ]
then
if [ -x "$(command -v gazebo)" ]
then
2015-10-25 18:25:37 +01:00
# Set the plugin path so Gazebo finds our model and sim
export GAZEBO_PLUGIN_PATH=$curr_dir/Tools/sitl_gazebo/Build:${GAZEBO_PLUGIN_PATH}
2015-10-25 18:25:37 +01:00
# Set the model path so Gazebo finds the airframes
2015-10-25 19:25:18 -04:00
export GAZEBO_MODEL_PATH=${GAZEBO_MODEL_PATH}:$curr_dir/Tools/sitl_gazebo/models
2015-11-12 15:30:03 +01:00
# The next line would disable online model lookup, can be commented in, in case of unstable behaviour.
# export GAZEBO_MODEL_DATABASE_URI=""
2015-10-25 19:25:18 -04:00
export SITL_GAZEBO_PATH=$curr_dir/Tools/sitl_gazebo
2015-10-25 18:25:37 +01:00
mkdir -p Tools/sitl_gazebo/Build
cd Tools/sitl_gazebo/Build
cmake -Wno-dev ..
2015-10-25 18:25:37 +01:00
make -j4
nice -n -10 gzserver --verbose ../worlds/${model}.world &
2015-10-25 12:25:15 -04:00
SIM_PID=`echo $!`
gzclient --verbose &
2015-10-27 13:14:17 +01:00
GUI_PID=`echo $!`
else
echo "You need to have gazebo simulator installed!"
exit 1
fi
2015-10-17 17:41:57 +02:00
fi
2015-10-24 10:57:46 -04:00
cd $build_path/src/firmware/posix
2015-09-12 17:02:42 +02:00
mkdir -p rootfs/fs/microsd
mkdir -p rootfs/eeprom
touch rootfs/eeprom/parameters
# Do not exit on failure now from here on because we want the complete cleanup
set +e
2015-10-17 17:41:57 +02:00
# Start Java simulator
2015-10-24 10:57:46 -04:00
if [ "$debugger" == "lldb" ]
2015-09-20 12:54:22 +02:00
then
2015-11-21 17:43:07 +01:00
lldb -- mainapp ../../../../${rc_script}_${program}_${model}
2015-10-24 10:57:46 -04:00
elif [ "$debugger" == "gdb" ]
2015-09-20 12:54:22 +02:00
then
2015-11-21 17:43:07 +01:00
gdb --args mainapp ../../../../${rc_script}_${program}_${model}
2015-11-06 21:11:54 -05:00
elif [ "$debugger" == "ddd" ]
then
2015-11-21 17:43:07 +01:00
ddd --debugger gdb --args mainapp ../../../../${rc_script}_${program}_${model}
2015-11-06 21:11:54 -05:00
elif [ "$debugger" == "valgrind" ]
then
valgrind ./mainapp ../../../../${rc_script}_${program}_${model}
2015-09-20 12:54:22 +02:00
else
nice -n -10 ./mainapp ../../../../${rc_script}_${program}_${model}
2015-09-20 12:54:22 +02:00
fi
2015-10-23 23:58:28 +02:00
if [ "$program" == "jmavsim" ]
2015-10-23 23:58:28 +02:00
then
kill -9 $SIM_PID
elif [ "$program" == "gazebo" ]
2015-10-23 23:58:28 +02:00
then
kill -9 $SIM_PID
2015-10-27 13:14:17 +01:00
kill -9 $GUI_PID
2015-10-23 23:58:28 +02:00
fi