I just spent the past three hours with Aaron Kahn, former IARC contestant and now UAV designer for ITT. He gave me an indepth description of how Kalman filters work and how to use them to process our gyro and acceleration sensor data. I'm greatly indebited to him for the assistance.

Most of the online tutorials on the filter are very abstract, so I've written a description of the Kalman filter that focuses on its use for attitude reference. It is a little heavy on the math and matrix arithmetic, but I think it does a good job of describing the process. I don't go into the theory for two reasons:

- There are lots of descriptions of the theory online
- I don't fully understand it.

My source code to implement an AHRS is online. It uses a simple matrix library that was provided by Aaron. As a bonus there are ECEF transforms for once we start building a GPS aided INS. I plan to recode the common matrix cases as inline functions to ensure type-safety and hopefully speed things up.

The ahrs program doesn't do anything yet, but it will read angular rates and linear acceleration data (in the strapdown inertial reference frame) from stdin and write out the estimated Euler angles in the North/East/Down reference frame. Right not it just test the algorithm in a steady state.

Interestingly, we could build a decent two-axis IMU with the code. It wouldn't have heading information, but would be able to track the attitude fairly well. We do have the problem that in a continuous coordinated bank the filter will slowly erect the attitude, but that plagues both two and three axis strapdown systems.