px4-firmware/Tools/sitl_run.sh

104 lines
2.5 KiB
Bash
Raw Normal View History

#!/bin/bash
2015-10-24 11:57:46 -03:00
rc_script=$1
debugger=$2
program=$3
model=$4
build_path=$5
2015-10-25 14:25:37 -03:00
curr_dir=`pwd`
2015-10-24 11:57:46 -03:00
echo SITL ARGS
echo rc_script: $rc_script
echo debugger: $debugger
echo program: $program
echo model: $model
2015-10-25 20:25:18 -03:00
echo build_path: $build_path
2015-10-24 11:57:46 -03:00
if [ "$model" == "" ] || [ "$model" == "none" ]
2015-10-24 11:57:46 -03: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 11:57:46 -03:00
exit 1
fi
# kill process names that might stil
# be running from last time
2015-10-25 20:25:18 -03:00
pkill gazebo
pkill mainapp
2015-10-25 13:33:48 -03:00
jmavsim_pid=`jps | grep Simulator | cut -d" " -f1`
if [ -n "$jmavsim_pid" ]
then
kill $jmavsim_pid
fi
2015-10-24 11:57:46 -03:00
cp Tools/posix_lldbinit $build_path/src/firmware/posix/.lldbinit
cp Tools/posix.gdbinit $build_path/src/firmware/posix/.gdbinit
2015-10-23 18:58:28 -03:00
SIM_PID=0
2015-10-30 12:33:19 -03:00
if [ "$program" == "jmavsim" ] && [ "$no_sim" == "" ]
2015-10-17 12:41:57 -03:00
then
cd Tools/jMAVSim
ant
java -Djava.ext.dirs= -cp lib/*:out/production/jmavsim.jar me.drton.jmavsim.Simulator -udp 127.0.0.1:14560 &
2015-10-26 17:03:22 -03:00
SIM_PID=`echo $!`
2015-11-21 12:43:07 -04:00
elif [ "$program" == "gazebo" ] && [ "$no_sim" == "" ]
then
if [ -x "$(command -v gazebo)" ]
then
2015-10-25 14:25:37 -03: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 14:25:37 -03:00
# Set the model path so Gazebo finds the airframes
2015-10-25 20:25:18 -03:00
export GAZEBO_MODEL_PATH=${GAZEBO_MODEL_PATH}:$curr_dir/Tools/sitl_gazebo/models
2015-11-12 10:30:03 -04: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 20:25:18 -03:00
export SITL_GAZEBO_PATH=$curr_dir/Tools/sitl_gazebo
2015-10-25 14:25:37 -03:00
mkdir -p Tools/sitl_gazebo/Build
cd Tools/sitl_gazebo/Build
cmake -Wno-dev ..
2015-10-25 14:25:37 -03:00
make -j4
gzserver --verbose ../worlds/${model}.world &
2015-10-25 13:25:15 -03:00
SIM_PID=`echo $!`
gzclient --verbose &
2015-10-27 09:14:17 -03:00
GUI_PID=`echo $!`
else
echo "You need to have gazebo simulator installed!"
exit 1
fi
2015-10-17 12:41:57 -03:00
fi
2015-10-24 11:57:46 -03:00
cd $build_path/src/firmware/posix
2015-09-12 12:02:42 -03:00
mkdir -p rootfs/fs/microsd
mkdir -p rootfs/eeprom
touch rootfs/eeprom/parameters
2015-10-17 12:41:57 -03:00
# Start Java simulator
2015-10-24 11:57:46 -03:00
if [ "$debugger" == "lldb" ]
2015-09-20 07:54:22 -03:00
then
2015-11-21 12:43:07 -04:00
lldb -- mainapp ../../../../${rc_script}_${program}_${model}
2015-10-24 11:57:46 -03:00
elif [ "$debugger" == "gdb" ]
2015-09-20 07:54:22 -03:00
then
2015-11-21 12:43:07 -04:00
gdb --args mainapp ../../../../${rc_script}_${program}_${model}
2015-11-06 22:11:54 -04:00
elif [ "$debugger" == "ddd" ]
then
2015-11-21 12:43:07 -04:00
ddd --debugger gdb --args mainapp ../../../../${rc_script}_${program}_${model}
2015-11-06 22:11:54 -04:00
elif [ "$debugger" == "valgrind" ]
then
valgrind ./mainapp ../../../../${rc_script}_${program}_${model}
2015-09-20 07:54:22 -03:00
else
./mainapp ../../../../${rc_script}_${program}_${model}
2015-09-20 07:54:22 -03:00
fi
2015-10-23 18:58:28 -03:00
if [ "$program" == "jmavsim" ]
2015-10-23 18:58:28 -03:00
then
kill -9 $SIM_PID
elif [ "$program" == "gazebo" ]
2015-10-23 18:58:28 -03:00
then
kill -9 $SIM_PID
2015-10-27 09:14:17 -03:00
kill -9 $GUI_PID
2015-10-23 18:58:28 -03:00
fi