(or how to control your Parrot AR Drone over the internet, even with an Airport router)
In 1858 a passionate Frenchman took the first arial photographs known to accessible history. In 1908, a crazy photographer outfitted a crazy adorable pigeon with a tiny camera to share the first set of photos that would show us a ‘birds eye view’ of the world.^1
In 1984 I remember my first airplane flight^2 and in 1993 I took the photo with a Minolta 110 that made me fall in love with photography and in 2013 I went to my first PDXNode meet up with an interest to fly a quadcopter. Aside from pruning some office plants and deciding that I’d have to make my very own lawnmower-bot some day, I wanted to control the Parrot AR Drone from Twitter^3 and have it post a picture in return. While it was ridiculously easy to get up and running (even without ever having setup or used Node before) with Felixge’s Node AR Drone library, I ran into some blocks that night, most notably:
- I couldn’t simultaneously connect to the Internet -and- the Drone blocking me from being able to listen to Twitter -and- control my Drone.
- I couldn’t get the dependent image and video packages installed properly.
A long summer later, a co-worker brought his old AR Drone 1.0 into the office for my hacking pleasure and I was finally able to tackle #1 – and document how you can too, bringing us one step closer to the Twitter Copter Cam.
1. Connecting the Drone to the Internet
To get started, I read up on some excellent tutorials including this one from bimo2700mf on the ARDrone-flyers forums. It would have been 100% perfect as-is if I weren’t stuck with an Airport which does not give one the luxury of setting the router’s own, internal IP address. After reading up on some “ipconfig” magic, I modified his instructions:
1. Connect to the AR Drone's default wifi network.
2. # telnet 192.168.1.1 (the default IP address)
3. # iwconfig ath0 mode managed essid SSIDNAME; ifconfig ath0 inet 10.0.1.2 netmask 255.255.255.0; route add default gw 10.0.1.1;
This assumes that my gateway IP is 10.0.1.1 and that 10.0.1.2 is not yet taken. Since the latest versions of Airport manager don’t give you a nice way to view connected devices, their Mac Addresses and IP addresses, I downloaded a FREE iPhone app called “Fing” that I can use on any network I’m on. Nifty! Other Airport options include 192.168.1.1 and 127.13.0.1 – so be sure to check your config before you try this at home.
This will also prevent your Drone from responding to other apps that require it to be set at 192.168.1.1. If you’re trying to build a better Twitter Copter Cam, then this is not a big deal.
4. Connect to your WiFi network. Ping 10.0.1.2 for fun and you'll see it respond. If it doesn't, you did something wrong.
5. Save this configuration on the AR Drone following bim02700mf's instructions. If you skip these steps, then you will have to repeat steps 1-4 EVERY TIME you crash your drone and have to power down/power up to get it glowing green again.
ADD ON: How to save the config file on your AR Drone
A simple way to create file /data/ap.sh directly on AR.Drone:Inside the Telnet window (step #2 above):
# cat > /data/ap.sh
Then enter the same content from step #3 above replacing “;” with line breaks and end with Ctrl-D (press key “Ctrl” with letter “D”)
Code:
iwconfig ath0 mode managed essid SSIDNAME
ifconfig ath0 inet 10.0.1.2 netmask 255.255.255.0
route add default gw 10.0.1.1
You can check the contents in file /data/ap.sh:
# cat /data/ap.sh
Change the file runable:
# chmod 755 /data/ap.sh
To run it:
# /data/ap.sh
That’s it!^4 Now all I had to do was update my local working copy of ARDrone module, dig up the Twitter script I started on on that magical NodePDX hack night, and edit my client settings to connect to my drone via its new IP address (10.0.1.2). For the interested, you can check out the script in this Gist. (Notice that the inline console logging spits out the tweeter’s handle, so we can tweet a picture back when we’re ready!)
Now, to tell my drone to do a quick dance, all I had to do was tweet from any account, anything with “tinyurl.com/gogonc” in my status (as in “go go node copter”). One can edit the script to listen for anything and I’d like to have a few different command options once I master image capture. Any ideas? Share ’em now and they may just make version 1.0!
Potential FAQ: why not use your computer’s wifi to connect to the drone and tether via USB or bluetooth with your mobile phone? Because I couldn’t get that approach to work. Using a MacOSx MacBookPro I either wasn’t skilled enough or the solution doesn’t exist to force an application to sometimes use one connection and other times use another. I won’t even bore you with the details of what I tried to make this work. Also, I read somewhere that connecting the drone itself to a wifi connection increases its range and I’m positive I’ll want that as soon as I take this baby outside.
As for the next hurdle:
2. Capturing and Sharing Images from the Drone
I ran into a block after upgrading ARDrone module to get the latest bug fixes only to run into an error that seems related to my using an old AR Drone and not the 2.0 version. Seeing as how this has already taken me longer to document than to initially program, I’m glad I decided to call it a night. I may try a simulator next, or working with the underlying image capture functionality in the abstract or find a 2.0 drone to borrow. Or I may jump into writing my own blackbox, having the copter write a flight log to a Google Spreadsheet next. Will mostly depend on what nights I find myself free … and who wants to join in on the adventure.
^1 (It’s taking a lot of energy to stop browsing for more history including Cooper the Cat whose had his own gallery shows, film and coffee table book and focus on this post long enough to get it shared.)
^2 I was in kindergarten and finally old enough to fly alone. (I was in charge of taking care of my brother.) Those were the days parents could walk us to the gates and the stewardesses would give us wings and the other passengers would grow to despise being on the same flight as my brother and I bickered so loudly and persistently that the stewardesses would end up separating us.
^3 After spontaneously volunteering to lead a BarCamp session a short while prior, I’d begun using Temboo (as I was and still am working there) and slightly obsessed with using the APIs in our library to make stuff without really having to go back into development (for reasons that blow even these rambling footnotes out of scope). If you’re wondering “why no Temboo” in the referenced gist code snippets, it’s because we didn’t have support for the Twitter Streaming API at that time. Once I get through step #2 and get images working, I plan on updating this to take advantage of Temboo’s library so that the drone can tweet a picture back.
^4 If you’re thinking, “what about my network that’s password protected”? Read up on ipconfig & ath0 protocol. When I need to, I’m going to start with this handy tutorial on using ipconfig to setup a network with ath0.
2 Comments
Jewel
September 21, 2013 at 10:24 amThat is amazing!
And right back at ya – more drone fun from XOXOfest.
* Ekai toted the drone he used to fly over Burning Man on his back. That’s some rugged construction. https://twitter.com/ekai + https://www.youtube.com/watch?v=m2ThTb6iffA
* Chris Anderson flew one of his drones over the goat field after talking about the implications of drones and the future of farming. http://www.portlandmonthlymag.com/arts-and-entertainment/culturephile-portland-arts/articles/xoxo-2013-chris-anderson-on-drones-and-farming-september-2013 + http://diydrones.com
I’m clearly someone who needs to carve a path in aviation, as I love birds, flying, photography and flying machines. <3
fayeishere
September 19, 2013 at 5:47 pmThis is an eagle: http://www.youtube.com/watch?v=G3QrhdfLCO8