14 January 2013
Simple Drone Flying Algorithms

The AR Parrot Drone seems to be all the rage these days, especially here at the Neo Cincinnati office. Two officemates have drones, and they’ve taken to the office space and the hallways during lunchtime. The drone comes with piloting apps that control it in real time - but they can also be controlled programmatically. Work on drone drivers is progressing (Jim Weirich’s in Ruby, Carin Meier’s in Clojure) that can send commands to the drone.

A drone command is specified as a 5-tuple: (roll, pitch, yaw, altitude, duration) all relative to it’s hover state. Once a command is executed, the drone returns to a hover state at its current location. From this it’s relatively straightforward to make a drone fly in a simple pattern. Tilt and pitch define the forward direction, and yaw is used to change it.

To actually plan a pattern however, the command’s values must be understood in relation to each other. Each is value specified in a [-1, 1] range in a drone command, and translated to an angle. This means that before programmed maneuvers can be created, scaling constants between angles must be determined. For example, consider flying one turn around a circle: the drone must be tilted forward (some combination of pitch and roll) and spun (a yaw value) over the time needed to complete a revolution.

(rc, pc, yc, 0, tc)

For a given tilt, spinning too fast spirals inward, while spinning too slow spirals outward. Too long or short a time will orbit more or less than one turn. Empirical examination of drone flight and timing must be done to determine this calibration. Assuming these values have been appropriately factored in then,

figure roll pitch yaw altitude duration notes
Circle r p y 0 t p&r = y
Spiral in r p y 0 t p&r < y
Spiral out r p y 0 t p&r > y
Figure 8 r p y 0 t p&r = y, t = one revolution
  r p -y 0 t  
Tilted circle r p y a t p&r = y, t = half revolution
  r p y -a t  
3-leafed Clover r p y1 0 t1 p&r = y1, t1 = two-thirds revolution, t2 = half a revolution
  0 0 y2 0 t2  
  r p y1 0 t1  
  0 0 y2 0 t2  
  r p y1 0 t1  

Compound curves are defined as a series of simple pieces.

This is all fine, but to watch a drone move around a room in these sorts of algebraic patterns doesn’t feel very aerobatic to me. The flying seems stunted and formulaic… more natural flight is a more complex dance of values. My best reference is a bird flying or fish swimming - when they maneuver, combinations of roll, pitch and yaw are smooth and complex. Changes in roll, pitch and yaw affect altitude. Coordinated moves are made to convert velocity into height. Soaring, diving, swooping - all feel like they should be aerobatic primitives.

Of course, these all can still be formulaic. But they’ll look more natural. Somewhere in there is the beginning of the algebra of nature and what constitutes enough of this essence to feel birdish or fishish.

I’ll be looking at this as our drones continue to learn to fly.