On the Necessity of Flight

Editor’s note: Our team participated in many of the Summer of Innovation events held by Laurie (@lsptahoe) and her team. Here’s a recap of the IoT Hackathon held at Oracle HQ, July 30-31. Enjoy.

“The wind was a torrent of darkness among the gusty trees,
The moon was a ghostly galleon tossed upon cloudy seas…”
The Highwayman, Alfred Noyes

To Luis, Osvaldo, and me this beautiful poetry calls to mind one thing. Quadcopters. We started flying these machines about a year ago. The Syma X1, for example, costs ≅$30 and I cannot recommend it enough. Guilty feelings come with this amount of fun and exhilaration, at this price. Relax. Order now!

Syma X1: AA batteries not included.

Syma X1: AA batteries not included.

So for a recent Oracle Internet of Things Hackathon, our first idea was to stick sensors on a quadcopter. We could have used the Syma X1 but we were ready to graduate to something more–programmable with the potential for autonomy–like the Parrot AR Drone 2.0. At an almost affordable $300, you get a very fun and very hackable quadcopter. You can telnet right into the thing. I mean, come on! There are even JavaScript libraries available to control it and grab live video from its two cameras, or you can use any Android or iOS device to fly while you see what it sees.

Parrot app with video + controls.

Screenshot of Parrot app shows streaming live video + controls.

Trust me here. You can justify the use cases and guarantee the safe, professional operation of a quadcopter in a corporate environment. And you can do it with less than 100 emails, discussions, and offhand comments executed strategically over the course of a year or so. A quadcopter seed will, if properly nurtured, sprout a seedling of official approval. Only minutes after approval, that seedling grows propellers.

Parrot AR Drone 2.0 + masking tape + LightBlue Bean.

Parrot AR Drone 2.0 + masking tape + LightBlue Bean.

The Parrot hatches. I hear its first peeps–beeps–and 2 seconds later it flies the nest. I close my front door behind me, the Parrot hovers outside. Surreal excitement, I fly. Flight! Flying! Crashing, fixing, caring, charging. Repeat, repeat,…

Now to the Hackathon. In a nutshell, our idea automates warehouse data collection: find merchandise, identify malfunctioning temperature/humidity sensors, go where people cannot, and such. Tape a LightBlue Bean and maybe some sensors onto the Parrot’s back, write some JavaScript to fly the quad around, do a little dance, and fly home. One problem: upon arriving the morning of the hackathon we were informed that due to safety concerns no drones would be allowed to fly in the venue. We had prepared for this so we went off to our already-booked private meeting room, GoPro in hand, ready to code and create a demo video.

But there was another problem. We could barely control the Parrot. We did not shell out for a Parrot with GPS, and we naively thought that a magnetometer would provide the data needed to precisely control flight. But that’s not the way the world works, baby. How many times did our code raise the Parrot into the air only to flip it over on its back or careen it into a wall? So many times, it was truly disheartening. At first we didn’t even have a clue what the problem might be. In our minds, as software guys, you tell the drone to go forward for 500ms and it goes directly forward as commanded. But what’s “forward” mean? The compass was not accurate and our other efforts…

quadcopter tiles

This did not work.

…no, the checkerboard does not help the Parrot go forward, does not help the flipping, nor the careening, nor the crashing. Something needed to be done and we did not have much time left. What about the Parrot’s eyes? The JavaScript libraries access video and images from the Parrot’s cameras. Grab an image, follow a line half way down the image, and check 10% of the pixels for something close to the color red. If the red target is to the right, go right. If the red target is to the left, go left. If the red target takes up 75% or more of the image, stop.

Will you believe me if I tell you it worked? It did! When carrying our red target, the Parrot would follow us around the room. Our simple code performed smoothly. Amazement, disbelief, and joy! Strangely, surreally, the Parrot seemed alive. All by itself, like a puppy coming to play, it knew how to get around.

The drone loved the color red so much, we had to cover up a few things.

The drone loved the color red so much, we had to cover up a few things.

Then it stopped working. We had split the code into parts: control, vision, sensors, UI. At one point, the code worked properly but then we got fancy. In our confidence we quickly added frills like a little dance, and a flip! Then the Parrot kept losing sight of the target. We only had two batteries and we did not have enough charge to debug. In retrospect, I think it started acting poorly when I tweaked the RGB color identifier function. We needed a video and had just enough charge for this…

See how jerky it acts? That’s me controlling it. When the code works, it runs much more smoothly. Given these complications, and some stiff competition, we did not win anything at the hackathon. I think Luis, Osvaldo, and I are OK with it though. The Parrot works well and if we get some more time to mess with it, it will fly autonomously once again.

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.