Commit 5279d725 authored by Damien SIX's avatar Damien SIX
Browse files

Update gazebo_sitl_multiple_run.sh

parent 1fad029c
......@@ -13,7 +13,7 @@ function cleanup() {
pkill micrortps_agent
}
function spawn_model() {
function spawn_gazebo_model() {
MODEL=$1
N=$2 #Instance Number
X=$3
......@@ -30,24 +30,33 @@ function spawn_model() {
exit 1
fi
working_dir="$build_path/instance_$n"
[ ! -d "$working_dir" ] && mkdir -p "$working_dir"
pushd "$working_dir" &>/dev/null
echo "starting instance $N in $(pwd)"
if [[ $MODEL == *"rtps" ]];
then
'gnome-terminal' -t "RTPSAgent$N" -- micrortps_agent -t UDP -r $((2020+${N}*2)) -s $((2019+${N}*2)) -n "Drone$((1+${N}))"
MODEL_SHORT=$(echo $MODEL | cut -d "_" -f1)
else
MODEL_SHORT=$MODEL
fi
gnome-terminal -t "SITLDrone$N" -- ../bin/px4 -i $N -d "$build_path/etc" -w sitl_${MODEL}_${N} -s etc/init.d-posix/rcS
python3 ${src_path}/Tools/sitl_gazebo/scripts/jinja_gen.py ${src_path}/Tools/sitl_gazebo/models/${MODEL_SHORT}/${MODEL_SHORT}.sdf.jinja ${src_path}/Tools/sitl_gazebo --mavlink_tcp_port $((4560+${N})) --mavlink_udp_port $((14560+${N})) --mavlink_id $((1+${N})) --gst_udp_port $((5600+${N})) --video_uri $((5600+${N})) --mavlink_cam_udp_port $((14530+${N})) --drone_number $((1+${N})) --output-file /tmp/${MODEL}_${N}.sdf
echo "Spawning ${MODEL}_$((1+${N})) at ${X} ${Y}"
python3 ${src_path}/Tools/sitl_gazebo/scripts/jinja_gen.py ${src_path}/Tools/sitl_gazebo/models/${MODEL_SHORT}/${MODEL_SHORT}.sdf.jinja ${src_path}/Tools/sitl_gazebo --mavlink_tcp_port $((4560+${N})) --mavlink_udp_port $((14560+${N})) --mavlink_id $((1+${N})) --gst_udp_port $((5600+${N})) --video_uri $((5600+${N})) --mavlink_cam_udp_port $((14530+${N})) --drone_number $((1+${N})) --output-file /tmp/${MODEL}_${N}.sdf
gz model --spawn-file=/tmp/${MODEL}_${N}.sdf --model-name=${MODEL}_$((1+${N})) -x ${X} -y ${Y} -z 0.1
}
function px4_instance() {
MODEL=$1
N=$2 #Instance Number
if [[ $MODEL == *"rtps" ]];
then
'gnome-terminal' -t "RTPSAgent$N" -- micrortps_agent -t UDP -r $((2020+${N}*2)) -s $((2019+${N}*2)) -n "Drone$((1+${N}))"
fi
working_dir="$build_path/instance_$n"
[ ! -d "$working_dir" ] && mkdir -p "$working_dir"
pushd "$working_dir" &>/dev/null
echo "starting instance $N in $(pwd)"
gnome-terminal -t "SITLDrone$N" -- ../bin/px4 -i $N -d "$build_path/etc" -w sitl_${MODEL}_${N} -s etc/init.d-posix/rcS
popd &>/dev/null
......@@ -121,7 +130,13 @@ if [ -z ${SCRIPT} ]; then
fi
while [ $n -lt $num_vehicles ]; do
spawn_model ${vehicle_model} $n
spawn_gazebo_model ${vehicle_model} $n
n=$(($n + 1))
done
sleep 2
n=0
while [ $n -lt $num_vehicles ]; do
px4_instance ${vehicle_model} $n
n=$(($n + 1))
done
else
......@@ -141,7 +156,14 @@ else
m=0
while [ $m -lt ${target_number} ]; do
spawn_model ${target_vehicle} $n $target_x $target_y
spawn_gazebo_model ${target_vehicle} $n $target_x $target_y
m=$(($m + 1))
n=$(($n + 1))
done
m=0
sleep 2
while [ $m -lt ${target_number} ]; do
px4_instance ${target_vehicle} $n
m=$(($m + 1))
n=$(($n + 1))
done
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment