Daniel Agar 4040e4cdf2 simulation organization and cleanup
- new modules/simulation directory to collect all simulators and related modules
 - new Tools/simulation directory to collect and organize scattered simulation submodules, scripts, etc
 - simulation module renamed to simulator_mavlink
 - sih renamed to simulator_sih (not a great name, but I wanted to be clear it was a simulator)
 - ignition_simulator renamed to simulator_ignition_bridge
 - large sitl_target.cmake split by simulation option and in some cases pushed to appropriate modules
 - sitl targets broken down to what's actually available (eg jmavsim only has 1 model and 1 world)
 - new Gazebo consistently referred to as Ignition for now (probably the least confusing thing until we fully drop Gazebo classic support someday)
2022-08-25 09:10:03 -04:00

48 lines
942 B
Bash
Executable File

#!/usr/bin/env bash
set -e
if [ "$#" -lt 4 ]; then
echo usage: sitl_run.sh sitl_bin model src_path build_path
exit 1
fi
sitl_bin="$1"
model="$2"
src_path="$3"
build_path="$4"
echo SITL ARGS
echo sitl_bin: $sitl_bin
echo model: $model
echo src_path: $src_path
echo build_path: $build_path
rootfs="$build_path/rootfs" # this is the working directory
mkdir -p "$rootfs"
export PX4_SIM_MODEL=${model}
echo "FG setup"
cd "${src_path}/Tools/simulation/flightgear/flightgear_bridge/"
./FG_run.py models/${model}.json 0
"${build_path}/build_flightgear_bridge/flightgear_bridge" 0 `./get_FGbridge_params.py "models/"${model}".json"` &
FG_BRIDGE_PID=$!
pushd "$rootfs" >/dev/null
# Do not exit on failure now from here on because we want the complete cleanup
set +e
sitl_command="\"$sitl_bin\" \"$build_path\"/etc"
echo SITL COMMAND: $sitl_command
eval $sitl_command
popd >/dev/null
kill $FG_BRIDGE_PID
kill -9 `cat /tmp/px4fgfspid_0`