Programming a flying bull with Node.js, Coffeescript and Parrot AR 2.0 Drone

When I was very young, my father used to take me to an airfield where hobbyists would gather to show off their model planes. I think that memory forced my hand into buying a Parrot A.R. Drone 2 a month ago.

The Parrot AR 2.0 Drone is now widely available with a 1GHZ ARM Cortex A8 Processor, 720p frontal camera, 240p bottom camera, Wi-Fi and a ton of other features and sensors. There is also an SDK available for anyone to build an app to control the drone. With that, Felix Geisendörfer, a node.js core contributor, created an awesome library called node-ar-drone. It’s very easy to use, and equally dangerous! You might end up running the drone against the walls several times while getting the hang of it; but you can get started pretty quickly.

Now to the good stuff: videos and demos!

In a nutshell, you can control the drone in a “verbal” way, like so:

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


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

As you see the library is pretty straight-forward, but it also has more low-level controls. Using the libraries, I was able to build a “drone-bull”, as in an angry drone that seeks and destroys red stuff! (And one time it destroyed a glass with some water, after it picked up a Pepsi can next to it).

Not bad for only a few hours of work! (minus debugging and getting the drone out of the ceiling when it flew away and wouldn’t come back)

If you want to check out the code (fair warning: it’s messy and it’s coffescript!) you can grab it here:

The logic is pretty straightforward. For each video frame received, I process it finding the amount of red pixels in the picture. If the number of red pixels is greater than 300, the drone-bull will ram the object and then turn around.

It also does face-tracking, but i don’t suggest enabling it at the same time as color tracking, unless you want to get a few laughs and scares.

I hope this post gets you pumped up to go and buy a drone and make it do fun, useful or mischievous things. Who knows, maybe one day we can have an R/GA army of drones, or you can participate in the next

  • Patrick Donnelly

    And I noticed that none of you were wearing red –  or is that an if then loop clause ? 

  • Patrick Donnelly

    And I noticed that none of you were wearing red –  or is that an if then loop clause ? 

  • Martin Nahuel Rabaglia

    Exactly. Actually… that happened when we started testing it. Look at this video