Wang Dongsheng Wang Yan Zhou Ying Jiang Guoping
(School of Automation, Nanjing University of Posts and Telecommunications, Nanjing 210023, China)
Abstract:To improve the accuracy of the calculation of a heading angle under magnetic interference, magnetometers and inertial measurement units (IMUs) were fused. The observation value of the heading angle was deduced on the basis of the modeling of the magnetometer error and the analysis of the relation of the magnetometer triaxial output and the distribution characteristics of the magnetic field at two adjacent time periods. Meanwhile, the gyro state and angular velocity increment were used as the basis of the IMU to calculate the prediction value of the heading angle. With the changes in the heading angle and environmental interference, a random forest (RF) algorithm was used to iteratively calculate the weights to fuse the observation value of the heading angle based on the magnetometer and the prediction value of the heading angle based on the IMU. The results show that relative to the common sensor fusion method, the proposed sensor fusion method based on the RF algorithm achieved an approximate 60% improvement in heading angle accuracy. Hence, the proposed method can effectively improve the accuracy of the heading angle under magnetic interference by using an RF algorithm to calculate the output weights of the magnetometer and IMU.
Key words:magnetometer; inertial measurement unit; fusion; heading angle; magnetic interference
The attitude and heading reference system (AHRS) plays an important role in carriers, such as vehicles, ships, and unmanned aerial vehicles[1-3]. The AHRS obtains the Euler angle of a carrier on the basis of the comparison of the rotation vectors of the carrier and the Earth for the measurement of the heading angle. One of the applications of the AHRS is the combination of inertial measurement units (IMUs) and magnetometers.
The approaches to calibrating magnetometers are very mature, and they are able to meet basic accuracy requirements[4-5]. The magnetic heading information of a three-axis magnetometer relative to the direction of the magnetic north is one of the most important parameters in navigation[6-8]. However, accurate heading estimation is not easy to conduct as it is often affected by many factors, which can be divided into two categories, namely, system errors and external interferences[9-12]. System errors include manufacturing and installation errors, and they can be mitigated by proper field calibration. As for external interferences, the approach to address them remains an open issue. For example, magnetic interference sources, such as ferromagnetic materials, machinery, and high voltage lines, are difficult to model in many unknown environments[13-16].Therefore, specific approaches need to be developed to reduce or eliminate magnetic field interference.
A number of approaches have been presented to mitigate the effects of external magnetic field disturbances on magnetic heading[17-18]; they can be divided into two broad categories, namely, data fusion of multiple sensor signals and compensation approaches using only magnetometer signals. The Kalman filter and its improved algorithm are the most commonly used algorithms to improve the accuracy of heading estimation by combining signals from multiple sensors, such as gyroscopes, accelerometers, and magnetometers. When magnetic disturbances occur, minimal weight is assigned to magnetometers, and the heading estimation depends heavily on gyroscopes and accelerometers[19-21].
In this study, we focus on the calculation of the heading angle on the basis of IMUs and magnetometers under magnetic interference. The novelties of this work are as follows. A calculation formula, including one for the heading angle, is established. The magnetometer and IMU are combined according to weight to calculate the heading angle on the basis of an error model. A random forest (RF) algorithm is used to determine the weight factor. The approach combines the advantages of two sensors and makes the final heading angle accurate and stable.
Firstly, a magnetic heading compensation approach is presented.Secondly, a fusion approach that combines the IMU and magnetometer to calculate the heading angle is proposed. Such a fusion approach is introduced in the following four sections.
Define two horizontal components of a geomagnetic field asMxandMy. Therefore, the magnetic heading can be calculated as If the magnetometer is horizontal,then we do not need to consider the vertical direction. Only the data of theX-axis andY-axis can be used to calculate the heading an-gle. However, the magnetometer does not always maintain a horizontal direction during carrier movement. Thus, the magnetic field strength of theX-axis measured by the magnetometer is not a horizontal component.
(1)
The navigation coordinate system is a local cartesian coordinate system, and it rotates in the order of theZXYaxis. The attitude matrix is obtained as follows:
(2)
In this work, the dynamic direction angle approach based on a magnetometer is mainly divided into the following steps. Firstly, the error model of the magnetometer is established according to the error source of the magnetometer measurement. Secondly, a set of formulas containing the course angle information is obtained. Finally, the heading angle is obtained by solving the formula.
The sources of magnetometer errors include the magnetometer itself and external interferences. The errors caused by the magnetometer itself are unchanged with the external environment and can be mitigated by proper field calibration. The errors caused by external interferences are changeable with the external environment. Thus, the error model of the magnetometer can be expressed as follows:
(3)
Without the consideration of white Gaussian noise, the error model of the magnetometer can be simplified as
(4)
(5)
whereNis the inverse matrix of the total error matrix, which remains unchanged with the external environment.
The matrix setting is introduced with consideration of the vertical direction. The correspondences of the magnetometer triaxial output at two adjacent time periods are expressed as
C1X1=C2X2
(6)
whereC1andC2are the attitude matrices of two adjacent time periods;X1andX2are the triaxial output vectors of two adjacent time periods.
The aforementioned triaxial correspondence is expressed as
(7)
If the carrier is in a horizontal position,then the force on the three axes is {0,0,-1}T. Combined with the output of the accelerometer,
(8)
whereAx,Ay, andAzare the outputs of the accelerometer.
From Eq.(8), the following can be obtained:
(9)
Then,θandγcan be calculated as follows:
(10)
(11)
It can also be calculated according to Eq. (5) as
NMh(k+1)-NE(k+1)
(12)
Therefore,
(13)
(14)
where {x1,y1,z1}Tis the output of the magnetometer at the current time; {x2,y2,z2}Tis the output of the magnetometer in the next time period; {n1,n1,n1}Tis the interference on three axes.
Assuming a very small sampling time, the strengths of the magnetic fields at the adjacent time periods are nearly equal. That is, ‖Mk‖=‖Mk+1‖, and then ‖N(Mh-E)‖k=‖N(Mh-E)‖k+1. As the value atkis known, let ‖Mk‖=M0. Then,
(15)
(16)
According to Eqs. (14) and (16), and (sinψ)2+(cosψ)2=1,ψcan be calculated.
(17)
whereAM(k) is the observation value of the magnetometer at timek;pkis the weight factor at timek.
Fig.1 Process of calculating the optimal value
Fig.2 Prediction model of weight factor pk based on RF algorithm
The calculation method for the unknown component ofxis as follows:
(18)
The weight factorpkof each group of data can be calculated as follows:
(19)
The RF algorithm is divided into four steps. Firstly, samples are selected randomly. Secondly, characteristics are selected randomly. Thirdly, a decision tree (classification and regression tree) is constructed. Finally, RF voting (i.e., averaging the output of each decision tree) is performed. The core step of the RF algorithm is to build a decision tree. In this process, the cut points of each node and the final output values should be established.
The feature space division of each tree adopts a heuristic method. Each division examines all the values of all the features in the current set and selects the optimal one as the segmentation point according to the square error minimization criterion. Thej-th feature variablex(j)and its value in the training are set as a cut variable and cut point respectively. Then, define two regions asR1(j,s)={x|x(j)≤s} andR2(j,s)={x|x(j)>s}. The bestjand s are obtained by solving the following:
(20)
wherec1andc2are the fixed output values in the two regions after division that minimize the square errors in each region. Obviously, these two optimal output values are the mean values ofyiin their corresponding regions. After solvingjands, each region is recursively divided into two subregions, andj′ ands′ in each subregion are determined. The steps are repeated until the decision tree is constructed. The decision tree divides the input space intouregionsR1,R2,…,Ru, and its output is as follows:
(21)
In the actual operation, the RF algorithm averages the results of each decision tree to obtain the current weight factorpk. Each phase of the calculation dynamically adjustspkaccording to the situation of the previous phase. Hence, the divergence of heading angle errors caused by the long-term dependence on gyroscopes and accelerometers is avoided under interference.
Magnetic field calibration is adopted to eliminate the zero errors of a magnetometer. The magnetometer measures the magnetic field strength of three axes. The direction of the magnetometer changes with carrier movement. The data measured by the sensor should have the same value in the positive and negative directions of the magnetic field; meanwhile, the symbols are opposite. In other words, the data should be a circle centered at the origin. This feature shows the zero drift of the data.
The experiment for the heading calibration of the magnetometer is performed with a magnetic interference source nearby. A magnet is used as the interference source (red dot in Fig. 3). PathAis 0.1 m away from the interference source, and PathBis 0.6 m away from the interference source.
Fig.3 Testing of magnetometer calibration
In this work, an approach to the dynamic calculation and correction of the heading angle is proposed. The effect of this approach under different interference intensities is verified by experiments. For the ease of comparison of the test results, we fix the steering gear so as to obtain a fixed angle under the condition in which the carrier is driven straight and need not to be turned. The data of the three-axis magnetometer in PathBare shown in Fig. 4. The heading angles under PathsAandBare presented in Fig. 5. PathAis closer to the interference source than PathBand is thus prone to stronger interference intensity. A serious deviation of the uncalibrated heading angle appears near the strong interference in Fig. 5 (a), and the deviation of the uncalibrated heading angle is minimal. Meanwhile, the calibrated value restores the true heading angle more closely in Fig. 5 (a) than in Fig. 5 (b).
The mean values of the uncalibrated heading angle error and calibrated heading angle error are 13.450 2° and 2.127 8°, respectively. The STD values of the uncalibrated heading angle error and calibrated heading angle error are 42.970 5° and 3.727 6°, respectively. The accuracy improves by about 60% after calibration. The mean values of the uncalibrated heading angle error and calibrated heading angle error are 2.467 0° and 1.220 7°, respectively. The STD values of the uncalibrated heading angle error and calibrated heading angle error are 2.981 2° and 1.226 7°, respectively. The accuracy improves by about 50% after calibration.
(a)
(b)
(a)
(b)
The experimental data are generated by random movement in the building. To facilitate the comparison, we preset the carrier trajectory in the experimental site and obtain the true heading angle on the basis of the carrier movement along the trajectory. After data elimination, 10 000 valid data are finally selected. Each set of experimental data includes the observation value of the magnetometer at the previous time, the angular velocity increment of the gyroscope at the current time, the observation value of the magnetometer at the current time, and the real angle at the current time. The sum of the previous magnetometer value, current angular velocity increment, and current magnetometer value are used as the input of the RF algorithm. Then,pis calculated by Eq.(22) as the output for the training model. Finally, the trained model is obtained. In the actual operation, we set the sampling time to 0.1 s. Thus, thepvalue is adjusted every 0.1 s.
Fig 6. compares the results of the fusion algorithm using fixedp-values and those based on RF prediction. The weight factorpaffects the value of the final heading angle. The value is biased toward the gyroscope aspincreases. The mean values of the heading angles are 2.2°,-1.72°, and 5.7° when the three coefficients correspond to eastward straight movement. The heading angles are 90.88°, 92.29°, and 87.25° when sensors are traveling northward. The heading angle corresponding to the straight line in the east should be 0, and the heading angle to the north should be 90°. Thus, when the weight factorpis calculated by the RF algorithm, the heading angle average is relatively close to the actual value. The heading angle variances of the three coefficients are 1.86°, 40.07°, and 11.87°. Therefore, relative to a fixedp-value, when the weight factorpis calculated by the RF algorithm, the calculated weighted heading angle is relatively stable.
Fig.6 Fusion results for different weight factors p
In the proposed weighted fusion approach, the gyroscope output value collected in real time is used as the increment of the heading angle calculated at the last moment to predict a heading angle. Then, the predicted heading angle and magnetometer output collected in real time are used as the input of the RF model to obtain the weight factorp. Finally, the current heading angle is calculated bypand the predicted heading angle and magnetometer output value collected in real time. In the experiment, the heading angle is determined by the proposed weighted fusion approach. The comparison experiment is shown in Fig.7.
Fig. 7 shows the heading angles corresponding to the magnetometer, gyroscope, and weighted fusion approach during the left turn. As the gyroscope measures the rota-tion angle, the current direction is equal to the direction of the previous time plus the rotation angle. Thus, the change is relatively stable. The magnetometer directly measures the absolute direction, and the measured heading angle changes relatively steeply even if filtering is performed. As shown in Fig. 7, both sensors can be sensitive to changes in the sensed direction. The magnetometer and gyroscope can effectively describe the trend of a user’s motion direction. The weighted fusion approach combines the advantages of the two sensors and ensures that the final heading angle is relatively accurate and stable.
Fig.7 Heading angle of different sensors
1) A dynamic error model of a magnetometer is set up on the basis of error classification in magnetometer measurement. This model can reduce the measurement error of the magnetometer.
2) An approach that entails dynamically calculating the heading angle is presented. This approach promotes the accuracy of magnetic heading calculation through sensor fusion. In the weighted fusion approach, the weight factorpis calculated using the RF algorithm. Then, the heading angle is calculated byp. The weight factor p determines whether the heading angle is biased toward the magnetometer or the gyroscope.
3)The experimental results show that the proposed approach improves calculation accuracy by about 60%. The proposed approach can also reduce magnetic field interference, but it cannot eliminate it completely.
Journal of Southeast University(English Edition)2021年2期