Running multiples drones in a simulation

Thanks for reply!
I have two separate wifi interfaces, in .drone files I have different names, poses, interfaces and stolen_interfaces. I also deactivate front camera for both drones.
When I run simulation with only one drone (using first or second file) everything is ok. But when I run both drones I have trouble.

This is the output from sphinx:

bqla@bqla-Lenovo:~$ sphinx  /opt/parrot-sphinx/usr/share/sphinx/drones/bebop2_local.drone  /opt/parrot-sphinx/usr/share/sphinx/drones/bebop2_local2.drone
Sphinx simulator version 0.29.1

connecting to firmwared version: 0.29.1
Gazebo multi-robot simulator, version 7.0.1
Copyright (C) 2012-2015 Open Source Robotics Foundation.
Released under the Apache 2 License.
http://gazebosim.org

[Msg] Waiting for master.
Gazebo multi-robot simulator, version 7.0.1
Copyright (C) 2012-2015 Open Source Robotics Foundation.
Released under the Apache 2 License.
http://gazebosim.org

[Msg] Waiting for master.
[Msg] Connected to gazebo master @ http://127.0.0.1:11345
[Msg] Publicized address: 127.0.0.1
[Msg] Connected to gazebo master @ http://127.0.0.1:11345
[Msg] Publicized address: 127.0.0.1
[Msg] created parameter server on http:8383
[Msg] connected to firmwared
[Msg] Preparation of firmware http://plf.parrot.com/sphinx/firmwares/ardrone3/milos_pc/latest/images/ardrone3-milos_pc.ext2.zip
[Msg] Preparation of firmware http://plf.parrot.com/sphinx/firmwares/ardrone3/milos_pc/latest/images/ardrone3-milos_pc.ext2.zip
[Msg] firmware /usr/share/firmwared/firmwares//ardrone3-milos_pc.ext2.zip.a3223a5b-4bd8-9583-54ad-cb89d0a34087.firmware supported hardwares: 
[Msg] 	milosboard
[Msg] Selected params to build .sdf file for bebop_leader:
	param flir_pos = tilted
	param kalamos_clip_far = 35
	param kalamos_clip_near = 1.5
	param low_gpu = 0
	param with_flir = 0
	param with_front_cam = 0
	param with_hd_battery = 1
	param with_kalamos = false
[Msg] Selected params to build .sdf file for bebop_follower_1:
	param flir_pos = tilted
	param kalamos_clip_far = 35
	param kalamos_clip_near = 1.5
	param low_gpu = 0
	param with_flir = 0
	param with_front_cam = 0
	param with_hd_battery = 1
	param with_kalamos = false
[Wrn] [BaseCameraSensor.cc:412] vertical_camera: parameter 'num_buffers' is now deprecated.
[Wrn] [BaseCameraSensor.cc:412] vertical_camera: parameter 'num_buffers' is now deprecated.
[Err] [ContactManager.cc:282] Filter with the same name already exists (default/body)! Aborting
I shd: omniscient_bebop_leader: created: generation=2 sample_count=4000 sample_size=184 sample_rate=1000 metadata_size=1083
I shd: time_bebop_leader: created: generation=2 sample_count=4000 sample_size=24 sample_rate=1000 metadata_size=128
I shd: battery_bebop_leader: created: generation=2 sample_count=4000 sample_size=8 sample_rate=1000 metadata_size=48
I shd: gps_bebop_leader: created: generation=2 sample_count=4000 sample_size=48 sample_rate=1000 metadata_size=245
I shd: omniscient_bebop_follower_1: created: generation=2 sample_count=4000 sample_size=184 sample_rate=1000 metadata_size=1083
I shd: time_bebop_follower_1: created: generation=2 sample_count=4000 sample_size=24 sample_rate=1000 metadata_size=128
I shd: battery_bebop_follower_1: created: generation=2 sample_count=4000 sample_size=8 sample_rate=1000 metadata_size=48
I shd: gps_bebop_follower_1: created: generation=2 sample_count=4000 sample_size=48 sample_rate=1000 metadata_size=245
[Msg] Drone bebop_leader[69abecfe09af8446a4f4aea6681b376cfae59839] loaded
[Msg] Drone bebop_follower_1[680158ee8c5108d80902c2a64a89e324a26b5cd8] loaded
[Msg] WEB DASHBOARD IS ACCESSIBLE at http://localhost:9002
[Msg] Instance efficacious_adelina[69abecfe09af8446a4f4aea6681b376cfae59839] started
[Msg] Instance garrulous_bellatrix[680158ee8c5108d80902c2a64a89e324a26b5cd8] started
[Msg] All drones instantiated
[Wrn] [IioObjectPrivate.hh:299] request for sample already ongoing!
[Wrn] [IioObjectPrivate.hh:299] request for sample already ongoing!
[Err] [ImuSensor.cc:475] WaitUntilQueueEmpty: Firmware has not asked for samples for more than 10 secs.
[Err] [ImuSensor.cc:477] 37, 0, 5
[Wrn] [IioObjectPrivate.hh:299] request for sample already ongoing!
[Wrn] [IioObjectPrivate.hh:299] request for sample already ongoing!
[Err] [ImuSensor.cc:475] WaitUntilQueueEmpty: Firmware has not asked for samples for more than 10 secs.
[Err] [ImuSensor.cc:477] 28, 0, 5
[Wrn] [IioObjectPrivate.hh:299] request for sample already ongoing!
[Wrn] [IioObjectPrivate.hh:299] request for sample already ongoing!
[Err] [ImuSensor.cc:475] WaitUntilQueueEmpty: Firmware has not asked for samples for more than 10 secs.
[Err] [ImuSensor.cc:477] 19, 0, 5

Simulation starts, there are two drones, but I cannot connect to them using bebop_autonomy.
As you can see I’ve got some errors that still occur… What do you think about it?

I solve this problem by downloading previous version of bebop2 firmware (v. 4.4.2).
I can connect to both drones with bebop_driver, everything works fine except of front cameras - probably because of my hardware…

Do you remember the version number of Bebop 2 that you were using when it failed? I’ll try to reproduce your issue but it may also have been an issue with bebop_autonomy.

It failed with: latest version, 4.7.1, 4.7.0.
It works with 4.4.2. I didn’t try to run with older versions.

1 Like

How exactly did you modify the .drone file? I downloaded the v4.4.0 firmware but sphinx crashed when I attempted to run sphinx. The downloaded firmware is in .plf format, while the original firmware is in .ext2.zip format.

The plf file is for a real drone. Here is how one can use v4.4.0 instead of the latest version:

sphinx /opt/parrot-sphinx/usr/share/sphinx/drones/bebop2.drone ::firmware=http://plf.parrot.com/sphinx/firmwares/ardrone3/milos_pc/4.4.0/images/ardrone3-milos_pc.ext2.zip

Thanks! I am able to download different version of firmware now. When I apply other version of firmware and run multiple bebops in the same scene, it gives segmentation fault. What might be the cause?

“bqla” said that he/she was using a Bebop2 4.4.2 firmware successfully with two simulated drones.
Have you tried with that firmware version?
Do you have any backtrace of this segmentation fault that you could share here?

In any case, please note that multiple drones in the same simulation is an advanced/experimental/may-be-unstable feature.

Regards
Nicolas

I solved the crashing issue by adding “::with_front_cam=false” at the end of one of the sphinx command like this: “sphnix <.drone file>::with_front_cam=false”. Not sure why, but it works!

I am having an issue when running two drones on the same simulation, basically gazebo is launched successfully but I can’t connect to any of the drones. Does anybody know what could be happening here?
The error that I got is

[Err] [ContactManager.cc.282] Filter with the same name already exists (default/body)! aborting

This error message does not show up when I open the simulator with one drone, that is why I believe it’s the reason.

My drones files are:
<?xml version="1.0" encoding="UTF-8"?>

<machine_params
low_gpu=“false”
with_front_cam=“false”
with_hd_battery=“false”
with_flir=“false”
flir_pos=“tilted”/>
-5 -5 0.8 0 0 0
eth3

<stolen_interface>wlx503eaa7a5259:eth1:192.168.42.1/24</stolen_interface>

And

<?xml version="1.0" encoding="UTF-8"?>
<drone
  name="bebop2"
  firmware="http://plf.parrot.com/sphinx/firmwares/ardrone3/milos_pc/latest/images/ardrone3-milos_pc.ext2.zip"
  hardware="milosboard">
  <machine_params
    low_gpu="false"
    with_front_cam="false"
    with_hd_battery="false"
    with_flir="false"
    flir_pos="tilted"/>
  <pose>default</pose>
  <interface>eth1</interface>
  <!-- 'wlan0' may need to be replaced the actual wifi interface name -->
  <stolen_interface>wlan0:eth0:192.168.42.1/24</stolen_interface>
</drone>

I am running the simulation like this:

sphinx bebop2.drone bebop2_2.drone

First drone is:

<?xml version="1.0" encoding="UTF-8"?>
<drone
  name="bebop2_2"
  firmware="http://plf.parrot.com/sphinx/firmwares/ardrone3/milos_pc/latest/images/ardrone3-milos_pc.ext2.zip"
  hardware="milosboard">
  <machine_params
    low_gpu="false"
    with_front_cam="false"
    with_hd_battery="false"
    with_flir="false"
    flir_pos="tilted"/>
  <pose>-5 -5 0.8 0 0 0</pose>
  <interface>eth3</interface>
  <!-- 'wlan0' may need to be replaced the actual wifi interface name -->
  <stolen_interface>wlx503eaa7a5259:eth1:192.168.42.1/24</stolen_interface>
</drone>

Sorry for the bad formatting

Try downloading firmware 4.4.2 from http://plf.parrot.com/sphinx/firmwares/index.html and modify all .drone files - you have to change firmware to correct path to file, e.g.:

firmware="/home/username/firmware/ardrone3-milos_pc.ext2.zip"

It worked for me.

Hi! Thanks for your experience. I tried to download the firmware 4.4.2 and used it in the .drone file. I could launch (two drones) in the sphinx successfully. However, when I tried to connect to the drone using bebop_driver, I always got an 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

When I changed the firmware to the latest version, I did not get the connection error, but I failed to launch two drones in sphinx. Do you have any clue how to solve the problem?

Hi!
Can you run at least one bebop_driver (connect to one drone) when you are running sphinx with two drones? What IP addresses are you using for drones? Remember that if you want to connect to two drones you have to got two interfaces (for example wifi and eth).
When I was running it I used separate launch file for each drone driver.
I think it would be easier to help you when you show your .drone and .launch files… :thinking:

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