2024-10-25 14:49:07 -03:00
|
|
|
#!/bin/bash
|
2024-11-01 12:47:35 -03:00
|
|
|
set -e #PR #6
|
2024-10-25 14:49:07 -03:00
|
|
|
source /opt/ros/$ROS_DISTRO/setup.bash
|
2024-11-01 12:47:35 -03:00
|
|
|
|
|
|
|
if [[ -z $SIM_DRONE_COUNT ]]
|
|
|
|
then
|
|
|
|
echo "SIM_DRONE_COUNT environment variable is not set."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2024-10-25 14:49:07 -03:00
|
|
|
gz sim -v -r $WORLD_FILE_NAME &
|
|
|
|
while true
|
|
|
|
do
|
|
|
|
topics=$(gz topic -l)
|
|
|
|
if [[ $topics == *"/world/$WORLD_NAME"* ]]
|
|
|
|
then
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
sleep 1
|
|
|
|
done
|
|
|
|
|
2024-10-29 17:00:57 -03:00
|
|
|
cd /ardupilot_gazebo/models/$DRONE_MODEL
|
2024-10-25 14:49:07 -03:00
|
|
|
for (( j=0; j<$SIM_DRONE_COUNT; j++ ));
|
|
|
|
do
|
2024-10-31 13:28:03 -03:00
|
|
|
xacro -v gstreamer_udp_port:=$(($GSTREAMER_UDP_PORT + ($j * 10))) fdm_port_in:=$(($FDM_PORT_IN + ($j * 10))) model.xacro.sdf -o model.sdf
|
2024-11-01 12:47:35 -03:00
|
|
|
#! string is better than using -file option. File is not up to date in the next iteration.
|
2024-10-29 17:00:57 -03:00
|
|
|
value=$(</ardupilot_gazebo/models/$DRONE_MODEL/model.sdf)
|
2024-11-01 12:47:35 -03:00
|
|
|
gz_drone_name=spiri-$(($j + 1))
|
|
|
|
#? Maybe read from text file for formation of drones? x y z r p y
|
|
|
|
ros2 run ros_gz_sim create -world $WORLD_NAME -string "$value" -name $gz_drone_name -x $j -y 0 -z 0.195
|
2024-10-25 14:49:07 -03:00
|
|
|
done
|
|
|
|
exec "$@"
|