Control the AR Drone over LTE
April 7, 2014

A tutorial on how you can control your AR drone over your iPhone's LTE connection.

Warning: This is a fairly technical article that requires familiarity with node.js, PHP, iOS, SSH and the command line.

Two weeks ago, I picked up my first AR Drone 2.0 Power Edition. I've been nothing less than impressed by how awesome this thing is to fly (and hack)!

After flying it a few times with the iPhone app, I quickly realized how short the wifi range was and thought "I wonder how I can make this better...". So, I set out to hack the drone and come up with a solution for extending the control from ~160ft to as far as reliably possible.

To my knowledge, this hasn't been done before...

The goal of this project was to extend the range on the AR drone so I didn't need to worry about how far away it was OR chasing it down the street until I was in range again. In the process of doing this, I contemplated countless solutions ranging from purchasing equipment to hacking the drone itself. I didn't want to pay for anything (since I just dropped ~$400 on the drone) and wanted to make use of what I already had — my cell phone (do they make drone-proof cases?).

With hacking my iPhone at the forefront of my objective, I quickly researched various ways to run code. At first, I tried to compile node on my phone but had no luck doing so.

Not long after, I ran into a curious iPhone package called "ios-lighttpd-php-mysql".

I started playing around with stuff and after a few days, managed to successfully control my AR drone using my phone's LTE connection.

Here's how it works

Upon startup, the AR drone creates an ad-hoc network which it then uses to communicate. Your iPhone connects to it and becomes a relay-mechanism that bridges your drone with a public server (I used my personal web server in this case). When any packets are sent from the drone to the phone, they're relayed to the server and vice versa. This only works because your iPhone uses client sockets and not server sockets (which are blocked by AT&T's firewall).

The public server runs a TCP/UDP server that accepts connections as they come in; your iPhone and your computer both connect to this server. Anytime data comes from your iPhone or computer, it's simply broadcasted to the opposite connection in the bridge; thus, creating the "full circle".

Requirements

Now that I've talked about how this works — let's get you up and running! Here's what you'll need to get started:

  1. a jailbroken iPhone 5
  2. an AR Drone (2.0 preferably - as I haven't tested 1.0)
  3. a public server with SSH access
  4. a computer running the latest version node.js
  5. ... patience!

Follow the steps below to get this up & running. If you run into any problems, please drop me a comment so we can get you online with your drone ASAP.

Prepping your iPhone

  1. Install MobileTerminal and OpenSSH from Cydia
  2. Add the http://ios-webstack.tk/cydia/ repo.
  3. Install the "ios-lighttpd-php-mysql" package.
  4. You should now have PHP 5.4 successfully running on your iPhone. You can test this by visiting http://127.0.0.1 in your iPhone's Safari browser.

Prepping your computer

  1. Download and install node.js.
  2. Clone git@github.com:felixge/node-ar-drone.git from GitHub (you'll need this for controlling the drone).
  3. Run npm install from the directory you cloned in the previous step.
  4. Clone git@github.com:bkw/node-dronestream.git from GitHub (you can use this to view the video stream from your AR drone)
  5. Run npm install from the directory you cloned in the previous step.
  6. Clone git@github.com:carldanley/drone-lte-relay.git from GitHub.
  7. Browse through the repo cloned in the previous step and replace all instances of yourdomain.com (like this) with the domain name of the server you're going to run these scripts from.

Installing the Scripts

  1. SSH into your iPhone and copy the scripts from the iPhone folder of the "drone-lte-relay" repo to /var/www on your iPhone.
  2. SSH into your server and copy the scripts from the server folder of the "drone-lte-relay" repo to whatever directory you want.

Controlling the drone over LTE

  1. SSH into your server and cd into the directory where you copied the server scripts.
  2. Run php udp-server.php.
  3. Connect your iPhone to your AR drone's ad-hoc network.
  4. On your iPhone, open MobileTerminal and run php /var/www/udp-relayer.php; you should see text appear in the server console AND the iPhone MobileTerminal.
  5. On your computer, cd into the directory where you cloned git@github.com:felixge/node-ar-drone.git.
  6. Follow the steps listed at https://github.com/felixge/node-ar-drone#client to create repl.js
  7. Change the line that reads:
    var client = arDrone.createClient();
    to read:
    var client = arDrone.createClient( { ip: 'your.servers.ip.address' } );.
    — Obviously, replace your.servers.ip.address with your server's IP address.
  8. Run node repl.js.
  9. Play with your drone via repl.

Streaming video over LTE

  1. SSH into your server and cd into the directory where you copied the server scripts.
  2. Run php tcp-server.php.
  3. Connect your iPhone to your AR drone's ad-hoc network.
  4. On your computer, cd into the directory where you cloned git@github.com:bkw/node-dronestream.git.
  5. Run node example/createServer/app.js.
  6. On your iPhone, open MobileTerminal and run php /var/www/tcp-relayer.php; you should see text appear in the server console AND the iPhone MobileTerminal.
  7. Open http:/127.0.0.1:5555 on your computer and witness your drone's LIVE video stream over LTE.

Demo (tl;dr)

Here's a demo of it working — "the proof of the pudding is in the eating"; I talk through most of what I mentioned above as a recap.

The Results

It's works amazingly well for me.

After having tested control of the drone over LTE and streaming live drone video, I'm extremely impressed with the results. I can fly the drone farther than ever with no lag whatsoever; it's pretty awesome!

Please feel free to drop me a comment if you have questions or want to share a better way to control your drone over LTE.