How to connect to the simulated drone

Once a simulation got launched, a drone is lying in the middle of the scene, waiting to be connected by a controller.

Depending on the drone model, the connection is achieved using various physical links. The table below shows the supported link(s) for each drone model.

drone virtual ethernet wifi bluetooth
Airborne no no yes
Bebop yes yes no
Bebop2 yes yes no
Disco yes yes no
Mambo no no yes
Swing no no yes

You might want to check the How to take off your drone page for detailed information on each drone requirements and capabilities.

Virtual ethernet

Sphinx creates a virtual ethernet interface on host side as well as in the simulated drone. On host side, the interface is generally called fd_veth0 and has the IP address 10.202.0.254. On drone side, it is called eth1 (see ‘interface’ element in the .drone file) and gets the IP address 10.202.0.1.

To use the virtual ethernet link, the controller application should run on the host so that the local interface is accessible. If you really need to run the controller application from another machine belonging to the same IP network, you need to activate the port forwarding mode, by using the following command line option.

$ sphinx --port-forwarding=<remote_machine_IP_address> <my.drone>

Note: Be aware that port forwarding only works if the required ports are not already taken by another process running on the host.

Now, using the appropriate API, you just need to indicate to the SDK stack what is the drone IP address to connect:

  • either 10.202.0.1, if the controller application is running directly on the host.
  • or the IP address of the host, if the port forwarding mode is activated.

Bluetooth

Several drone models only accept to be connected via a Bluetooth link. To be able to connect by Bluetooth, you need a compatible Bluetooth hardware. Please check the page system requirements (bluetooth) for more details.

The drone section of your .drone file needs an element stolen_bdaddr properly set, meaning that it expects the Bluetooth MAC address of the host. You can easily find it by entering the command:

$ hciconfig
    hci0:   Type: BR/EDR  Bus: USB
    BD Address: 00:1A:7D:DA:71:03  ACL MTU: 310:10  SCO MTU: 64:8
    UP RUNNING
    RX bytes:676 acl:0 sco:0 events:47 errors:0
    TX bytes:2703 acl:0 sco:0 commands:47 errors:0

Once your .drone file is set and the Bluetooth hardware ready, just launch sphinx. The simulated firmware should be connectable through Bluetooth Low Energy from a device implementing ARDroneSDK3 stack.

Testing with Freeflight Mini is of course possible, exactly as if you were trying to connect to a real drone.

_images/freeflightmini_discovery.png

To retrieve the bluetooth identifier (UUID) of the simulated drone, you must first obtain the identifier of your running firmware instance:

$ fdc list instances

Then, enter the following command:

$ fdc show instances <instance_name> | grep cmdline | sed 's/ /\n/g' | awk -F= '$1 ~ /ro.sphinx.btfriendlyname/{print $2}'