Raspberry Pi

Android Autonomous Drone, Part 1: Intro

I have a long standing passion of all things remote controlled; be it planes, helicopters, cars, you name it. That passion has been eclipsed for the last few years by coding, and more specifically, Android development. The time has come to get back to it though. Armed with my coding experience and some tasty new technology, many possibilities have opened up that I would never have thought possible before.

This article was also published on Medium.

Android Things

Not too long ago Google released a new flavor of Android to the family; Android Things. This stripped down version of the world’s most popular OS still includes plenty of the high level functionality us Android Devs are used to, but also adds a new set of APIs that are indispensabl to embedded applications; direct access to GPIOs and hardware interfaces.

Having already done some development on Arduino based platforms, and hearing the joyful news that Android Things had direct support for the Raspberry Pi, I was one of the first to download and flash the new OS onto an SD for my Pi.

The biggest challenge I had faced with embedded programming was the massive gulf between simple micro-controllers like the Arduino family, and the full OS based SOCs like the Raspberry Pis and Qualcomm’s Dragonboard. One was too simple and other had too much overhead.

I wanted all the features and functionality of an Android OS (and Android Studio for that matter) but also easy access to low level hardware (I’ve yet to find any other Android version for embedded devices that isn’t a nightmare to access even GPIOs). Android Things is built for exactly that purpose. While still only in Developer Preview 3, the features that are present are more than enough for some very interesting projects.

The projects I have in mind for Android Things are growing quite steadily actually, with this drone, a full RC transmitter with HD video streaming, and an Android powered 3D Printer all either ongoing or to be started very soon. But those are for another article.

Coding above your weight class

I’ve never coded anything as mathematically complex as an autonomously flying drone before, so there’s a lot to learn and a lot of challenges ahead for sure. I’m also going to need another custom frame designed for my 3D printed RC quadcopter (you can see the current progress in the header image). 

Disclaimer: I’m quite possibly biting off more way than I can chew with this project, but why should that stop us trying eh?

The first thing I look for when tackling a new project with a skill set I don’t have, is an online course (preferably a free one). Control of Mobile Robots hosted on Coursera comes to the rescue as the perfect candidate. My impression from the first few videos is that the professor has all the hallmarks of a great teacher, and it looks to be a wonderful course for a relative novice to the field. There are a few others on Coursera tackling the subject of autonomous drones, but the above course looks to be the easiest to get started with.

Expectations / Goals

As the term “autonomous drone” can cover anything from the very basics to 5+ years of research and development, let’s define some goals for this first version:

  • Can take off to a stable hover and land (gently!) without outside intervention.
  • Has relatively decent heading and altitude holding.
  • Understands high level control commands from an external source (Go forward x distance, turn x degrees etc.).
  • Avoids obstacles.

I think that’s probably more than enough of a challenge to get started with, though far from what I hope will be the final feature set down the line.

Challenges / Difficulties

While I have limited experience in embedded software design, I am very comfortable with the Android OS and it’s development tools. There are still some things I believe will prove to be quite difficult however:

  • Reliable communication between a base-station and the drone, and a fast acting kill switch if things go wrong.
  • The complex mathematics and extensive control theory necessary for stable autonomous flight.
  • Interfacing with the sensors for altitude holding and object detection.

I’m hoping that even with these challenges the goals outlined above will not be impossible, or that I’ll at least learn enough in failing to try again from a different angle or with a new setup.

In part two I’ll be going through the design and 3D printing of the custom frame, the parts I intend to build all this with, and interfacing with my Naze32 style flight controller.

Until then, feel free to comment any advice or thoughts you have, or recommend if you like this article. Happy coding!