0
$\begingroup$

Rosanswers logo

Hi all, I am using ROS Kinetic on Ubuntu 16.04 and am trying to fly and control multiple drones at the same time running a single script using ardrone_autonomy. I manage to connect to the two drones, and get 2 separate nodes created for 2 separate instances of ardrone_driver.

My problem is that the different topics of ardrone_autonomy only have a single instance. This means that all my drones read off of the same topics (i.e. all drones read off of the same /ardone/takeoff topic) and thus get the same commands. I would like to have a way to give each drone a different command, either by having 2 separate takeoff topics and cmd_vel topic and land topics and so on, or by any other means possible.

All the posts I can find are from 2014 or older, and I am not sure if any significance changes have been made since, and where this stands now.

Has anyone gotten this working? Any help would be greatly appreciated.


Originally posted by oha on ROS Answers with karma: 35 on 2018-03-27

Post score: 0


Original comments

Comment by melhazzouri on 2018-06-25:
Hi man,

I am trying to do the same thing for a school project. I am new to ROS and I honestly do not know where to start. Would you be able to share what you did?

Thanks in advance!

Comment by oha on 2018-06-26:
For what I did to get the multiple drones working I tried to explain the best I could in the answer below. I will be glad to tell you how I got started in general and recommend some things, but I will need you to post a question so I am not limited on characters and stuff when answering.

Comment by oha on 2018-06-26:
Link your post here or tell me the numb er of the post (you can see it in the URL) so that I can find it.

Comment by melhazzouri on 2018-06-26:
Hi, https://answers.ros.org/question/295383/controlling-multiple-drones-using-ros/ The question is called "Controlling multiple drones using ROS and the number is 295383. Thank you!!

Comment by ahmad abid on 2018-08-22:
hi oha ! can yoou please send me your current code in which all the drones follow the same command? because im currently at this initial stage and want to have any sort of code for multi drones to work in swarm...pl send me all the files(codes) including launch file and others too. thx in advance :)

Comment by oha on 2018-08-23:
I guide I made with some code can be found here: https://gitlab.com/ohanoch/MSS_Guides/blob/master/Drones/launching_multiple_ardrones_guide.pdf and code I used to implement it can be found here: https://gitlab.com/ohanoch/MSS_drone_camera_project

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

Ok, so I have an answer - remap! There is an option inside the launch file to remap one topic to a different name. Here is an example of how I remapped /ardrone/takeoff to /ardrone1/takeoff:

<remap from="/ardrone/takeoff" to="/ardrone1/takeoff"/>

I put this line before the node initialization line: <node ...>

Using remap I could now remap all the topics I wanted for the first drone to change "ardrone" to "ardrone1" and for the second drone remap again, but this time to "ardrone2" - thus getting two separate topics for the two drones, namely for /ardrone/takeoff example we get:
/ardrone1/takeoff
/ardrone2/takeoff

Now I had a problem that I wanted to do this for ~30 topics. As far as I can tell there is no way to just change /ardrone/ with /ardrone1/ and thus with a single remap changing all the topics at once. I looked around and found some github issues mentioning that it is not supported, and in any case I couldn't figure it out. Sadly this meant I had to manually remap the 30 topics (if someone found a better way I would be very happy to see it).

But I do not want to manually edit 30+ topics every time I want to add another drone, its not fun and it looks terrible. So what I ended up doing is have a BASH script that had a for loop for the amount of drones I want and ran the launch file that many times. In order for this to work I now needed to change my launch file and add the following lines:

<arg name="droneip" default="192.168.1.1" />
<arg name="drone_name" default="ardrone"/>

In order to accept in arguments for the drone name and IP. Then in my remap commands I needed to change ardrone1 with $(arg drone_name) to look like the following:

<remap from="/ardrone/takeoff" to="/$(arg drone_name)/takeoff"/> 

and when initializing my node I need to make the node name change with name="$(arg drone_name)_driver1" and the ip change args="-ip $(arg droneip)" so my node initialization looks as follows:

<node name="$(arg drone_name)_driver1" pkg="ardrone_autonomy" type="ardrone_driver" output="screen" args="-ip $(arg droneip)">

My BASH script is short and looks as follows:

#!/bin/bash
for (( i=1; i<=$1; i++))
do
    roslaunch launch_multi_drone.launch drone_name:=ardrone$i droneip:=192.168.1.$i &
    sleep 15
done    

Now everything seems to work.


Originally posted by oha with karma: 35 on 2018-04-10

This answer was ACCEPTED on the original site

Post score: 0

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.