I hope you all watched the Royal Institution Christmas lectures on hacking your home. The series covered two of the most interesting interactive computational systems of the 21st Century (so far) – smartphones and drones. Both of these systems have already had a huge impact on modern society, and the potential for autonomous land, marine, and aerial vehicles to contribute hundreds of billions of pounds to the global economy is very real. Last year a couple of Andy Rice’s PhD students and I took on the challenge of bringing these two systems together and building an all-smartphone drone. This integration has been performed before to some degree, but normally using an Arduino or similar embedded processor to perform the real-time hardware control. We wanted to develop a solution which used only the smartphone for all aspects of sensing, planning, command and control.
A smartphone is all you need to build an autopilot for a plane. There, I said it. It’s a bold (and italicised) statement, but it is true. A smartphone contains inertial sensors to determine roll, pitch and yaw; GPS to know global position and altitude; a wealth of radio communication options; and plenty of processing grunt. It even packs a couple of cameras. So we set about proving that it could be done.
The first challenge lay in our output options to send control messages from the smartphone to the plane. We wanted to make use of the headphone jack from the smartphone, rather than use an On-The-Go port connection. This was for a number of reasons, including the limited number of devices with OTG ports, and the attraction of the “purity” of the headphone jack solution. The idea that we would be playing “just the right sort of music” down the headphones in order to make the phone fly the plane was quite a neat one. However standard aircraft designs incorporate a rudder, elevator, and ailerons. This means that three independent control signals are needed to fly the aircraft. A headphone jack however only provides left and right channels – just two control signals. Our solution was to choose a flying wing, or delta wing, design for our aircraft. This is the iconic shape of the US B2 stealth bomber and by turning the entire aircraft into a single wing only two control channels are needed (elevator and aileron). Technically the control surfaces of a delta wing take on a new name (elevon) because the same moving flaps fulfill the tasks of both elevator and aileron. The right sort of music, by the way, is pulse width modulation. To you and me it just sounds like a nasty buzzing sound, but no one said the music that makes a plane fly would be symphonic. However, our smartphone UAV pilot sounding a lot like an angry bee is actually rather poetic. The smartphone pilot was christened Captain Buzz for obvious reasons…
The second challenge lay in tuning the control loops for the autonomous controller. There is a good reason why most people use an Andruino or similar for the controller when attempting to build a smartphone drone – the lag from sensing to control output through the Android system is pretty high. Probably because the Android development team did not have a fixed wing autopilot in mind when brainstorming the likely uses of this operating system. We used PID controllers within our control loops, and many of the parameters needed to be tuned gradually by hand in test flights. We could overcome the lag to some degree, but the smartphone drone will always wander sluggishly around the sky compared to an Arduino counterpart. However, in the words of JFK, we chose to do this and other things, not because they are easy but because they are hard. Admittedly, the moonshot was definitely harder than this.
A third challenge lay in safely developing the autopilot software through live test flights. You cannot tune the parameters statically on the ground, the system has to fly for both it and us to learn various system behaviours and parameter settings. To do this safely we made use of a “buddy box” which is traditionally used to train novice human pilots. The buddy box is mounted in the plane and two controllers are hooked up to it, with one set of outputs from the buddy box running to the plane’s control surfaces and engine. We used standard radio equipment to fly the aircraft to a safe height and position, and then a switch on the human’s controller allowed the smartphone in the cockpit to take control of the elevons. The human pilot maintained throttle control and could always switch back to full control in an instant as needed. This system allowed the smartphone controller parameters to be determined over a series of test flights safely.
A fourth challenge lay in the mounting of the smartphone and buddy box in the airframe. A smartphone seems relatively light and compact, but is actually a relatively awkward shape to mount into the narrow confines of a standard aircraft fuselage battery bay. We struggled to maintain a good centre of gravity with a conventional off-the-shelf delta wing design, plus we wanted a slower flying aircraft with larger lifting area than the standard designs provide, and so turned to a laser cutter to 3D print our own aircraft. Our smartphone mounting point became an external pod running underneath the delta wing, hacked into place courtesy of a bit more laser cutting and a hot glue gun.
After quite a few test flights to tune over a dozen parameters we have a relatively stable autonomous aircraft. Captain Buzz has his own Google+ page, so you can follow more of his antics there over the coming months. There are a couple of YouTube videos of test flights linked from that page too. We will be adding some more functionality, and doing an interview for BBC Radio Cambridgeshire during a live flight once the weather picks up. At the moment Buzz can turn onto provided compass headings and maintain stable flight in turns and on the level. By providing a sequence of GPS waypoints to Buzz he can look at his current GPS position, calculate a bearing to the new waypoint, and turn onto that heading. This is the essence of waypoint following for an autonomous platform.
If reading this and watching our videos has inspired you to fly remote control aircraft, or to build a flying robot then please read the following very carefully. The CAA regulations on flying devices must be followed at all times, read the air navigation guidelines very carefully before flying anything outdoors.