#6 (comment) and fix drone name
This commit is contained in:
parent
dfdcb284f8
commit
3078feb2fb
|
@ -1,11 +1,17 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
set -e #PR #6
|
||||||
source /opt/ros/$ROS_DISTRO/setup.bash
|
source /opt/ros/$ROS_DISTRO/setup.bash
|
||||||
|
|
||||||
|
if [[ -z $SIM_DRONE_COUNT ]]
|
||||||
|
then
|
||||||
|
echo "SIM_DRONE_COUNT environment variable is not set."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
gz sim -v -r $WORLD_FILE_NAME &
|
gz sim -v -r $WORLD_FILE_NAME &
|
||||||
while true
|
while true
|
||||||
do
|
do
|
||||||
topics=$(gz topic -l)
|
topics=$(gz topic -l)
|
||||||
echo $topics
|
|
||||||
if [[ $topics == *"/world/$WORLD_NAME"* ]]
|
if [[ $topics == *"/world/$WORLD_NAME"* ]]
|
||||||
then
|
then
|
||||||
break
|
break
|
||||||
|
@ -13,17 +19,14 @@ do
|
||||||
sleep 1
|
sleep 1
|
||||||
done
|
done
|
||||||
|
|
||||||
if [[ -z $SIM_DRONE_COUNT ]]
|
|
||||||
then
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
cd /ardupilot_gazebo/models/$DRONE_MODEL
|
cd /ardupilot_gazebo/models/$DRONE_MODEL
|
||||||
for (( j=0; j<$SIM_DRONE_COUNT; j++ ));
|
for (( j=0; j<$SIM_DRONE_COUNT; j++ ));
|
||||||
do
|
do
|
||||||
xacro -v gstreamer_udp_port:=$(($GSTREAMER_UDP_PORT + ($j * 10))) fdm_port_in:=$(($FDM_PORT_IN + ($j * 10))) model.xacro.sdf -o model.sdf
|
xacro -v gstreamer_udp_port:=$(($GSTREAMER_UDP_PORT + ($j * 10))) fdm_port_in:=$(($FDM_PORT_IN + ($j * 10))) model.xacro.sdf -o model.sdf
|
||||||
|
#! string is better than using -file option. File is not up to date in the next iteration.
|
||||||
value=$(</ardupilot_gazebo/models/$DRONE_MODEL/model.sdf)
|
value=$(</ardupilot_gazebo/models/$DRONE_MODEL/model.sdf)
|
||||||
#-string is better than using -file option. File is not up to date in the next iteration.
|
gz_drone_name=spiri-$(($j + 1))
|
||||||
ros2 run ros_gz_sim create -world $WORLD_NAME -string "$value" -name spiri-$j -x $j -y 0 -z 0.195 ##Possible read from text file for formation of drones.
|
#? 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
|
||||||
done
|
done
|
||||||
exec "$@"
|
exec "$@"
|
Loading…
Reference in New Issue