Introduction: Autonomous AR Parrot Drone 2.0 Flying

Picture of 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

Picture of 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

Picture of 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

Picture of 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

Picture of 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

Picture of 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

Picture of 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

Picture of 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

Picture of 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.


HoussamA7 (author)2017-02-04

Please help. I have an issue with a warning that happens after npm install.

MohanMaker (author)HoussamA72017-04-07

Hi. What does the warning that you get say? I might be able to help since I have completed this project many times. Thanks!

HoussamA7 (author)MohanMaker2017-04-30

I will answer you soon. please bear with me.

AlonsoB4 made it! (author)MohanMaker2017-04-28

This is the error

MohanMaker (author)AlonsoB42017-04-29

Looks like you aren't running the file in the directory/folder where you saved it. Before you run npm install ar-drone you need to get in to the directory where you installed .json. Your error indicated that npm install is looking for the .json file in the current directory.

Thanks and good luck.

VyenteR (author)2016-06-26

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.

MohanMaker (author)VyenteR2017-04-29

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


karana35 (author)2017-04-04

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 ?

fraser.white.186 (author)2017-01-17

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

CharleyD2 (author)2016-06-23

So I did all these steps and when I was trying to make the drone use my test.js program nothing happened it just sat there and no errors popped up but nothing happened. what am i doing wrong?

MohanMaker made it! (author)CharleyD22016-11-06

Try this as your program. The program in the instructions 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 think there is just an error with the instructions.

MohanMaker (author)2016-11-06

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() {;



Brandonoutdoors (author)2016-10-25

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

Gym_Goober99 (author)2016-10-03

Will this program work with other drones?

AliceT24 (author)2016-08-26

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.

AndrewW14 (author)2016-04-23

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.

LeslieN9 (author)AndrewW142016-05-10

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();

AndrewW14 (author)LeslieN92016-05-10

Thank you, eventually I did figure it out. Each time I closed the terminal it wanted me to reinstall the library. I didn't know this so was just trying to continue as I was. It was driving me crazy.

Eventually i changed to using Ruby as the programming language and everything fell into place perfectly. I need to remember there's always more than one way to skin a cat (program a drone).

I very much appreciate you taking the time to reply. Thank you again.

LeslieN9 (author)AndrewW142016-05-10

You're very welcome!

Have fun :)

ShridharS5 (author)2016-03-20

I'm currently working on a 3d reconstruction project. so i need to capture multiple view images of the object. Anyone knows how to make the drone go in a circular orbit around an object? Please help!

LeslieN9 (author)ShridharS52016-05-10

ardrone-autonomy would be able to approach this "mission". You could get it to orbit an object fairly easily.

BrunoB7 (author)2016-02-29

Anyone knows if it is possible that the ar.drone can fly alone without existing wirelless connection during the flight ? Since there is only connection when the command is given by the node.js and send it to certain points GPS

AliH1 (author)2014-08-10

I'm on a windows 8.1 and I've done everything correctly yet npm install ar-drone command keeps giving me an ENOENT error. Is this not compatible with windows 8.1? Please advise !!

nsalay (author)AliH12014-09-10

open command prompt.

type: cd c:\[NameOfYourFolder] [enter]

type: npm install npm -g [wait]

when complete,

type: npm install ar-drone [enter\

it should work from here.

I would like to note that when writing scripts, there is no way to stop your drone unless it finishes the script, so start small and work your way up. or try ez-builder.

ChristopherA54 (author)nsalay2015-12-26

i got to my folder n when i got to ur 2nd part type: npm install npm -g [wait] nothing happens? do i wait longer?

nsalay (author)ChristopherA542015-12-26

to be honest, and in sorry, I don't remember writing this.

ChristopherA54 (author)nsalay2015-12-26

its all good if anyone else can help that'll b appreciated

nathanH67 (author)ChristopherA542016-02-07

what you need help with? Got this working and its great, feel free to email me any questions you got!

TeganB (author)nsalay2015-01-05


rinaldo.tjipjes (author)AliH12014-11-27

I have this same exact issue, its sad nobody gave a reply after 3 monts.

mjankowiak (author)2016-01-26

I haven't tried it yet but how do u send the program to the drone and can I do this with any drone, preferably one I have made

nathanH67 (author)mjankowiak2016-02-07

I think you can only do it with this drone do to its open source community and plugins that are supported such as node js, if your drone is supported by javascript and node and has a wifi port you can connect to from your computer, then yeah give it a shot!

GoranČ (author)2014-11-22

I seems that the drone will except the commands only while connected to the laptop via wifi.

Do you know a way to run your program while the drone is disconnected from the phone or computer?

It should involve installing the program on the drones onboard computer.

Any ideas ?

PetrK12 (author)GoranČ2016-01-02

Unfortunately, what the author presents here is actually not a drone's autonomous flight - it's rather laptop-controlled flight without human intervention.

I guess this might be interesting for autonomous flying:

BrentM3 (author)GoranČ2015-04-16

Maybe this will work for you. I've yet to test this myself but it is on the "to do list"

rlburger (author)2015-12-28

In steps 5 and 7 you have to comment out or delete the first; line or the program will not work. Please update!

HarmjanL (author)2015-04-26

when i am testing and i type the first two commands, the var ones it says undefined, when i say takeoff or land it says true, i am probally doing something incerdibly wrong but i don't know what. please help me

lröst (author)HarmjanL2015-10-17

After ( i use terminal) writing the lines;
> var arDrone = require('ar-drone');

> var client = arDrone.createClient();

I also get undefined, just continue with:

client.(the command)

So for instance



MarkV13 (author)2015-10-10

Hey, I'm running into an issue when attempting step 8, running ffmpeg's FF Prompt and entering the node... command doesn't do anything except throw an error about 'node' being an unknown command :/ how do I resolve this?

TeganB (author)2015-01-06

Video Won't stream unless constantly refresh page??

MEN1 (author)TeganB2015-08-07

I have the same problem

JasperD2 (author)2015-06-24

Will the code let it fly exact pathes? as i want it to fly a very specific route trough my home.

jwflammer (author)JasperD22015-07-17

you could use painters tape, get it in green or blue from the dollar store (cheap and you will use a lot of it ) and you and tape out a colored track for it to fly but that's for close to the ground flying

MátéM (author)2015-07-14

I've done something very similar with my AR Drone:

I was thinking about using the Web Speech API to control it with my voice. I might do that later :)

JaredD2 (author)2015-06-30

Is it possible to save the latest .png file that is viewed in the browser to my Drone file (i.e., save the image generated in step 8)? I want to be able to analyze these frames in real time for tracking purposes.


greigt1 (author)2014-10-04

I have got most things working and BTW thanks for a clear simplistic how to.

I have got to the Run a Program section and cannot get a .js program to run. In the node.js console I get an UNDEFINED error after I execute the

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

lines of code, however, the next two lines for take-off and land work and the AR-Drone flies.

Now when I make a test.js file and try to load it using the node.exe command prompt I get three dots ... on the following line, so something seems to be running but the AR-Drone is not responding.

Any clues to what I might be doing wrong?

theonenandrew (author)greigt12015-06-19

Try closing node.js and just using the regular cmd. Type node c:\Drone\test.js or whatever folder you saved the test.js in. Also, you need to remove the first; from the script. Basically, the script is telling the drone to take off and immediately land. The last 5 lines of the script are what tells the drone to land after 5000 ms.

yuckoz (author)greigt12014-12-06

Have you already found a way to fix this? I have the exact same problem and can't figure out why it won't work. The script has no faults and the drone seems to be receiving it but it won't do anything except for blinking it's green led's..

BrentM3 (author)yuckoz2015-04-01

Hi yuckoz, griegt1 - did you guys manage to get this going at all. The test.js file in neither being seen by 'command prompt' [cmd] or node.exe

I'm totally clueless after spending a day so far installing and uninstalling trying to work this out - patience is a virtue as they say.

BrentM3 (author)BrentM32015-04-16

sorted so it's all cool... back on track and the learning curve is slow but meaningful... cat doesn't like the drone flying in the house :)

Check out this site as well:

A lot of useful tips

About This Instructable




Bio: I hope to help people with the things I make.
More by Patrick S:Guitar BackpackDIY Prosthetic Leg Foam Cover (Cosmesis)Tact: Low-cost, Advanced Prosthetic Hand
Add instructable to: