2015-06-15 13:51:07 -03:00
|
|
|
#!/bin/bash
|
2015-10-24 11:57:46 -03:00
|
|
|
|
|
|
|
rc_script=$1
|
|
|
|
debugger=$2
|
|
|
|
program=$3
|
|
|
|
build_path=$4
|
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 build_path: $buid_path
|
|
|
|
|
|
|
|
if [ "$#" != 4 ]
|
|
|
|
then
|
|
|
|
echo usage: sitl_run.sh rc_script debugger program build_path
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2015-10-25 11:57:24 -03:00
|
|
|
# kill process names that might stil
|
|
|
|
# be running from last time
|
|
|
|
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-25 11:57:24 -03:00
|
|
|
|
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-24 11:57:46 -03:00
|
|
|
if [ "$program" == "jmavsim" ]
|
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-23 18:58:28 -03:00
|
|
|
SIM_PID=echo $!
|
2015-10-22 11:30:23 -03:00
|
|
|
elif [ "$3" == "gazebo" ]
|
|
|
|
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
|
|
|
|
GAZEBO_PLUGIN_PATH=${GAZEBO_PLUGIN_PATH}:$curr_dir/Tools/sitl_gazebo/Build
|
|
|
|
# Set the model path so Gazebo finds the airframes
|
|
|
|
GAZEBO_MODEL_PATH=${GAZEBO_MODEL_PATH}:$curr_dir/Tools/sitl_gazebo/models
|
|
|
|
# Disable online model lookup since this is quite experimental and unstable
|
|
|
|
GAZEBO_MODEL_DATABASE_URI=""
|
|
|
|
mkdir -p Tools/sitl_gazebo/Build
|
|
|
|
cd Tools/sitl_gazebo/Build
|
|
|
|
cmake ..
|
|
|
|
make -j4
|
|
|
|
gazebo ../worlds/iris.world &
|
2015-10-25 13:25:15 -03:00
|
|
|
SIM_PID=`echo $!`
|
2015-10-22 11:30:23 -03:00
|
|
|
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-10-24 11:57:46 -03:00
|
|
|
lldb -- mainapp ../../../../$rc_script
|
|
|
|
elif [ "$debugger" == "gdb" ]
|
2015-09-20 07:54:22 -03:00
|
|
|
then
|
2015-10-24 11:57:46 -03:00
|
|
|
gdb --args mainapp ../../../../$rc_script
|
2015-09-20 07:54:22 -03:00
|
|
|
else
|
2015-10-24 11:57:46 -03:00
|
|
|
./mainapp ../../../../$rc_script
|
2015-09-20 07:54:22 -03:00
|
|
|
fi
|
2015-10-23 18:58:28 -03:00
|
|
|
|
|
|
|
if [ "$3" == "jmavsim" ]
|
|
|
|
then
|
|
|
|
kill -9 $SIM_PID
|
|
|
|
elif [ "$3" == "gazebo" ]
|
|
|
|
then
|
|
|
|
kill -9 $SIM_PID
|
|
|
|
fi
|