SITL: add multi-vehicle support to rcS

This also removes the HIGHRES_IMU mavlink stream to the GCS. I don't see
why it's needed and it adds noticeable CPU load.
This commit is contained in:
Beat Küng
2018-08-13 21:50:14 -04:00
committed by Daniel Agar
parent a00f7ebf47
commit e6b9806ee1
9 changed files with 37 additions and 233 deletions
+11 -31
View File
@@ -2,21 +2,16 @@
# run multiple instances of the 'px4' binary, but w/o starting the simulator.
# It assumes px4 is already built, with 'make posix_sitl_default'
# The simulator is expected to send to UDP port 14560+i for i in [0, N-1]
# For example jmavsim can be run like this:
#./Tools/jmavsim_run.sh -p 14561
sitl_num=2
sim_port=15019
mav_port=15010
mav_port2=15011
mav_oport=15015
mav_oport2=15016
port_step=10
[ -n "$1" ] && sitl_num="$1"
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
src_path="$SCRIPT_DIR/.."
rc_script="posix-configs/SITL/init/ekf2/multiple_iris"
build_path=${src_path}/build/posix_sitl_default
echo "killing running instances"
@@ -24,32 +19,17 @@ pkill -x px4 || true
sleep 1
cd $build_path
export PX4_SIM_MODEL=iris
user=`whoami`
n=1
while [ $n -le $sitl_num ]; do
working_dir="instance_$n"
if [ ! -d $working_dir ]; then
mkdir -p "$working_dir"
pushd "$working_dir" &>/dev/null
# replace template config with configured ports of current instance
cat ${src_path}/${rc_script} | sed s/_SIMPORT_/${sim_port}/ | \
sed s/_MAVPORT_/${mav_port}/g | sed s/_MAVOPORT_/${mav_oport}/ | \
sed s/_MAVPORT2_/${mav_port2}/ | sed s/_MAVOPORT2_/${mav_oport2}/ > rcS
popd &>/dev/null
fi
n=0
while [ $n -lt $sitl_num ]; do
working_dir="$build_path/instance_$n"
[ ! -d "$working_dir" ] && mkdir -p "$working_dir"
pushd "$working_dir" &>/dev/null
echo "starting instance $n in $(pwd)"
sudo -b -u $user ../bin/px4 -i $n -d "$src_path" -s rcS >out.log 2>err.log
../bin/px4 -i $n -d "$src_path/ROMFS/px4fmu_common" -s etc/init.d-posix/rcS >out.log 2>err.log &
popd &>/dev/null
n=$(($n + 1))
sim_port=$(($sim_port + $port_step))
mav_port=$(($mav_port + $port_step))
mav_port2=$(($mav_port2 + $port_step))
mav_oport=$(($mav_oport + $port_step))
mav_oport2=$(($mav_oport2 + $port_step))
done