The Voice-Controlled, Face Recognizing, Drone Journey – Part 1

Total Shares

Introduction to the Drone Journey

Laying The Groundwork

This post is the first one covering my step-by-step journey to build an autonomous, voice-controlled, face recognizing drone. It is inspired by the post from Lukas Biewald I referenced in my introduction blog post. If you follow this entire series (warning – there are 10 more pots coming up) you will be able to completely replicate what I have built.

As a hacker I am sure there are better and more efficient ways to do some of the coding I will show. If you make things better let me know and I am happy to create a “making things better” blog!

Assumptions

My starting point in this post assumes a few things:

  1. That you have bough a Parrot AR drone 2.0. This is the one I bought.
  2. That you have checked the drone works using one of the supplied apps and that you can see its wireless network from your windows computer.
  3. That you have got a machine running the anniversary edition of windows. Most people have that by now but if you are not sure this post might help.
  4. You have access to a wireless network
  5. You know the name and password of your secured wireless network (I assume WPA2 security).
  6. You can assign a static IP address for your wireless network.

Focus of this post

In this “long” post I am going to cover:

  • The basics of getting node.js installed on your windows computer.
  • Getting the BASH shell installed on your windows computer.
  • Installing a node.js library to interact with the drone
  • Connecting our computer to the wireless network of the drone and control it via an interactive session of node.js.

Getting Node.js installed on your windows computer

The first thing you need to do is navigate to http://www.nodejs.org. Node JS Web PageFrom there you can simply download the correct package.

At the time of writing the download most recommended is V6.9.4 LTS as shown in the image.

I would suggest you download and install the package that is recommended for most users. Once downloaded you should execute the downloaded MSI file and keep all the default settings unless you want to install the files in a different location.

If all has gone well you should be able to open a command window Node Install Checkand simply type “node -v” as shown in the image to the left.

If you get a response of “v6.9.4” then in this case you are all good to go. If you install a different version the returned number should match what you installed.

An important note is that you need to open the command window AFTER your install finishes otherwise the node executable will not be in the path and it will fail.

All good. Your node.js install is done and we can move on.

Creating your development space

The next step is to create a space where you can build out your node.js projects. In my case I am creating a directory Development on  my c drive. Within  that I have then created a directory called Drone. The command window commands I used (assuming you are installing off the root of your c drive) are:

  • cd \
  • mkdir Development
  • cd Development
  • mkdir Drone
  • cd Drone

You can of course also create this with windows explorer.  This will be the place we do all our node.js development and where we store all our files. From now on when you open a command window typing “cd \Development\Drone” will get you to that folder directly.

Next lets get the BASH Shell Installed

One of the node packages we will need  to use (the one we will later use to get the drone onto our secured WPA2 network) only works from within a unix/linux style environment. I could not find a windows version.  For a while I started to think I would need to setup a virtual machine and install some environment just to do a basic part of this development.

Then I remembered. Microsoft added the BASH Ubuntu shell to the anniversary edition. Yes.. Microsoft loves Linux that much. I am not going to list all the steps (it is very easy) since there is an excellent post that shows you everything here.

Just a note of caution. It could be that when you select developer mode the various developer packages need to be located and downloaded before you can move into installing BASH Ubuntu. Dependent on your network speed that can take sometime so a bit of patience might be required.  Also – once you select to install the BASH shell, and it completes, you will then be asked to reboot so save your work first.

Once installed you use it pretty much like any unix/linux shell and the same page, linked above for installation, shows those with little Linux experience all you need to know. We are not actually doing that much heavy lifting so don’t worry if you are not familiar with Linux.

The one thing I ran into is that after closing the bash shell and restarting it you need to get back to the mnt directory so that you can find your files. This is not needed when you first install as it takes you to the right place automatically.

To locate your files you need to use the following commands in the bash window:

  • cd ..BASH Shell
  • cd ..
  • cd Development
  • cd Drone

 

Remember Linux/unix is case sensitive so if you do not use the right case it will not find the directory. This is important as a later step will see us download and install the hack we will use to get the drone onto our WPA2 secured wireless network and it will get installed in that directory so you need to be able to get back there.

Downloading the “ar-drone” Node.js package

This is the first part that overlaps some with a little of what Lukas covered in his post. There is a great package called “ar-drone” that allows you to connect to, and interface with, your drone.  As you do more things this location will become super useful as it documents the commands you can use.

Before we can install the package, and as this is the first time doing things, we need to create a package.json file. Think of this as a description of your project and all its required files. You can create this yourself, if you know the options, or you can run a utility.

We will use the utility having changed directory to the appropriate place. You only need to do this when creating a new project.

The command is “npm init” as shown below.

NPM Init1

You will then be asked a series of questions.

  1. Set the name to “drone_project”
  2. Set the version to “1.0.0”
  3. Give a description of “Drone Project”
  4. For all other options simply hit enter/return except for Author (provide your name) and Keywords (use Drone).

You should then see it suggests a package.json file as shown below which you can confirm it should create.

NPM Init 2

Given we want to use this package in our project the first thing you need to do is to download and install it.

To do that simply type “npm install ar-drone” from within the C:\Development\Drone directory. You will get a warning but that is simply as we are not connected to a repository where we might push our project.

If you do not like warnings then open the package.json file that was created and add  “private” : true , to the JSON just under the version number and it will go away on this install and all future installs.  If you do that then the final package.json file looks as shown below.

Package.json

Interactively controlling the Drone

If you are still with me at this point then you are almost ready to use the node.js REPL (Read-Evaluate-Print-Loop) facility in the same way that Lukas did in his blog. This is also explained on the package documentation.

The first thing we need to do is to connect our laptop to the same network that the drone is emitting. With your drone turned on you need to go to your network settings and find the network that has the name “ardrone2” in it and connect to it.

Now your computer and the drone are sharing the same network. There should be no issues connecting as the network is open and does not require a password.

So now we need to create a file called repl.js with the following lines in it and save it:

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

Once saved you can execute this file using the command “node repl.js” as shown below.

Node REPL JS

From there you can run the command “takeoff()” which will cause the drone to take off to about 1 meter high and then “land()” which will cause it to land. If you want to play around you can make the drone move about clockwise etc using other commands.

Congratulations. You can now control your drone from your computer.

Smashes

When I was reading the post from Lukas he stated that if you got this far you have probably crashed the drone a few times playing with it. I laughed and thought that was just bad piloting… alas he was right.

In my case I managed to do so much damage flying my drone into a wall I needed to actually open up a motor drive and repair it. I give thanks to “TheGrach13” for his YouTube video at this point. That was it.. my warranty was now void but I was having fun 🙂.

When I add to that the bent propellers (bought some spares), the battery running out every 10 mins (bought an extended life one) and the tools I needed to repair I felt like I was slowly becoming a Parrot Drone engineer and a Drone parts workshop.

I hope this step by step guide fills in a few gaps and gets you on the journey.  I look forward to continuing it next time.

Next up

In the next blog I will explain how I went about doing the following:

  • Controlling the drone via a node.js application when you are both on the default wireless network
  • Hacking the drone  so that it could operate on the same WPA2 secured wireless network I am on (we need Internet access later).
  • Installing express to setup a simple web server in node-js land
  • Building a basic web application to control the drone using express

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.