ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
Ill try to give a more simplified answer than my answer on https://answers.ros.org/question/286722/controlling-multiple-drones-using-ardrone_autonomy/
The first thing you need to do is connect your computer to all the wifi connectors of all the drones. This seems to be a problem, since all the ardrones by default give themselves the IP 192.168.1.1, but there is a solution! I took the solution from the following link, which is explained very well:
https://github.com/AutonomyLab/ardrone_autonomy/wiki/Multiple-AR-Drones
The basic Idea is to give the drones static IP addresses and tell them to connect to a certain network, that you create on your PC or router. I used a router to create this network, and connect the drone to it. My router is a Netgear Nighthawk R7000 and a tutorial I made can be seen here:
https://github.com/ohanoch/MSS_Guides/blob/master/NetGear/netgear_nighthawk_router_setup_guide_for_multiple_ardrones.pdf
This tutorial might still be helpful for other routers, as the general setup might be similar, but I really don't know. Notice the wireless network you make should not be WEP/WPA secured as this can cause issues.
In order to change the network configurations you need to telnet into the drones and create a script that will do so when run, this is explained in the tutorials mentioned above better than I can do here.
The only thing not mentioned there is that you will need to telnet into each drone and run the script after every reboot of a drone. This is a bit tedious, but is safe, as if you made a mistake or have your drones network settings wrong for some reason then just rebooting it will get you back to a state that can be managed. That being said I assume you can enter the command to run the script into /etc/rc.local or something in order to make it run it automatically on boot, as this is a Linux system and thats how you can generally do it on them. I haven't tried this and can't vouch for it.
I made my own guide for configuring the drones, as well as creating the launch file (which I explain below), which you can find here:
https://github.com/ohanoch/MSS_Guides/blob/master/Drones/launching_multiple_ardrones_guide.pdf
Its mostly made redundant by the other tutorials, but I thought it might help, and in any case can't hurt.
I used the following launch file and bash script. Feel free to use these files. Launch file:
<launch>
<!-- declare variables to be taken in from parameters -->
<arg name="droneip" default="192.168.1.1" />
<arg name="drone_name" default="ardrone"/>
<!-- remap ardrone topics to specific topics per drone -->
<remap from="/ardrone/land" to="/$(arg drone_name)/land"/>
.
. About 30 remaps. run `rostopic list` to get a list of topics.
.
<remap from="/ardrone/takeoff" to="/$(arg drone_name)/takeoff"/>
<remap from="cmd_vel" to="/$(arg drone_name)/cmd_vel"/>
<!-- create node for drone -->
<node name="$(arg drone_name)_driver1" pkg="ardrone_autonomy"
type="ardrone_driver" output="screen" args="-ip $(arg droneip)">
<param name="navdata_demo" value="False" />
<param name="realtime_navdata" value="True" />
<param name="realtime_video" value="True" />
<param name="looprate" value="30" />
</node>
</launch>
The launch file launches a single drone with the given variables for node name and IP address that are given as parameters when running the launch file. If you run rostopic list
you will be able to see that all of your ardrone_autonomy topics now change "ardrone" with the drone name you provide, i.e. "/ardrone/takeoff" becomes "/<name_provided>/takeoff". This is done using the "remap" line in the launch file and is explained better in the answer to my original post at:
https://answers.ros.org/question/286722/controlling-multiple-drones-using-ardrone_autonomy/
This allows you to run the launch file multiple times, once for each drone you want, and by giving different names and IPs you will be able to connect and control the drones separately.
The script does precisely that:
#!/bin/bash
# This bash script will run launch_multi_drone.launch with different drone names for the amount of drones specified.
# This will initialize nodes for the amount of drones specified as well as separate topics for each drone.
# Each drones topic will be of the form /ardrone#/<topic_name>. i.e /ardrone/takeoff => /ardrone42/takeoff for drone # 42
# usage: launch_multiple_drones.sh <num_of_drones>
for (( i=1; i<=$1; i++))
do
roslaunch launch_multi_drone.launch drone_name:=ardrone$i droneip:=192.168.1.$((9+$i)) &
sleep 15
done
All it has is a for loop that calls the launch files with the name "ardrone#" and IP 192.168.1.# (where # is the number of the current iteration of the loop). Of-course this can be edited and you can change the name and IP as you wish. Also notice that the script sleeps for 15 seconds after each launch, I found that if I don't do that I get bugs. The script needs to be in the same directory as the launch file to work, or you can just edit the script to call a launch file from a certain directory by just prefixing it to the launch file call in the for loop.
At this point if you run the script you will see (by running rostopic list
) different topics made for each drone. You can send your ROS commands to each topic separately and control each drone as you wish. If you are writing code to control your drones you will need to create separate publishers and subscribers for each drone, and send commands to each drones separate publishers.
This turned out pretty bulky, sorry, I hope it can still help, and if you need further explanations please let me know.