I am in the process of building a simple IMU for an autopilot. I am using Sparkfun, 9 Degrees of Freedom - Razor IMU (https://www.sparkfun.com/products/10736). It is surprisingly user friendly.
I was able to get accelerometer, gyro and magnetometer data right out of the box. After calibration of the sensors and a simple complementary filter i have reliable roll and pitch values.
Now I have a problem with the yaw...
I found here http://www.pololu.com/file/download/...?file_id=0J434 the equation to get the yaw out of the magnetometer value:
Xh= Xm cosPitch + Zm sinPitch Yh= Xm sinRoll sinPitch + Ym cosRoll - Zm sinRoll cosPitch with Xm, Ym, and Zm are magnetic sensor measurements
Yaw = Heading = arctan( Yh / Xh )
It sound be simple, but I can't do it. I hope that someone who already worked on IMUs can help me solve this problem.