Hi Guys I am using the MPU9150 to build an AHRS. I am using the Sparkfun I2c Dev Lib for getting the raw data. The roll and pitch are working fine. The magnetometer yaw reading is pretty messed up. I am able to get some data but do not know how to get correct yaw. I am using the following equations:
T=[cos(theta), sin(theta*sin(phi), sin(theta)*cos(phi); 0, cos(phi), -sin(phi); ... , ... , ...];
cmps - Normalized value from magnetometer m=magnetometer planar readings.
However, it gives absurd values and changes suddenly too from say 0 to 180 0r -180.
Also, it changes smoothly if I move pitch it up or down.
Please help me out guys. :)