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.

  • Gibbs

    can i use opencv with this?

  • Gibbs

    thats possible! but it requires a device on the ar.drone to give it internet assess!

  • Anonymous

    Yes, look at the end of that other article: http://gauth.fr/2011/10/follow-a-region-of-an-image-frame-by-frame/

  • Gibbs

    thanks a lot :) im not sure if i should buy one anyway, i have been in love with this for 3 years, but i’m 100% its mostly a toy! if i want to pay that much i could build my own! and the funniest part is making quadricopter self balance in air!

  • Pepito Perez

    After the “make” in the Linux folder examples, It says: “Compilation terminated” and then, some errors… is it normal?? can I continue?? apparently a problem with “curses.h” how can i solve this?? Thanks!!

  • sandeep

    Very interesting and relavant website. Thank you very much. I am trying to setup the environment using ADT on windows 8. Could you suggest if it can work?

  • Anonymous

    I didn’t try, sorry, I guess there’s an API for that but I don’t know if this code is comptatible.

  • lxy0816

    why cant ardrone connect to two devices (one is a PC,one is a Android phone) at the same time ?(one is video playing,one is to control the flying)(sorry,i am not a native English speaker)

  • Anonymous

    likely not

  • Fizuli Valizada

    Hello,
    Firstly, I thank you for such a great tutorial. While trying to install sdk on Ubuntu 14.04 I had many missing package issues by modifying make files I could finally install sdk and run given examples(like navigation, sdk_demo). However, it does not always behave the same way, in most cases I would get errors(I pasted below) that I have no idea why are happening, but sometimes it works just normal. I would really appreciate if you give advice on how I should proceed.

    sudo ./linux_sdk_demo
    Setting locale to en_GB.UTF-8
    Wait authentification
    Wait authentification
    Wait authentification
    ===================+> 192.168.1.1
    Starting thread video_stage
    Failed to open AT
    Starting thread navdata_update

    Video stage thread initialisation

    Video stage thread ended

    Starting thread ardrone_control
    PA : MEMORY SPACE ALLOWED : 40 MB
    Start thread thread_academy_upload
    Start thread thread_academy
    Start thread thread_academy_download
    Academy download stage resumed
    VP_Com : Failed to open socket for navdata
    Academy download stage paused
    FTOSFC: No route to host

  • Fizuli Valizada

    Hello,
    Firstly, I thank you for such a great tutorial. While trying to install sdk on Ubuntu 14.04 I had many missing package issues by modifying make files I could finally install sdk and run given examples(like navigation, sdk_demo). However, it does not always behave the same way, in most cases I would get errors(I pasted below) that I have no idea why are happening, but sometimes it works just normal. I would really appreciate if you give advice on how I should proceed.

    sudo ./linux_sdk_demo
    Setting locale to en_GB.UTF-8
    Wait authentification
    Wait authentification
    Wait authentification
    ===================+> 192.168.1.1
    Starting thread video_stage
    Failed to open AT
    Starting thread navdata_update

    Video stage thread initialisation

    Video stage thread ended

    Starting thread ardrone_control
    PA : MEMORY SPACE ALLOWED : 40 MB
    Start thread thread_academy_upload
    Start thread thread_academy
    Start thread thread_academy_download
    Academy download stage resumed
    VP_Com : Failed to open socket for navdata
    Academy download stage paused
    FTOSFC: No route to host

  • Miguel Rocha Jr

    Hello!
    Congratulations for your website! The world needs people to do things like you did!
    So, I had one awkward issue when I gave the “make” command in ../Linux/Examples.

    First, I had a problem saying that inside of the /Examples/sdk_demo/Build makefile there were a space missing on line 35 (I am not sure about the line, I just assumed since I am a big noob at it). The error is shown below.

    I went to the pointed makefile and gave a tab at the beginning of the line where there was a “cd” command. Well, looked like the problem was solved but now I had another: it is saying that “commands commence before first target. Stop.”
    I am really confused. I would really appreciate a little help.

    Again thank you so much for all your content!

  • https://valizada.com Fizuli Valizada

    I am not quite sure, but I guess you could follow these steps:

    1) In the Terminal application run the following six commands:
    Code:
    sudo apt-get install libgtk2.0-dev
    sudo apt-get install libsdl1.2-dev
    sudo apt-get install libiw-dev
    sudo apt-get install libxml2-dev
    sudo apt-get install libudev-dev
    sudo apt-get install libncurses5-dev libncursesw5-dev

    2) Set “USE_LINUX=yes” in “ARDronelib/Soft/Build/custom.makefile”.*
    3) In the Terminal application go to the “ARDroneLib/Soft/Build/” folder and run make
    4) Open the ARDronelib/Examples/Linux/video_demo/Build/Makefile.
    Add to GENERIC_LIBS in line 47 -lm -lgobject-2.0 -lgdk-x11-2.0
    So that it looked like a
    GENERIC_LIBS=-lpc_ardrone -lrt -lgtk-x11-2.0 -lcairo -lgobject-2.0 -lgdk-x11-2.0 -lm
    5) In ARDronelib/Examples/Linux/Navigation/Makefile add -lm to GENERIC_LIBS
    6) Navigate to the ARDronelib/Examples/Linux. Run make

    Reference: https://svn.ardrone.org/boards/1/topics/show/5907

  • Ronaystein

    Thanks for the tutorial. I am working with the ARDrone developing some applications in Ubuntu with ROS. I saw this tutorial and look very interesting. I am trying to install the SDK, specially I get the following error compiling the examles
    ¿Do you have any idea about this problem?

  • Leslie Nock

    Hey, I’ve also been working on something similar and discovered the curses.h error was caused by not having all the dev libraries installed. When installing the dev libraries, include these:
    sudo apt-get install libncurses5-dev libncursesw5-dev

    Hope this helps!