Technical Blog

Introduction to the AR.Drone SDK

What is the AR.Drone ?

The AR.Drone is a quadricopter created by Parrot. It can be be purchased in stores like Amazon.com at a price of around 300 dollars. It is mainly used as a flying video game, and several games has been released using augmented reality.

The drone has two cameras: one frontal and one vertical. The technical specifications can be found here.
The drone can be controlled using any Wifi device. When the drone is turned on, it automatically creates a ad-hoc wifi. The controlling device connects to the wifi, and communicates with the drone. Parrot developed an application for the iPhone and the Android Phones, named AR.FreeFlight. More applications created by other developers can be found on the AppStore, etc.

The SDK

Parrot released a SDK to help developers creating innovation applications using the drone. The SDK is available for iOS, Android, Linux and Windows. Linux and Windows SDK are using the C programming language. In this article, I will focus on the Linux SDK. The specifications of the communication’s protocol used by the drone is also available. Therefore, it is possible to create a new SDK instead of using Parrot’s one.

The SDK and the Developer’s Guide can be found in the AR.Drone Open API Platform. In this article, I am using the version 1.7. Several ways exist to create an application using the AR.Drone. In the developer guide, Parrot recommends to use the AR.Drone Tool, a framework designed to create easily applications.

SDK structure

The root of the archive contains several files and directory:

  • ARDroneAPI.dox: doxygen file, used to generate the documentation.
  • ARDroneLib: AR.Drone library (communication with the drone, video codecs etc.)
  • ControlEngine: files specific to the iPhone.
  • Docs: folder where the documentation is generated
  • Examples: folder containing demonstration code for each platform and the ARDrone Tool.

The archive contains more files than we need. We can remove the ControlEngine directory, and all the directories in Examples except the Linux one.

Building the examples

The examples are useful for several reasons:

  • To check that the system has all the needed libraries.
  • To check that the computer can communicate with the drone

The first step is to install the missing package. If you’re using Ubuntu, a script was developed to install them automatically. ARDroneLib/Soft/Build/check_dependencies.sh must be executed with the root privilege. OK is displayed when all the packages are installed.
When all the packages are installed, we are ready to compile the libraries and the examples:

cd Examples/Linux
make

If you get the following error message:

In file included from ..//VP_Com/linux/vp_com_serial.c:33:
..//VP_Com/vp_com_serial.h:22: error: expected ‘)’ before ‘*’ token

you need to edit the file ARDroneLib/Soft/Build/custom.makefile and change the line

USE_LINUX=no

to

USE_LINUX=yes

We need to connect to the wifi created by the drone when It is turned on. Its name is ardrone_XXXXX, with XXXXX the ID of the drone.
By default, only two IP addresses are used:

  • 192.168.1.1 is the drone.
  • 192.168.1.2 is the device that communicates with it.

Thefore, when we are connected to the wifi, we need to set our IP address. We can use the following command:

sudo ifconfig wlan0 192.168.1.2 netmask 255.255.255.0

If the computer address is not 192.168.1.2, the drone won’t be able to communicate with the computer.
Several examples have been compiled. The most useful one is Build/Release/ardrone_navigation. This graphical application is able to display all the information transmitted by the drone:

  • Camera’s images
  • Battery status
  • Gyroscopic data

The application is able to control the drone movement using a Joystick. Refer to the Developer’s Guide for more information.

Common troubleshooting

Error:

In file included from ..//VP_Com/linux/vp_com_serial.c:33:
..//VP_Com/vp_com_serial.h:22: error: expected ‘)’ before ‘*’ token

Solution:
Edit the file ARDroneLib/Soft/Build/custom.makefile and change the line

USE_LINUX=no

to

USE_LINUX=yes

Error:

undefined reference to symbol ‘some_gtk_function’

Solution:

Some flags are probably missing in the Makefile. A way to fix it is to edit the file Examples/Linux/sdk_demo/Build/Makefile. To add the correct flags, change the following line:

GENERIC_LIBS=-lpc_ardrone -lgtk-x11-2.0 -lrt

to

GENERIC_LIBS=-lpc_ardrone -lgtk-x11-2.0 -lrt `pkg-config --libs gtk+2.0`

Error:

Timeout when reading navdatas – resending a navdata request on port 5554

Solution:
One possibility is that your computer’s IP is not 192.168.1.2. You can set it with the following command line:

sudo ifconfig wlan0 192.168.1.2 netmask 255.255.255.0

Error:
The navigation data always contains zeros:
Solution
This is an error I had with VMWare. I changed my IP (in this case, the eth0 IP) to 192.168.1.3 and since then, I don’t have any more errors like this one. I use the bridged mode to connect to the drone via AirPort.
Error:
The check_dependencies.sh file is not installing the packages.
Solution:
Several problems can exist:

  • You are not using Ubuntu, and therefore the script cannot work. You need to manually install required packages.
  • You are not running the script with the root privilege. Prefix your command line by sudo.
  • The file temporary_file located in the same folder exists and indicates to the script that all the packages are installed. It can happen if you got an archive from an other computer, instead of the official SDK. You simply need to remove this file.
  • Ted

    good tutorial thank you

    Missing flags in the Makefile
    add cflags gtk2 :
    GENERIC_LIBS=-lpc_ardrone -lgtk-x11-2.0 -lrt `pkg-config –cflags –libs gtk+-2.0`

  • Anonymous

    Those flags are already present in the default Makefile provided by Parrot:
    ./ARDroneLib/Soft/Build/config.makefile: GENERIC_CFLAGS+=$(shell pkg-config –cflags gtk+-2.0)
    ./ARDroneLib/Soft/Build/config.makefile: GENERIC_LIBS+=$(shell pkg-config –libs gtk+-2.0)

  • Kiollpt

    how can i work in ardroid platform?
    i use elipse through cygwin compiler (.so)
    but, it doesn’t work….
    ths error say missing XX.h,but xx.h not include in ARDroneLib

  • Raizen87

    Hello!! The error which the variables are vision_detect 0, not resolved, any ideas? The navdata send me the values of velocity or orientation correctly but de vision_Detect no. Thanks

  • sergio

    how to run the sdk in windows

  • Anonymous

    Check the official developer guide, it contains instructions to compile the examples on Windows.

  • http://twitter.com/BlakeAly Blake Aly

    where can i have the android SDK? i can only get the one for iOS. and how am in going to run ar drone using 3g networks instead of wifi? thnx

  • Anonymous

    Android SDK can be found here: https://projects.ardrone.org/projects/show/ardrone-api
    You can’t use 3G directly instead of Wifi as the AR.Drone is communicating through Wifi only, but we can imagine a more complicated client-server architecture where you would connect to a server via 3G that communicates with the AR.Drone using Wifi.