Abstract:Aiming at the problems of serious magnetic field interference, poor dynamic performance of magnetometer calibration and low accuracy of UAV attitude estimation, a two-stage heading and attitude estimation method based on real-time magnetometer calibration was proposed. According to the characteristics of small variation of geomagnetic field vector, the real-time calibration model of magnetometer was established by using Levenberg-Marquardt (LM) algorithm and magnetometer error model, and the error parameters of magnetometer were calculated in real time. Considering the disturbance of motion acceleration, motor magnetic field and environmental magnetic field, the unscented Kalman filter (UKF) was used to fuse gyroscope and accelerometer to realize the first-stage attitude estimation, and the attitude information of roll angle and pitch angle was accurately analyzed through quaternion. The second-stage attitude estimation combined the realtime calibration data of the magnetometer and the gyroscope to correct the heading angle, and finally realized the accurate estimation of the UAV attitude and heading. The test results showed that when the external magnetic field interference was up to 30.97μT, the real-time calibration algorithm can still quickly calculate the calibration parameters of the magnetometer, and the mode length root mean square error was 0.59μT, which reduced the noise of heading observation information. The root mean square error of the attitude angle of the attitude measurement system was no more than 0.75°, and the root mean square error of the heading angle was 1.40°. Compared with that of complementary filtering algorithm, the attitude angle accuracy was increased by 0.6°, and the heading angle estimation accuracy was improved by 1.38°. In the dynamic flight test, the attitude estimation algorithm greatly reduced the influence of magnetic interference, the attitude tracking was accurate, the heading angle converged quickly, and the steady-state accuracy was higher.