Magnetometer and Gyroscope Calibration Method with Level Rotation

Micro electro mechanical system (MEMS) gyroscopes and magnetometers are usually integrated into a sensor module or chip and widely used in a variety of applications. In existing integrated gyroscope and magnetometer calibration methods, rotation in all possible orientations is a necessary condition for a good calibration result. However, rotation around two or more axes is difficult to attain, as it is limited by the range of movement of vehicles such as cars, ships, or planes. To solve this problem, this paper proposes an integrated magnetometer and gyroscope calibration method with level rotation. The proposed method presents a redefined magnetometer output model using level attitude. New gyroscope and magnetometer calibration models are then deduced. In addition, a simplified cubature Kalman filter (CKF) is established to estimate calibration parameters. This method possesses important value for application in actual systems, as it only needs level rotation for real-time calibration of gyroscopes and magnetometers. Theoretical analysis and test results verify the validity and feasibility of this method.


Introduction
Micro-electro-mechanical-system inertial measurement units (MEMS-IMUs) commonly include a gyroscope, accelerometer, and magnetometer, and are widely employed in many fields which rely on their small size and low costs. The gyroscope can sense the vehicle angular velocity and calculate the attitude change. The magnetometer and accelerometer measure the local magnetic field and the acceleration of the rigidly-attached platform. However, the precision of MEMS gyroscopes is generally not high and attitude error may accumulate quickly. Therefore, MEMS gyroscopes must be calibrated before use. In general, gyroscope calibration methods need to be supplemented by external information. One of the common methods is based on Global Navigation Satellite System (GNSS)-aided calibration [1][2][3]. In dynamic environments, with the use of the precise positioning and velocity information, a GNSS-or GNSS/MEMS-IMU-integrated navigation system can estimate gyroscope bias in real-time and obtain accurate attitude. However, it is impossible to achieve good performance in a static environment. Furthermore, GNSS signals are not always available on account of occlusions, such as buildings, viaducts, tunnels, and dense forests. To improve the reliability and accuracy of the navigation solution, a magnetometer has been introduced to calibrate the gyroscope.
A magnetometer must be calibrated before use because it is prone to being influenced by electromagnetic disturbance. Many magnetometer calibration methods have been presented in related literature. Ellipsoid fitting is a common technology to calibrate a magnetometer [4,5]. This technology does not need any external information because it fits an ellipsoid locus from a non-calibrated magnetometer to a sphere. The advantages of this technology are ease of use, short run-time, and reduced computational needs. However, it also has the weakness of low Particle swarm optimization algorithm [18][19][20] Magnetic field Need not set initial parameters, Model precision High calculation cost, Rotation in all possible orientations, Off-line Gyroscope integrated calibration [21,22] Magnetic field, Angular rates Model precision, On-line Rotation in all possible orientations Virtual rotation scheme [23][24][25] Angular rates

System Modeling and Filter
In this section, the leveled output model of the magnetometer is introduced by analyzing the characteristics of level rotation. Based on this model, the magnetometer and gyroscope calibration models are constructed. Finally, a simplified CKF is designed to estimate the calibration parameters.
The frame definitions are introduced as follows, and a sketch of the coordinate systems is shown in Figure 1.
• Navigation frame (n-frame): The navigation frame is located on the vehicle. It points to the east, north, and upward. • Body frame (b-frame): The body frame is fixed to the vehicle. Its x-axis and y-axis point to the right and forward of the vehicle, and its z-axis follows the right-hand rule. • Leveled frame (l-frame): The leveled frame is also located on the vehicle. It is the frame by leveling b-frame such that its z-axis is parallel to the upward vertical and possesses an error angle with respect to the n-frame.

System Modeling and Filter
In this section, the leveled output model of the magnetometer is introduced by analyzing the characteristics of level rotation. Based on this model, the magnetometer and gyroscope calibration models are constructed. Finally, a simplified CKF is designed to estimate the calibration parameters.
The frame definitions are introduced as follows, and a sketch of the coordinate systems is shown in Figure 1.
• Navigation frame (n-frame): The navigation frame is located on the vehicle. It points to the east, north, and upward. • Body frame (b-frame): The body frame is fixed to the vehicle. Its x-axis and y-axis point to the right and forward of the vehicle, and its z-axis follows the right-hand rule.

•
Leveled frame (l-frame): The leveled frame is also located on the vehicle. It is the frame by leveling b-frame such that its z-axis is parallel to the upward vertical and possesses an error angle with respect to the n-frame.

Magnetometer Model
The magnetometer measurement model can be expressed as [26]: where is the measurement from the magnetometer and is the true magnetic field. is a scale factor matrix, is a non-orthogonal matrix and is a soft-iron effect matrix. and

Magnetometer Model
The magnetometer measurement model can be expressed as [26]: where B m is the measurement from the magnetometer and B t is the true magnetic field. C sc is a scale factor matrix, C no is a non-orthogonal matrix and C si is a soft-iron effect matrix. b hi and b b are, respectively, the hard-iron effect vector and bias. ε m is the measurement noise of the magnetometer, which can be modeled as Gaussian white noise. C sc , C no , and C si are specifically expressed as follows: For the measurement of the magnetometer in the b-frame, Equation (1) can be rewritten as in which and B t is in b-frame such that B b t = C b n H n , in which C b n is the n-frame to b-frame rotation matrix and H n is the n-frame geomagnetic field.
When B m is redefined as the leveled magnetometer measurement in l-frame, B t can be changed to equal C l n H n , in which C l n is the n-frame to l-frame rotation matrix and can be calculated by the level attitude. Equation (5) can then be rewritten as Because the bias in the b-frame is a goal of magnetometer calibration, Equation (8) can be transformed to in which C l b is the b-frame to l-frame rotation matrix provided by the level attitude. For convenience of the next calculation, C is represented as where I 3×3 is an identity matrix. In this paper, as the algorithm is designed for level rotation, this situation may lead to lower-quality observation of some calibration parameters. To avoid the error introduced by unobservable parameters, C l is assumed to be a symmetric matrix [11]: After the leveled magnetometer model is obtained, the calibration model for unknown parameters C and b b m needs to be established. From the above deduction, it is known that B l m are direct magnetometer readings, H n can be acquired from the International Geomagnetic Reference Field (IGRF) model [27] and the norm of H n satisfies Hence, the relationship between the known H n 2 and calibration parameters can be built. The transformation of Equation (9) can be obtained as: The normalized H n can be expressed by The measuring equation of the magnetometer calibration model can be given by

Gyroscope Model
The common gyroscope output model is given by [21,22]: where ω b g is the measured value from the gyroscope and ω b t is the real angular rate. b b g is the gyroscope bias in the b-frame. C gsc and C gno are, respectively, the scale factor error matrix and non-orthogonal matrix of the gyroscope, C gmis is a misalignment error matrix between gyroscope and magnetometer, C g is a combination matrix of the above three, and ε g and ε u are independent zero-mean Gaussian white-noise.
In this paper, considering that the method is designed for low-cost MEMS navigation systems, a computationally expensive calibration process cannot be afforded. At the same time, to improve the observability of parameters, the scale factors and the non-orthogonal are considered as the calibrated parameters before leaving the factory. Therefore, only the gyroscope bias is considered and the gyroscope model is simplified as After establishing the gyroscope model, the relationship between the gyroscope bias and the magnetometer needs to be found. From Equation (9), we can obtain The derivative of Equation (21) can then be shown by .
As vehicles usually rotate more slowly than the sampling rate, are defined as follows: Combining Equations (14) and (22), we can obtain Some parameters are defined as follows:

Filter Algorithm
According to the above analysis, the magnetometer and gyroscope calibration problem can be formulated as a state estimation problem. Equations (16) and (33) are taken as the observation model and the state transition model is expressed as follows: State transition model: Observation model: .
In the above, the calibration parameters of the magnetometer and the gyroscope are constant, such that the rate of change of these parameters is equal to zero in the state transition model. For the observation model, it is known that the calibration system is a nonlinear system and the Jacobian matrix of the observation model is difficult to obtain. Hence, the appropriate filter should be employed for rapid and precise calibration. In this paper, CKF is applied for magnetometer and gyroscope calibration since it has some advantages, including fast convergence and less computational needs [28].
CKF is a filter method based on the cubature transform. The core of CKF is the cubature transformation by a spherical-radial rule [29]. It takes advantage of a set of cubature points to propagate state and covariance matrices of the system. The time update process of the CKF algorithm is expressed as: where SVD(·) represents the singular value decomposition of the matrix and f(·) is the state transition function. Matrix S k−1/k−1 is the root mean square of the covariance matrix P, m = 2n (n is the dimensions of the system), ξ = √ m/2 [1] i (For example, when n = 2, [1] = {(1,0) T ,(−1,0) T ,(0,1) T ,(0,−1) T }, [1] i represents the ith column of set [1]). However, because the state vector of the calibration system is constant, the state transfer matrix is a unit matrix, which allows the state transition errors to be ignored; in other words, Q k is a zero matrix. The time update can be simplified as follows: This solution simplifies the operation of updating time, which also reduces computational needs. The CKF measurement update process is summarized as follows: where h(·) is the observation function. x k/k and P k/k are the estimated results at step k, and represent the state vector and state covariance matrix separately.

Simulation Test
In this section, the feasibility of the proposed method will be verified by simulation testing. In the following, the simulation details will be introduced.

Reference Algorithm
The proposed method aims to solve the problem that existing calibrations methods do not consider the situation that only level rotation is performed. Existing calibration methods need data in all possible directions and cannot be used with only level rotation. To check the effect of the proposed method, the normal attitude-independent method (NAIM) [8,9] and the magnetometer and gyroscope integrated calibration method (MGICM) are compared in the specified rotation and simulation parameters [21,22]. The NAIM is a classic magnetometer calibration method without any attitude information. This method uses an attitude-independent model for magnetometer calibration by removing the attitude matrix, and CKF is used to estimate calibration parameters. In this algorithm, according to Equation (5), the magnetometer calibration model is set as in which the scale factor matrix C b is symmetric. B b m and b b m are located in the b-frame and the attitude matrix C b n is removed by the normalized process of Equation (55). Then, the gyroscope calibration model is deduced. The NAIM calibration system is expressed as follows: State transition model: Observation model: .
in which The MGICM calibrates the magnetometer using the angular velocity from the gyroscope, while gyroscope calibration parameters are simultaneously estimated using the calibrated magnetometer readings. The state transition model and observation model are summarized as follows: State transition model: Observation model: To guarantee fairness, this algorithm will use CKF to estimate parameters.

Simulation Setting
The proposed method is considered for the situation that the navigation system on many vehicles cannot rotate around two or more axes, such that traditional magnetometer and gyroscope calibration methods may give the wrong results. To check the effectiveness of the proposed method, the rotation model is set to level rotation, where the system rotates only around the z-axis and a limited angular rate may exist on the other two axes. Table 2 provides simulation settings. More detailed rotations are shown in Figure 2. Figure 2a shows the gyroscope output and Figure 2b demonstrates the three-axis magnetometer output. The three-dimensional diagram of magnetometer output is displayed in Figure 2c. The system level attitude is shown in Figure 2d. From Figure 2c, it is clearly observed that the locus of magnetometer data is an approximate ellipse rather than ellipsoid.

Items Values
Device rotation angular rate on z-axis Less than 20 (degree/s) in sine wave with 300 s periods Device rotation angular rate on x and y-axis Less than 3 (degree/s) in sine wave with 3 s periods Update frequency calibration methods may give the wrong results. To check the effectiveness of the proposed method, the rotation model is set to level rotation, where the system rotates only around the z-axis and a limited angular rate may exist on the other two axes. Table 2 provides simulation settings. More detailed rotations are shown in Figure 2. Figure 2a shows the gyroscope output and Figure 2b demonstrates the three-axis magnetometer output. The three-dimensional diagram of magnetometer output is displayed in Figure 2c. The system level attitude is shown in Figure 2d. From Figure 2c, it is clearly observed that the locus of magnetometer data is an approximate ellipse rather than ellipsoid.  This method has high precision and stability when static, but cannot guarantee those advantages in dynamic conditions. 2. The gyroscope can update a known attitude by several methods, including quaternions. The advantage is high precision and stability over a short period of time. It is prone to accumulate errors over longer time periods. 3. An integrated navigation system can provide the precision attitude by integrating different sensors with integration algorithms such as KF and EKF, and so on. These sensors may include a gyroscope, accelerometer, odometer, GNSS, Wi-Fi, etc. This method can guarantee high precision and stability over a long time period, and can be applied in any environment if a 1.
The level attitude can be gained through accelerometer measures of the orientation of gravity. This method has high precision and stability when static, but cannot guarantee those advantages in dynamic conditions. An integrated navigation system can provide the precision attitude by integrating different sensors with integration algorithms such as KF and EKF, and so on. These sensors may include a gyroscope, accelerometer, odometer, GNSS, Wi-Fi, etc. This method can guarantee high precision and stability over a long time period, and can be applied in any environment if a suitable integration algorithm is chosen.

Simulation Result
First, to verify the effectiveness of NAIM and MGICM, the data in all possible directions are used to achieve calibration. Figure 3 shows the 3D diagram of data in all possible directions. magnetometer output; (d) Level attitude of system. The proposed method needs the level attitude of the system to assist calibration. The level attitude can be obtained by any one of the following methods [8]: 1. The level attitude can be gained through accelerometer measures of the orientation of gravity.
This method has high precision and stability when static, but cannot guarantee those advantages in dynamic conditions. 2. The gyroscope can update a known attitude by several methods, including quaternions. The advantage is high precision and stability over a short period of time. It is prone to accumulate errors over longer time periods. 3. An integrated navigation system can provide the precision attitude by integrating different sensors with integration algorithms such as KF and EKF, and so on. These sensors may include a gyroscope, accelerometer, odometer, GNSS, Wi-Fi, etc. This method can guarantee high precision and stability over a long time period, and can be applied in any environment if a suitable integration algorithm is chosen.

Simulation Result
First, to verify the effectiveness of NAIM and MGICM, the data in all possible directions are used to achieve calibration. Figure 3 shows the 3D diagram of data in all possible directions.               The calibration results are summarized in Table 3. In Figures 7-9, the red line is the reference value, and the blue, green, and brown lines represent the estimation results of the proposed method, NAIM, and MGICM. Figures 7 and 9 show the estimation result of the magnetometer, from which it is evident that the results of the NAIM and MGICM converge to incorrect values; by contrast, the results of the proposed method gradually converge to the reference. The result of magnetometer calibration is the basis of gyroscope calibration. Figure 8 indicates the simulation results of gyroscope bias. In Figure 8, the estimation results of the proposed method quickly and accurately converge to the reference values. In comparison, the estimation of NAIM and MGICM cannot get close to the reference. In conclusion, when the system only rotates around the z-axis, the NAIM and MGICM cannot calibrate the system because of a lack of sufficient data in that direction. However, the proposed method can complete calibration successfully, which indicates that it boasts better adaptability and important application value in actual systems.  The calibration results are summarized in Table 3. In Figures 7-9, the red line is the reference value, and the blue, green, and brown lines represent the estimation results of the proposed method, NAIM, and MGICM. Figures 7 and 9 show the estimation result of the magnetometer, from which it is evident that the results of the NAIM and MGICM converge to incorrect values; by contrast, the results of the proposed method gradually converge to the reference. The result of magnetometer calibration is the basis of gyroscope calibration. Figure 8 indicates the simulation results of gyroscope bias. In Figure 8, the estimation results of the proposed method quickly and accurately converge to the reference values. In comparison, the estimation of NAIM and MGICM cannot get close to the reference. In conclusion, when the system only rotates around the z-axis, the NAIM and MGICM cannot calibrate the system because of a lack of sufficient data in that direction. However, the proposed method can complete calibration successfully, which indicates that it boasts better adaptability and important application value in actual systems. Table 3. Simulation results.

Experimental Test
To verify the practical application of the above algorithm, this section will take advantage of an actual MEMS-IMU integrated system to verify the effect of the algorithm.

Test Condition
This test was performed indoors and in a stable magnetic field environment. In the test, we chose ADIS16488 as the MEMS-IMU integrated system, as indicated in Figure 10. The features of ADIS16488  Table 4. ADIS16488 rotated around the z-axis with a certain angular velocity by hand and the gyroscope and magnetometer data were collected simultaneously.
Sampling rates 205 (Hz) Gyroscope bias repeatability ±0.2 (degree/s) Gyroscope in-run bias stability 6.25 (degree/h) Gyroscope angular random walk 0.3 (degree/√h) Gyroscope output noise 0.16 (degree/s)(rms) Accelerometer bias repeatability ±16 (mg) Accelerometer in-run bias stability 0.1 mg Accelerometer velocity random walk 0.029 m/s/√h Accelerometer output noise 1.5 (mg)(rms) Magnetometer output noise 0.45 (mGauss)(rms) Figure 10. ADIS16488 micro-electro-mechanical-system inertial measurement unit (MEMS-IMU) system. Figure 11 display the three-axis raw output of ADIS16488′s gyroscope and magnetometer. Figure 11c demonstrates the three-dimensional diagram of ADIS16488′s magnetometer output. Figure 11d shows the level attitude of the system. This level attitude was calculated by the accelerometer, and the calculation method is provided in Section 3.2.  Figure 10. ADIS16488 micro-electro-mechanical-system inertial measurement unit (MEMS-IMU) system. Panels a and b of Figure 11 display the three-axis raw output of ADIS16488 s gyroscope and magnetometer. Figure 11c demonstrates the three-dimensional diagram of ADIS16488 s magnetometer output. Figure 11d shows the level attitude of the system. This level attitude was calculated by the accelerometer, and the calculation method is provided in Section 3.2.

Experimental Test
To verify the practical application of the above algorithm, this section will take advantage of an actual MEMS-IMU integrated system to verify the effect of the algorithm.

Test Condition
This test was performed indoors and in a stable magnetic field environment. In the test, we chose ADIS16488 as the MEMS-IMU integrated system, as indicated in Figure 10. The features of ADIS16488 are shown in Table 4. ADIS16488 rotated around the z-axis with a certain angular velocity by hand and the gyroscope and magnetometer data were collected simultaneously.  Figure 10. ADIS16488 micro-electro-mechanical-system inertial measurement unit (MEMS-IMU) system.
Panels a and b of Figure 11 display the three-axis raw output of ADIS16488′s gyroscope and magnetometer. Figure 11c demonstrates the three-dimensional diagram of ADIS16488′s magnetometer output. Figure 11d shows the level attitude of the system. This level attitude was calculated by the accelerometer, and the calculation method is provided in Section 3.2.

Test Results
The results of the actual experiment are listed in Table 5. In Figures 12-14, the red line expresses the reference. The blue, green, and brown lines show the results of the proposed method, NAIM, and MGICM, respectively. Due to the reference values of the magnetometer, parameters are difficult to know, so gyroscope calibration results could be used to verify magnetometer calibration results. From the velocity of convergence, the calibration of the magnetometer was completed first, and then the gyroscope was gradually calibrated. In other words, if the gyroscope is calibrated accurately, the magnetometer is also calibrated precisely. To check the gyroscope calibration results, the approximate bias of the gyroscope can be obtained by letting the system remain stable for a long time. Therefore, it will be applied to verify the calibration results as the reference values. In Figure  13, it is obvious that the result of the proposed method only gets close to the reference and the other results are wrong, which indicates that the proposed method is correct and valid. Moreover, the calibration of the magnetometer can be completed within 200 s, and the calibration of the gyroscope bias is finished in about 600 s. From the above results, the proposed method can be used accurately with level rotation, otherwise the general calibration model may obtain an incorrect result when using only level rotation.

Test Results
The results of the actual experiment are listed in Table 5. In Figures 12-14, the red line expresses the reference. The blue, green, and brown lines show the results of the proposed method, NAIM, and MGICM, respectively. Due to the reference values of the magnetometer, parameters are difficult to know, so gyroscope calibration results could be used to verify magnetometer calibration results. From the velocity of convergence, the calibration of the magnetometer was completed first, and then the gyroscope was gradually calibrated. In other words, if the gyroscope is calibrated accurately, the magnetometer is also calibrated precisely. To check the gyroscope calibration results, the approximate bias of the gyroscope can be obtained by letting the system remain stable for a long time. Therefore, it will be applied to verify the calibration results as the reference values. In Figure 13, it is obvious that the result of the proposed method only gets close to the reference and the other results are wrong, which indicates that the proposed method is correct and valid. Moreover, the calibration of the magnetometer can be completed within 200 s, and the calibration of the gyroscope bias is finished in about 600 s. From the above results, the proposed method can be used accurately with level rotation, otherwise the general calibration model may obtain an incorrect result when using only level rotation. Table 5. Calibration results.

Conclusions
Aiming at an actual problem (i.e., that most calibration methods require that the sensors be rotated in all possible orientations to guarantee a good result), it is, however, impossible for the navigation system on vehicles such as cars, ships, or planes. Therefore, a gyroscope and magnetometer integrated with an on-line calibration method is proposed with level rotation. This work mainly provides two contributions: (1) Relying on the level attitude, the magnetometer output model is redefined and the level two-dimensional gyroscope and magnetometer calibration model is deduced. (2) A simple CKF is designed to rapidly and accurately complete calibration. Then, the NAIM and MGICM are introduced to check the simulated effect of the proposed method. With level rotation, the NAIM and MGICM obtain the wrong calibration results, while the calibration result of the proposed method is close to the reference. In the actual test, an ADIS16488 MEMS-IMU integrated system is used to verify the practicability of the proposed method. The test data were

Conclusions
Aiming at an actual problem (i.e., that most calibration methods require that the sensors be rotated in all possible orientations to guarantee a good result), it is, however, impossible for the navigation system on vehicles such as cars, ships, or planes. Therefore, a gyroscope and magnetometer integrated with an on-line calibration method is proposed with level rotation. This work mainly provides two contributions: (1) Relying on the level attitude, the magnetometer output model is redefined and the level two-dimensional gyroscope and magnetometer calibration model is deduced. (2) A simple CKF is designed to rapidly and accurately complete calibration. Then, the NAIM and MGICM are introduced to check the simulated effect of the proposed method. With level rotation, the NAIM and MGICM obtain the wrong calibration results, while the calibration result of the proposed method is close to the reference. In the actual test, an ADIS16488 MEMS-IMU integrated system is used to verify the practicability of the proposed method. The test data were

Conclusions
Aiming at an actual problem (i.e., that most calibration methods require that the sensors be rotated in all possible orientations to guarantee a good result), it is, however, impossible for the navigation system on vehicles such as cars, ships, or planes. Therefore, a gyroscope and magnetometer integrated with an on-line calibration method is proposed with level rotation. This work mainly provides two contributions: (1) Relying on the level attitude, the magnetometer output model is redefined and the level two-dimensional gyroscope and magnetometer calibration model is deduced. (2) A simple CKF is designed to rapidly and accurately complete calibration. Then, the NAIM and MGICM are introduced to check the simulated effect of the proposed method. With level rotation, the NAIM and MGICM obtain the wrong calibration results, while the calibration result of the proposed method is close to the reference. In the actual test, an ADIS16488 MEMS-IMU integrated system is used to verify the practicability of the proposed method. The test data were

Conclusions
Aiming at an actual problem (i.e., that most calibration methods require that the sensors be rotated in all possible orientations to guarantee a good result), it is, however, impossible for the navigation system on vehicles such as cars, ships, or planes. Therefore, a gyroscope and magnetometer integrated with an on-line calibration method is proposed with level rotation. This work mainly provides two contributions: (1) Relying on the level attitude, the magnetometer output model is redefined and the level two-dimensional gyroscope and magnetometer calibration model is deduced. (2) A simple CKF is designed to rapidly and accurately complete calibration. Then, the NAIM and MGICM are introduced to check the simulated effect of the proposed method. With level rotation, the NAIM and MGICM obtain the wrong calibration results, while the calibration result of the proposed method is close to the reference. In the actual test, an ADIS16488 MEMS-IMU integrated system is used to verify the practicability of the proposed method. The test data were obtained by rotating the system around the z-axis with a certain angular velocity by hand. Finally, the proposed method displays good effects, which illustrates that the method possesses strong practicability.