This invention relates to an attitude calculation method for an unmanned aerial vehicle (UAV) attitude reference
system, belonging to the field of UAV navigation. In this invention, the collected sensor data is first filtered to obtain an initial unit
quaternion from the navigation coordinate
system to the vehicle coordinate
system. The
accelerometer output is normalized and an error vector is constructed with the normalized gravity vector. The vehicle
motion mode is determined by the
accelerometer and
gyroscope outputs, and the
gain coefficient is adaptively adjusted to calculate the
gyroscope error correction, thus completing the attitude update and correcting the horizontal attitude. Simultaneously, the
magnetometer output is evaluated; if the
magnetometer output is valid, the heading angle is corrected, and the corrected three-axis attitude angles are output in real time. This invention uses only quaternions for calculation, avoiding the calculation of rotation matrices and improving calculation efficiency. Compared to traditional complementary filtering algorithms, it incorporates vehicle
motion mode judgment and adaptive
complementary filter parameter adjustment, avoiding erroneous attitude corrections by the
accelerometer under high dynamic conditions. By applying a second-order
complementary filter to process accelerometer and
magnetometer data for attitude compensation, horizontal attitude correction can be avoided when magnetometer data is unavailable, achieving decoupling of attitude correction.