Hacking the APM2 Part #1: Introduction
Introduction
I would like to start off my first post in this series by briefly describing where I’ve been and where I’m going. Hopefully this will give a bit of context to help understand subsequent posts and hopefully will help put my engineering decisions in some context.
History of the World, Part 1
Somewhere around 2005 I became very interested in aerial robotics. I have always been an aviation enthusiast, I’ve built model airplanes since I was a kid, and I have been flying RC airplanes since high school. At the time I was working for the Univ. of Minnesota and managed to get myself sent off to a training class for a little device called a Crossbow MNAV. The MNAV was a small package that included mems gyros, accelerometers, altimeter, air speed, GPS, RC receiver PPM train decoding, and could control up to 8 servos. It was perfect for building a small UAV autopilot. As it turned out, even though the MNAV was pretty good for it’s time, it wasn’t perfect — and about 2 years later when I finally had my code up and flying successfully, Xbow announced they had discontinued the MNAV.
My autopilot code was written for Linux. I had been running it on a 400mhz Gumstix processor (the really old one) and that talked to the MNAV over a serial connection. The MNAV sent up the IMU and GPS data to the Gumstix which ran the attitude filter, autopilot, and navigation code, and sent servo positions back to the MNAV. This worked rather well so I was pretty disappointed when the MNAV was terminated.
History of the World, Part 2
In a world with no MNAV I launched off on an adventure to build my own autopilot from off the shelf parts. What made this possible was the original ArduPilot. I could buy IMUs, GPSs, and processors off the shelf, but the ArduPilot gave me the ability to interact with RC servos, the RC receiver, and gave me a hardware failsafe mux, so whenever something went wrong with my code, I could immediately take over manual control of the aircraft. As it turns out, this has saved me more times than I can count.
I ended up with a system built around the new Gumstix Verdex “pro”. This processor ran at a whopping 600mhz and had enough number crunching power to run a full blown 15-state kalman filter at 50hz. I connected a SparkFun 6DOFv4 IMU initially (ultimately upgraded to a VectorNav VN-100) for my inertial sensor, a ublox5 for my GPS, and of course the original ArduPilot for servo control.
At that time I hacked my own version of the ArduPilot firmware to talk directly to the Gumstix Verdex. I left out all the AP stuff and simply used it to read the RC receiver and relay the pilot stick commands to the Gumstix, and then the Gumstix would send back servo positions to the ArduPilot which would take care of moving the servos to the specified positions.
History of the World Part 3
Time passes, a few projects came and went. Now it’s 2012, and now the APM2 is released. Compared to the original ArduPilot, the APM2 is a beautiful work of art! It looks good, it packs on all kinds of high quality sensors, it has a powerful at mega 2560 processor, it is small, it is light, it is cheap, and it’s pretty well debugged because so many people are buying and flying them.
I decided it would be interesting to revisit my old autopilot design and modernize it based on the new APM2. Any set of engineering decisions has plusses and minues. Embedded autopilots are always a delicate balance between, size, weight, cost, capability, power requirements, etc. And within those larger parameters, every architectural choice has subtle implications related to performance, latency, precision, capability, development tools, integration issues, unexpected surprises (good and bad), and on and on. On the one hand, there is a huge matrix of possibilities, and on the other hand specific choices have cascading effects and lead you in specific directions. In the end, the goal is to find that magic balance of choices that lead you to an ideal outcome without sacrificing too many things along the way.
Looking to the Future
Where am I going with all this? What do I envision my autopilot will look like at the end of the process? Here is a quick summary:
- An APM2 with firmware rewritten to simply collect all the sensor data and pass it up stream to my Gumstix for actual processing.
- A Gumstix Verdex (1Ghz Arm) with hardware floating point, 512Mb of RAM
- Linux based Autopilot software that includes a full 15-state kalman filter, XML configurable PID system, and advanced mission/task system.
- Everything running at 200hz.
I plan to continue this “Hacking the APM2” series with future posts describing interesting things that I’ve learned or issues that I’ve solved along the path; culminating (hopefully) with a “Super ArduPilot Mega 2 on 1Ghz ARM Steroids” based autopilot system.