mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-05-12 01:57:35 +08:00
99f6d4190c
Edited line to account for the fact that the file has been moved one level deeper in the folder tree (the same edit should be made in the documentation https://docs.px4.io/main/en/simulation/multi_vehicle_jmavsim.html)
36 lines
923 B
Bash
Executable File
36 lines
923 B
Bash
Executable File
#!/bin/bash
|
|
# run multiple instances of the 'px4' binary, but w/o starting the simulator.
|
|
# It assumes px4 is already built, with 'make px4_sitl_default'
|
|
|
|
# The simulator is expected to send to TCP port 4560+i for i in [0, N-1]
|
|
# For example jmavsim can be run like this:
|
|
#./Tools/simulation/jmavsim/jmavsim_run.sh -p 4561 -l
|
|
|
|
sitl_num=2
|
|
[ -n "$1" ] && sitl_num="$1"
|
|
|
|
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
src_path="$SCRIPT_DIR/../../"
|
|
|
|
build_path=${src_path}/build/px4_sitl_default
|
|
|
|
echo "killing running instances"
|
|
pkill -x px4 || true
|
|
|
|
sleep 1
|
|
|
|
export PX4_SIM_MODEL=gazebo-classic_iris
|
|
|
|
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)"
|
|
$build_path/bin/px4 -i $n -d "$build_path/etc" >out.log 2>err.log &
|
|
popd &>/dev/null
|
|
|
|
n=$(($n + 1))
|
|
done
|