Running multiples drones in a simulation

Thanks for your quick reply! I have two wifi interfaces. Here are my two .drone files:

<?xml version="1.0" encoding="UTF-8"?>This text will be hidden
<drone 
    name="bebop2_1"
    firmware="/home/hai/ROS/hai_ws/src/bebop2_toolbox/bebop2_sphinx/firmware/ardrone3-milos_pc.ext2_4.4.2.zip"
    hardware="milosboard">
    <machine_params
        low_gpu="false"
        with_front_cam="false"
        with_hd_battery="false"
        with_flir="false"
        flir_pos="tilted"/>
    <pose>1 0 0.2 0 0 0</pose>
    <interface>eth1</interface>
    <!-- 'wlan0' may need to be replaced the actual wifi interface name -->
    <stolen_interface>eth0:eth0:192.168.42.1/24</stolen_interface>
   </drone>

and

<?xml version="1.0" encoding="UTF-8"?>This text will be hidden
<drone 
    name="bebop2_2"
    firmware="/home/hai/ROS/hai_ws/src/bebop2_toolbox/bebop2_sphinx/firmware/ardrone3-milos_pc.ext2_4.4.2.zip"
    hardware="milosboard">
    <machine_params
        low_gpu="false"
        with_front_cam="false"
        with_hd_battery="false"
        with_flir="false"
        flir_pos="tilted"/>
    <pose>-1 0 0.2 0 0 0</pose>
    <interface>eth1</interface>
    <!-- 'wlan0' may need to be replaced the actual wifi interface name -->
    <stolen_interface>dev30:eth0:192.168.42.2/24</stolen_interface>
   </drone>

And the bebop_driver lauch files:

<?xml version="1.0"?>
<launch>
    <arg name="namespace" default="bebop2_1" />
    <arg name="ip" default="10.202.0.1" />
    <arg name="drone_type" default="bebop2" /> <!-- available drone types: bebop1, bebop2 -->
    <arg name="config_file" default="$(find bebop_driver)/config/defaults.yaml" />
    <arg name="camera_info_url" default="package://bebop_driver/data/$(arg drone_type)_camera_calib.yaml" />
    <group ns="$(arg namespace)">
        <node pkg="bebop_driver" name="bebop_driver" type="bebop_driver_node" output="screen">
            <param name="camera_info_url" value="$(arg camera_info_url)" />
            <param name="bebop_ip" value="$(arg ip)" />
            <rosparam command="load" file="$(arg config_file)" />
        </node>
        <include file="$(find bebop_description)/launch/description.launch" />
    </group>
</launch>

and

<?xml version="1.0"?>
<launch>
    <arg name="namespace" default="bebop2_2" />
    <arg name="ip" default="10.202.0.2" />
    <arg name="drone_type" default="bebop2" /> <!-- available drone types: bebop1, bebop2 -->
    <arg name="config_file" default="$(find bebop_driver)/config/defaults.yaml" />
    <arg name="camera_info_url" default="package://bebop_driver/data/$(arg drone_type)_camera_calib.yaml" />
    <group ns="$(arg namespace)">
        <node pkg="bebop_driver" name="bebop_driver" type="bebop_driver_node" output="screen">
            <param name="camera_info_url" value="$(arg camera_info_url)" />
            <param name="bebop_ip" value="$(arg ip)" />
            <rosparam command="load" file="$(arg config_file)" />
        </node>
        <include file="$(find bebop_description)/launch/description.launch" />
    </group>
</launch>

Now I got the following issue:
(1) Even launch with only one drone in sphinx using the firmware version 4.4.2, I cannot run the bebop_driver launch file successfully. I got the error:

[ERROR] [1584316039.436036190]: [ARDISCOVERY_Connection] 00:47:19:436 | ARDISCOVERY_Connection_ControllerInitSocket:669 - connect() SO_ERROR: 111 Connection refused
[ERROR] [1584316039.436087379]: [ARDISCOVERY_Device] 00:47:19:436 | ARDISCOVERY_Device_NewARNetworkAL:243 - error: Socket access permission denied
[ERROR] [1584316039.436104709]: [ARCONTROLLER_Network] 00:47:19:436 | ARCONTROLLER_Network_New:355 - error: Error during the getting of the ARNETWORKAL_Manager from the device

(2) If I use the latest firmware (4.7.1), I can launch one drone in the sphinx and run the bebop_driver to connect to it successfully.

(3) However, with firmware 4.7.1, if I launch two drones in the sphinx and try to run the bebop_driver launch file, I got an error in the sphinx terminal:

[Err] [DataProvider.cc:284] Failed to write on socket 116

and could not run the bebop_driver successfully.

I am using Ubuntu 18.04 and ROS melodic. I’m not sure if this leads to the problem.

1 Like

In drone files:

  1. for second drone try to change line:
    <interface>eth1</interface>
    to
    <interface>eth2</interface>
  2. for every drone IP in line stolen interface is:
    192.168.42.1/24

In launch files:

  1. IP addresses for drones should be:
    <arg name=“ip” default=“10.202.0.1” />
    <arg name=“ip” default=“10.202.1.1” />
    <arg name=“ip” default=“10.202.2.1” />

    because all drones should be in the same subnet.

Hope it will help.
If won’t, maybe it is the issue of ROS version or firmware as you pointed out. When I was doing my project I was working with Ubuntu 16.04 and ROS Kinetic

1 Like

I have changed the second .drone file to eth2. But it does not solve the connection problem. It might be the issue of the ROS version and the firmware version.

Anyway, thanks a lot for your help and quick reply. There does have some strange issue running the bebop_autonomy under Ubuntu 18.04 and ROS Melodic, e.g.
roslaunch bebop_nodelet.launch fails on 18.04/Melodic/src · Issue #170 · AutonomyLab/bebop_autonomy · GitHub

I’ll reply here if I solve the problem later :slight_smile:

Hi all, I had a similar problem in the sense that:

  1. I wanted to simulate and control multiple separate Anafi drones
  2. I wanted to connect to each drone individually through the API (Olympe)
  3. I only had 1 physical ethernet adapter on my laptop

After reading through the thread, I was able to get a working solution that I wanted to document for anyone who stumbles upon this in the future. @ocrave gives a working solution, which is linked to this post. However, I wanted to build upon it, as it took me a while to understand how it all worked.

To start when you run the command:

$ sphinx /opt/parrot-sphinx/usr/share/sphinx/drones/anafi4k.drone::stolen_interface=

According to my understanding, you are creating an anafi4k drone that has a stolen interface that is not connected to an ethernet adapter on your PC. Thus it creates only a virtual ethernet connection which you can connect to in your python code. I believe the only downside to this is that you won’t be able to connect any real controller to the simulation, as these require an actual network connection. So for instance, after launching the simulator, you can see the virtual ethernet the Anafi is connected to, and you can ping it using:

$ iwconfig
>>> ...
>>> fd_veth0  no wireless extensions.    // <-- The virtual ethernet
>>> eth0      no wireless extensions.       // <-- My actual ethernet
$ ping 10.202.0.1
>>>  ...
>>> 64 bytes from 10.202.0.1: icmp_seq=1 ttl=64 time=0.091 ms  // <-- The drone responding
>>> ...

Now using this I simply duplicate the drone and place it in a different position as shown below (note I also turn off the front camera as suggested by @ocrave):

sphinx /opt/parrot-sphinx/usr/share/sphinx/drones/anafi4k.drone::stolen_interface=::pose="2 0 0.2 0 0 0"::with_front_cam=true /opt/parrot-sphinx/usr/share/sphinx/drones/anafi4k.drone::name=other::stolen_interface=::pose="-2 0 0.2 0 0 0"::with_front_cam=false

As you would expect, this creates two virtual ethernet connections on my computer as shown below:

$ iwconfig
>>> ...
>>> fd_veth0  no wireless extensions.    // <-- The virtual ethernet for drone 1
>>> fd_veth1  no wireless extensions.    // <-- The virtual ethernet for drone 2
>>> eth0      no wireless extensions.       // <-- My actual ethernet

Okay here is where it took some time to figure things out. If you now want to connect to both drones, you need to know what IP addresses they are. As I am using a simulated drone, the default IP address is 10.202.0.1. So using Olympe, I wrote some basic code to test the drone. The code is below:

import olympe
from olympe.messages.ardrone3.Piloting import TakeOff, moveBy, Landing

drone = olympe.Drone("10.202.0.1")
drone.connection()
drone(TakeOff()).wait()
drone(moveBy(0,  1, 0, 0)).wait()
drone(moveBy(0, -1, 0, 0)).wait()
drone(moveBy(0,  1, 0, 0)).wait()
drone(moveBy(0, -1, 0, 0)).wait()
...
drone(Landing()).wait()
drone.disconnection()

When I run this code, you can see that the first drone’s motors start to spin, and the drone moves. Now, all we need is the second drone’s IP address. Following advice from @ocrave I assumed the second drone’s IP address would be 10.202.0.2. After running some tests, including using the ping command, I found that this is not the case (at least for me). I was able to connect to the second drone using the same python script above however, I needed to use the IP 10.202.1.1. Below are the results of my tests. Here is a link to the Video.
MultiDrone
I hope this helps someone in the future.

2 Likes