Lego UAV 2: full details now available!

I'm at the FIRST Robotics Championship in Atlanta and we've just unveiled the first REAL Lego UAV. It's actuallly been working for a few months, but we couldn't talk about it since it's based on the new hardware that was just announced yesterday as the new FIRST Tech Challenge competition kit. Our UAV uses Mindstorms and the new hardware to make a full IMU-based autopilot, which both stabilizes and navigates the plane autonomously. It uses:

--Mindstorms NXT controller
--Two prototype integrating gyros from HiTechnic. These are not the rate gyros already available. Rate gyros output degrees/sec, which requires a pretty gnarly math process to measure and integrate the results over time to get absolute degrees. The prototype iGyros from HiTechnic do that in hardware, and output absolute degrees, which is very easy for the NXT to deal with with.
--A 3-axis accelerometer to calibrate the gyros using a modified Kalman filter. Basically gyros are right in the short term (seconds) but wrong in the long term (minutes; they drift over time). Meanwhile accelerometers are wrong in short term (they're noisy) but right in the long term (they don't drift). So we averge the accelerometer readings over time to correct drift in the gyros.
--A prototype servo multiplexer from HiTechnic. This is similar to the servo driver accessory that they're selling as part of the FTC competition kit, but is designed for RC use. It takes I2C output from the NXT and converts it into PWM for the servos. It also has a channel 6 input from the RC receiver that switches it from RC to NXT control (this is our hardware failsafe switch).
--A GPS sensor/datalogger (iBlue 747) that communicates with the NXT via bluetooth.

I'll post the RobotC code this weekend, but I wanted to give you a quick look at this. It's really cool, flies, and can now expand into anything else in the robotics world, from cameras to communications. More soon!

They're actually gyros originally designed for shake-reduction on cameras. Drift is on the order of 10 degrees/min, which isn't bad at all. We're also using a high-wing trainer, which is naturally pretty stable, so it's nowhere near as hard as your helis

When the plane is supposed to be flying straight and level, we sample the accelerometers constantly and do a least squares regression every second or so to establish "true down" and then adjust the gyro bias accordingly.. When the bias gets too high (more than 90 degrees), we reset the gyros to zero and start over.

As a final check, if the accelerometers say we're flying level and the gyros say we're flying level, but the GPS says we're turning, we can add a calibration factor to the bias to compensate for those errors.

I don't think my control loop qualifies for anything as formal as PID designation, but that's roughly the direction we're headed. Right now the gyros fly the plane with a direct proportional input, and the rest just calibrates the gyros when the plane is supposed to be flying level.

Dear Chris Anderson:
I am really interested in the project of the full IMU based autopilot with the hardware based in the Mindstorms control and the new hardware.
I would thank you send me the RobotC code. We work with Labview and the toolkit for Mindstorm
I want to use the same hardware like the Mindstorms UAV:
Mindstorms NXT controller
Two prototype integrating gyros from HiTechnic.
A 3-axis accelerometer.
A prototype servo multiplexer from HiTechnic.
A GPS sensor/datalogger (iBlue 747).
I want to expand into anything else in the robotics world, from cameras to communications.

I contacted HiTechnic regarding the iGyro integrating gyros to see when they might be available commercially and learned that they are evaluating that right now. They might not go commercial, but if they do it could be early to mid 2009. If these do not become available, does that mean that the Mindsprings NXT is not really a viable platform to both stabilize and navigate a plane autonomously? Even though affordable plug-and-play autopilots seem to be right around the corner, I love the idea of a "toy" being used for this purpose. It's also a bit more "DIY," but something I can handle, I think.

It is possible to build a Mindstorms IMU with standard gryos and accelerometers, but the software is a lot harder (too hard for me!). You need a real Kalman filter, rather than the simple PID loops that I use. But if you're up for that, it's technically very possible.