ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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 ...&gt;<="" p="">

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 have args="-ip $(arg droneip)" so my node initialization looks as follows:

<node name="ardrone_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
    echo roslaunch launch_multi_drone.launch drone_name:=ardrone$i droneip:=192.168.1.$i
done

Now everything seems to work.

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 ...&gt;<="" p="">

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 have args="-ip $(arg droneip)" so my node initialization looks as follows:

<node name="ardrone_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
    echo roslaunch launch_multi_drone.launch drone_name:=ardrone$i droneip:=192.168.1.$i
done

Now everything seems to work.

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 ...&gt;<="" p="">

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 have 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="ardrone_driver1" 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
droneip:=192.168.1.$i &
    sleep 15
done

Now everything seems to work.