2016-04-05 06:37:57 -03:00
|
|
|
#!/bin/bash
|
2016-09-19 15:08:35 -03:00
|
|
|
# run multiple instances of the 'px4' binary, but w/o starting the simulator.
|
2018-11-22 00:27:21 -04:00
|
|
|
# It assumes px4 is already built, with 'make px4_sitl_default'
|
2016-04-05 06:37:57 -03:00
|
|
|
|
2019-01-29 04:37:13 -04:00
|
|
|
# The simulator is expected to send to TCP port 4560+i for i in [0, N-1]
|
2018-08-11 09:09:20 -03:00
|
|
|
# For example jmavsim can be run like this:
|
2019-01-29 04:37:13 -04:00
|
|
|
#./Tools/jmavsim_run.sh -p 4561
|
2016-04-05 06:37:57 -03:00
|
|
|
|
2018-08-11 09:09:20 -03:00
|
|
|
sitl_num=2
|
|
|
|
[ -n "$1" ] && sitl_num="$1"
|
2016-04-05 06:37:57 -03:00
|
|
|
|
2016-09-19 15:08:35 -03:00
|
|
|
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
|
|
src_path="$SCRIPT_DIR/.."
|
2016-04-05 06:37:57 -03:00
|
|
|
|
2018-11-22 00:27:21 -04:00
|
|
|
build_path=${src_path}/build/px4_sitl_default
|
2016-04-05 06:37:57 -03:00
|
|
|
|
2016-09-19 15:08:35 -03:00
|
|
|
echo "killing running instances"
|
2017-01-18 05:16:34 -04:00
|
|
|
pkill -x px4 || true
|
|
|
|
|
2016-09-19 15:08:35 -03:00
|
|
|
sleep 1
|
2016-04-05 06:37:57 -03:00
|
|
|
|
2018-08-11 09:09:20 -03:00
|
|
|
export PX4_SIM_MODEL=iris
|
2016-09-19 15:08:35 -03:00
|
|
|
|
2018-08-11 09:09:20 -03:00
|
|
|
n=0
|
|
|
|
while [ $n -lt $sitl_num ]; do
|
|
|
|
working_dir="$build_path/instance_$n"
|
|
|
|
[ ! -d "$working_dir" ] && mkdir -p "$working_dir"
|
2016-09-19 15:08:35 -03:00
|
|
|
|
|
|
|
pushd "$working_dir" &>/dev/null
|
|
|
|
echo "starting instance $n in $(pwd)"
|
2018-08-11 09:09:20 -03:00
|
|
|
../bin/px4 -i $n -d "$src_path/ROMFS/px4fmu_common" -s etc/init.d-posix/rcS >out.log 2>err.log &
|
2016-09-19 15:08:35 -03:00
|
|
|
popd &>/dev/null
|
|
|
|
|
|
|
|
n=$(($n + 1))
|
2016-04-05 06:37:57 -03:00
|
|
|
done
|