Electronic compass calibration method based on magnetic sensor

The invention discloses an omnibearing electronic compass calibration method. By adopting a Kalman filtering algorithm, data of an accelerometer and a gyroscope are subjected to filtering processing, so the dip angle compensation effect of a magnetic sensor is good, the static calibration can be carried out, and the dynamic calibration can be simultaneously carried out. The magnetic field strength can be obtained with an IGRF model through calculating, approximate evaluations of a soft magnetic interference matrix and a hard magnetic interference vector quantity are obtained through utilizing the data of the magnetic field strength and a measurement model of the magnetic sensor by a soft and hard magnetic correction model parameter estimator based on an ellipsoid hypothesis. A datum model which is established by hypothesizing the soft magnetic interference matrix as an upper triangular matrix with unknown parameters in a soft and hard magnet corrected recursive algorithm accords with the soft magnetic interference characteristics; and simultaneously initial values of the parameters are calculated results of the soft and hard magnetic correction model parameter estimator based on the ellipsoid hypothesis, so the initial values which are not given under the hypothesis of no soft and hard magnetic interference are closer to true values of the parameters, thereby the iterative convergence speed is accelerated, and the calibrating spot selection is relatively free.