Heading calculation requires magnetometer parallel to the surface (0-degree pitch and 0-degree roll). These pitch and roll values are useful to compensate for the magnetometer heading angle.
Compensated Yaw angle is given as,
Yaw=arctan((mag_y*cos(roll))-(mag_z*sin(roll)),(mag_x*cos(pitch))+(mag_y* sin(roll)*sin(pitch))+(mag_z*cos(roll)*sin(pitch)))
Comentarios