Autonomous AR Parrot Drone 2.0 Flying





Introduction: Autonomous AR Parrot Drone 2.0 Flying

This instructable will give you an EXTREMELY simple and quick way (< 15 minutes) to have an AR Parrot Drone 2.0 fly autonomously with code written by you! The best part of this project is it only requires the drone and a laptop (mac or windows). No modifications to the drone. I will also show you how to stream the video from the drone onto your laptop. Check out a sample program I wrote for my drone:

People have done CRAZY stuff with this, including having a drone that can follow peoples faces or be attracted to objects that are red. This guide is a step-by-step on how to use Felixge's node library to control your drone. Definitely check out what he's done. I did this through trial and error and pared it down to the essentials, best of luck!

Step 1: The Drone

To program your drone, you will first need a drone! I am using an AR Parrot Drone 2.0. The first version may work, but no promises. You can find them at Radioshack, Amazon, etc.

First you will need to get comfortable just controlling the drone with you smartphone/tablet. Download one of the apps such as 'AR.FreeFlight 2.4' to control it. It might be a good idea to leave the indoor bumper hull on at first to minimize damage from collisions. I also suggest flying in an open field or park. 

Step 2: Node JS

The first thing needed for autonomously programming our drone is to download Node JS. It's awesome for web applications with JavaScript and if you are interested you can learn a bit more about it. For our purposes though just download the file. I recommend making a new folder on your computer in your 'C' drive and naming it something like 'Drone'. Move the program into this new folder.

You are halfway to controlling your drone with your laptop!

Step 3: Command Line

Now we will do a bit of work with the command line. Follow the instructions for your type of computer.

The command line program is called 'Command Prompt' and on recent windows versions can be opened by going to 'Start' and searching through the programs or viewing 'all apps'. If confused refer to this help. Once you have the program open type the following line of code and then hit enter:

npm install ar-drone

This will give you access to Felixge’s node.js library so that you can use high level commands such as 'takeoff()' and 'leftFlip' to control the drone. As long as the Command Prompt doesn't throw any errors you are all set to start controlling the drone with your computer! For help using the Command Prompt check this resource.

The command line program on a mac is called Terminal. The easiest way to open it is to click in the Spotlight search bar in the upper right hand of your desktop screen and type 'Terminal'. Then just click on the program called Terminal. Once open type the following line of code and hit enter:

sudo npm install ar-drone

This will give you access to Felixge’s node.js library so that you can use high level commands such as 'takeoff()' and 'leftFlip' to control the drone. As long as Terminal doesn't throw any errors you are all set to start controlling the drone with your computer! For help using Terminal check this resource.

Step 4: Testing

Now that you have Node.js installed with the ar-drone library we can control it with your laptop! To do this, first turn the drone on by plugging in the battery.

Next connect you laptop to the Wi-Fi network named something similar to 'drone######'.

Open up the node.js program. 

Type the next four lines of code into the node.js window and hit enter after each line. (WARNING: as soon as you hit enter on the third line the drone will take off and hover a few feet off the ground until you type the fourth line and hit enter again). Please make sure the drone is in an open space.

var arDrone = require('ar-drone');
var client = arDrone.createClient();

It works! Woohoo! This is a good way to check that everything was installed correctly. If you come across any errors you may need to go back to the last step and download the 'ar-drone' library again. 

Step 5: Autonomous Program

Now the exciting part! We will make some autonomous programs for the drone. This is a huge advantage over what we just did because rather than typing the code line by line we can send a whole program to the drone and it will execute it sequentially for some flawless and exciting flight. 

To do this we will need to write programs in JavaScript. Don't fear if you don't know JavaScript we will mostly be using the same cut and paste commands. If you are interested you can read up on it HERE. We will need a text editor to write our code in, I recommend Sublime Text. Just download it and then upon opening it will open a new file we will type all the lines of our code directly into Sublime Text, as shown in the picture for this step. Then when saving the program make sure to save the file with '.js' at the end of the name and it will automatically become a JavaScript file! 

For now copy my simple program in the picture and save it as 'test.js'. This will have the drone takeoff, hover for a few seconds, and then land. Check the next step on how to run this program.

Step 6: Running Programs

To run the program 'test.js' we first need to know where we saved the file. Move the program into the 'Drone' folder you made in your 'C' drive. Once again we will need to use the command line, for Windows open Command Prompt, and for Mac open Terminal. 

Turn your drone on and connect the laptop to its Wi-Fi connection. Type the following line of code and hit enter:
node c:\Drone\test.js

What this is doing is having the node.js program run the file test.js which is stored in the 'Drone' folder in the 'C' directory. By looking at the line of code hopefully this makes sense. When running a different program only the name 'test.js' needs to be changed as long as the program is located in the 'Drone' folder.

If the drone took off, hovered, and landed you did it! 

Step 7: Functions

Now you have everything you need to autonomously fly your drone. To write more complicated programs you will just have to know a few functions that the drone is capable of. Below I show the name and describe what they do. You should also check out Felixge's README file that was included with the ar-drone library as it has tons of beneficial information.

takeoff() - has the drone takeoff and hover above the ground
land() - has the drone land
up(speed) - has the drone gain altitude at a speed between 1 (max speed) and 0 (still).
down(speed) - makes the drone reduce altitude
clockwise(speed) - drone spins clockwise
counterClockwise(speed) - drone spins counter-clockwise
front(speed)/back(speed) - changes the pitch causing horizontal movement
left(speed)/right(speed) - changes the roll causing horizontal movement
stop() - keeps the drone hovering in place
(for complex functions like flips and manuevers, check out the README file linked above)

All of these functions can be used in a long list with a dedicated time between them by using the format:

    .after(5000, function() {
    .after(3000, function() {

The amount 5000 is the time in milliseconds that the drone will turn clockwise for at 0.5 of its top turning rate (1 being max and 0 being still). We can see for the stop function that it doesn't have a speed because it takes care of that itself. By making a long list of commands like this we can set up an autonomous task list to carry out. I have copied the code that my drone ran, in the video on the first page, below:

var arDrone = require('ar-drone');
var client  = arDrone.createClient();


  .after(2000, function() {
  .after(2000, function() {
  .after(1000, function() {
    this.animate('flipBehind', 500);
  .after(1000, function() {
  .after(1000, function() {
    this.animate('flipRight', 500);
  .after(5000, function() {
  .after(2000, function() {
  .after(5000, function() {
  .after(2000, function() {;

Hopefully this will give you a good idea of how your program outline will look.

Step 8: Streaming Video

For all the super awesome applications like face tracking you will have to stream the video from the ar drone. One easy way to do it is to download ffmpeg. After downloading go ahead and run it. A command line type window will pop open (you can see a picture of mine on this step). You will need to make a new JavaScript program using the Sublime Text editor as described in step 5. Copy and paste the code below into a file and save it as 'video.js' in your 'Drone' folder (Sorry I couldn't upload any '.js' files).

var arDrone = require('ar-drone');
var http    = require('http');

console.log('Connecting png stream ...');

var pngStream = arDrone.createClient().getPngStream();

var lastPng;
  .on('error', console.log)
  .on('data', function(pngBuffer) {
    lastPng = pngBuffer;

var server = http.createServer(function(req, res) {
  if (!lastPng) {
    res.end('Did not receive any png data yet.');

  res.writeHead(200, {'Content-Type': 'image/png'});

server.listen(8080, function() {
  console.log('Serving latest png on port 8080 ...');

Now run this program by typing the following line into the command line window that opened when you ran ffmpeg. Don't forget to hit enter.
node c:\Drone\video.js

Go to your web browser (any one will work) and go to the following website (you can just copy/paste it):

You will now be getting a stream of the video that your drone is viewing through the front camera! You can see a picture of what mine was viewing along with some of my bookmarks :)

CONGRATS! You are now set to begin doing some awesome stuff with you drone. Feel free to check out Felixge's library if you are interested in using the video feed from the drone to do things such as track and follow people's faces (this uses a program called OpenCV). Best of luck.

2 People Made This Project!


  • Science of Cooking

    Science of Cooking
  • Trash to Treasure

    Trash to Treasure
  • Paper Contest 2018

    Paper Contest 2018

We have a be nice policy.
Please be positive and constructive.



Hey I’ve been trying to do this step for a while now but the only thing that says is that there is no ar-drone module. Can you help me out on how I can add it? I’ve already typed the npm instal ar-drone command. I’m stuck in this step


Hi all, Im fairly new in regard to programming for a drone so please bare with me if my questions sound "newb-ish". Everything regarding programming for the Parrot AR drone is a few years old. It seems odd because I've found alot of cool things with the AR drone 2.0. Has anyone else noticed that? Is there a better, more accurate, newer model of a drone for this sort of programming? My background is in C++ but I'm open to trying any language to make an autonomous obstacle avoiding drone.

You can try the Parrot Bebop 1 or Parrot Bebop 2.


Hey great work but i would like to know would this be possible of a self made fpv drone , what all components would be needed and how would it be programmed ?

Great instructable Patrick! One very quick question. Would this work with the first generation of Parrot Drone ? I'm not too familiar with the protocols used as my drones all use 2.4GHz transmitter/receiver. Is the basic communication API the same between the 2 Parrot versions. Many Thanks

Great instructions. Love it! Just one thing I wanted to mention to the community, your example program in step five doesn't work (for me at least). It is having the drone takeoff, immediately land (so fast that it doesn't even take off), then land again after a certain amount of time. I believe it should be:

var arDrone = require('ar-drone');

var client = arDrone.createClient();



.after(5000, function() {;



This is awesome!!! I had no idea I could do this with my parrot

Will this program work with other drones?

Wow, that actually sounds pretty interesting. Definitely worth checking out and maybe upgrading the Parrot if I can do it right :) Thanks! If I may, you can also check out this review, and take a look how these guys took a different approach with this model.

Someone please help me before I shoot myself. I had everything going well, then started a 'client.createrepl()' in node. Now I can't do anything because within terminal everything I write comes back with:

ReferenceError: client is not defined

at repl:1:1

at REPLServer.defaultEval (repl.js:262:27)

at bound (domain.js:287:14)

at REPLServer.runBound [as eval] (domain.js:300:12)

at REPLServer.<anonymous> (repl.js:431:12)

at emitOne (events.js:82:20)

at REPLServer.emit (events.js:169:7)

at REPLServer.Interface._onLine (readline.js:211:10)

at REPLServer.Interface._line (readline.js:550:8)

at REPLServer.Interface._ttyWrite (readline.js:827:14)

I have tried stopping it, ctrl D, system/stop 0 and nothing works. Now I am at a loose end and considering suicide.

Please help me. Thank you in advance.

Not sure if you figured this out already but the command should be as followed: client.createRepl()

Take not of the capital letter on the command. :)

Be sure that you are defining the ar-drone library and create the client before trying the command:

var arDrone = require('ar-drone');
var client = arDrone.createClient();