After we demoed a little five-channel "AutoPylot" program on a Naze32 with ODROID companion board, our friends at A2USA, Inc . asked us whether we could do the same for the Pixhawk that they use for flying their big birds. We started modifying our MSPPG parser generator to output MAVLink messages, but soon stumbled across some awesome gists by Christopher Vo that showed a better way, using Tridge's pymavlink.mavutils library. Thanks to their work, we were able to create a little Python class that automates much of the programming.
As with our ARDroneAutopylot and PyQuadSim packages, the autopilot kicks in when you hit a switch (default = channel5, which I've configured as SC on my Taranis), and automatically calls a Python method that you write, which returns the other four RC channel overrides (pitch, roll, yaw, throttle). By overriding the getChannelsPos1() and getChannelsPos2() methods, you can create two different automated behaviors based on the two non-default switch positions. Our code includes a simple example that you can run from an ordinary computer, where getChannelsPos1() cycles the throttle up and down, and getChannelsPos2() cycles the roll. To help avoid accidents, these methods will not get called until the switch has first been reset to its default position. Because our goal is to put this code on an ODROID to support missions like the one simulated in this video, we have also included an ODROID-specific copy of this example in the repository.
To run on ODROID, you'll need an inexpensive Pixhawk telemetry cable from 3DR and a level-shifter board to step up the ODROID 1.8v UART to the 5v required by the Pixhawk's telemetry ports. (We followed advice from A2USA about not using the simpler USB connection, whose rigid cable can transmit vibrations from the ODROID to the Pixhawk). Our video shows us using an older level shifter on a breadboard, but as soon as our new level shifter arrives from Sparkfun, we'll make up a little cable to go directly from the ODROID to the Pixhawk through the shifter. The video also shows 5v power from a Castle Creations CC BEC, but on an actual vehicle the 5v would likely come from the BEC output of one of the Electronics Speed Controller (ESC) units. We're going into the Pixhawk through its TELEM 2 port, so TELEM 1 can be used for the 3DR Radio talking to Mission Planner on our Windows box.
WARNING: We have not flight-tested this system and will doubtless encounter bugs once we do. Obviously you should (1) know how to program in Python and (2) thoroughly bench-test your autopilot solution before flying.