A Weighted Estimation Algorithm for Food Transporting Magnetic Compass

In this study, a weighted estimation algorithm is proposed for food transporting two-axis magnetic compass. This method is based on ellipse fitting algorithm and compensates the combined effort of all linear timeinvariant distortions, namely bias, scale factor, hard iron, non-orthogonality and so on. In contrast to the direct ellipse fitting method for estimating ellipse coefficient, which achieves best estimate based on minimizing the mean square algebraic distance from collected data points to ellipse in mathematical model, this procedure presents a new estimator in least-square sense where the weighted approximate distance is presented. The algorithm is simulated to verify robustness and further validated on collected experimental data using a low-cost fluxgate compass. The results indicate that the calibration algorithm is effective and superior to the direct ellipse fitting method, the heading error after calibration is less than.


INTRODUCTION
Magnetic compass is a device indicating the heading of vehicle, which is widely used in scientific and engineering applications (Zhang et al., 2013;Wu et al., 2013 andYun et al., 2012).When the vehicle is level, heading is computed by the measurements of the earth's horizontal magnetic field vector with a two-axis magnetic compass: where, h and b y h represent components of earth's horizontal magnetic field vector in the carrier's body coordinates where x-axis is in the forward looking direction and y-axis points to the right, the b superscript denotes the body coordinate frame.However, due to the manufacturing tolerance and magnetic interferences, compass reading is distorted by various errors and heading calculated with the raw measurements is directly corrupted.Therefore, calibration of compass involving both identifying and compensating the errors is essential.
There are many methods for food transporting compass.A classical procedure called swinging algorithm in Gebre-Egziabher et al. (2001) has been used successfully.This method involves rotating vehicle containing the compass through a series of known headings and adopts the difference between the crude heading determined by compass reading and the known heading to compute calibration parameters.A method utilizing neural networks (Wang and Gao, 2006) has been presented by modeling the nonlinear mapping between the compass heading and the true heading, which is robust in practical applications.The angular-rate method derived in Markovic et al. (2011) requires turning the compass through a full circle and estimates the parameters using the information from a low-cost gyroscope.All these methods demand an external heading reference, which limit in-situ calibration and the quality of the calibration degrades when compass is moved far away from the location where the calibration is performed, because the parameters are functions of the local magnetic field strength.Moreover, a class of reference-free approaches has been proposed.A simple method using one-turn rotation scheme (Caruso, 1998;Yun et al., 2008) measures the minimum and maximum readings of each axis and then calculates the scale factors and the bias errors with these readings, of which the error parameters is sensitive to the noise.The ellipse-fitting method described in develops the calibration parameters estimation into an ellipse fitting problem through a non-linear transformation and adopt analytic algorithm or iterative algorithm to minimize algebraic distance between ellipse and compass reading data to identify ellipse parameter.The criteria of 'best fit' (in the least squares sense) are mainly focused on minimizing the distance for ellipse, not the distortion for heading.Therefore, for heading determination systems, these methods cannot achieve the state of 'best fit' because of the nonlinear relationship between heading and magnetic vector described in Eq. ( 1), even more, when the data points for fitting ellipse distribute in a limited region, the heading accuracy corrected with these methods make large error.
To improve the performance of the aforementioned procedure, we introduce a new approach based on ellipse fitting for food transporting compass without requiring external reference.In this method, a new estimator based on the weighted approximate distance is devised, of which the approximate distance is derived using Taylor's expansion of quadratic polynomial on ellipse, the weighting coefficient is predetermined to establish the initial conditions and is heading-dependent in the iterative process and then an iterative, leastsquare algorithm is utilized to estimate the ellipse parameters.

MATERIALS AND METHODS
Error modeling: Since compass reading is corrupted by various errors to some degree, the raw magnetic field vector ˆb h which is direct output of magnetic compass will be different from the error-free magnetic field vector h b .To counteract these errors, a mathematical model between them is required first.In general, there are five error sources, namely, scale factor K sf , non-orthogonality K no , soft iron K si , hard iron B hi and Bias B b , the compass reading can be modeled as: where, K e represents the combined effect of the first three error sources and B e accounts for the rest.Generally, each axis of compass has a varying constant of proportionality between input and output and thus, in the two-dimensional case, K sf is a 2×2 diagonal matrix, in which the elements of the principal diagonal stand for the sensitivities of individual axis of compass.
Soft iron is a kind of ferromagnetic material that generates its own field in response to an external magnetic field and the resulting magnetic field depends on the magnitude and direction of the applied magnetic field with respect to the soft iron.In this study, we assume that the response of soft iron is linear and without hysteresis, then soft iron error can be expressed with a 2×2 matrix.Using the QR decomposition for the matrix, we can obtain an orthogonal matrix of which the coefficients can be calculated with compass alignment calibration and a lower triangular matrix which is in our sights.In terms of the analysis, we assume that K si is a lower triangular matrix.
Non-orthogonality error comes from the misalignment between individual axes and carrier's body coordinates and results in compass reading be cross coupling of the magnetic field components.If care is taken during installation that x-axis of compass is defined to be completely aligned with the x-axis of carrier's body coordinates, y-axis lies in the plane defined by the x-axis and y-axis of the coordinates and it is close to the latter axis, hence K no can be expressed as a lower triangular matrix which shows an equivalent effect with matrix K si .
Hard iron error is result of unwanted magnetic field generated by permanent magnets in the vicinity of compass, it is time invariant in vehicle coordinate frame, shifts compass reading by a constant amount and is represented by a 2×1 vector B hi in Eq. ( 2).
Bias is also known as dc offset or zero shift, which is a non-zero constant value and can be modeled as a 2×1 vector B b and mathematically it is grouped together with hard iron error B hi .
On the basis of these error forms, we get the other matrix sets in Eq. ( 2) that K e is a 2×2 lower triangular matrix and B e is a 2×1 vector.
Thus, in accordance with the mathematical model ( 2) and the heading computation Eq. ( 1), the combination of these errors will result in an incorrect heading estimate.

Calibration algorithm:
In this section, we present a weighted optimization estimation technique to calibrate magnetic compass, the method is based on the fact that the locus of error-free measurements from two-axis magnetic compass is a circle and the circle changes into an ellipse with the addition of errors described in the last section.
For a level, error-free magnetic compass, there is an expression as follows: where, H h is the magnitude of the earth's horizontal magnetic field vector.
Taking inverse transformation of equation gives: where, Analyzing errors effect on circle described in Eq.
(3), Eq. ( 5) gives an ellipse about vector ˆb h .Since an ellipse is a kind of planar curve, its general equation can be represented as follows:  5) and ( 6), we have: For a set of collected data, calibration process is to estimate a "best" ellipse that fit the data points as close as possible and then calculates the calibration parameters of K c and B c with the ellipse coefficients.In general, the mean square distance from data points to ellipse defined by the parameters is deemed as fit criteria, which cannot be computed by direct methods.If we define F and X by: [ , , , , ,1] T X x xy y x y = Eq. ( 6) can be expressed in a compact form: Let: ( ) where, p = (x, y) is a data point and For a set of point p i , i = 1, 2,…., N, there is an equation given by the truncated Taylor series expansion of f: where, p 0 is the unique point that minimizes the distance ||p 0 -p i || to p i and f(p 0 ) = 0, f'(p i ) is the Jacobian matrix of f(p i ), then p 0 is given by: ( ) ( ) where, f'(p i ) + is the pseudo inverse of f'(p i ).The square distance from a point to the ellipse can be approximated as: And the mean square approximate distance is: Note, (13) has a geometric property that it doesn't change if we replace αf for f where α is a nonzero number, this may result in the ellipse parameters identifiable, so a matrix constraint: Can be imposed on f without affecting the set of zeros of a minimizer of Eq. ( 13).
Substitute Eq. ( 9) into expression (13) and Eq. ( 14), we have: where, where, 1 1 ( ) ( ) Thus, ellipse fitting corresponds to the minimization of expression constrained by equation, which is an approximate estimator that can be computed with generalized eigenvector fit algorithm.Theoretically, the approximate fitting method represented by the expressions above, has been considered to be superior to the Direct Ellipse Fitting Method (DEFM) with simplified estimator based on the minimization of algebraic distance between ellipse and reading data.
For food transporting magnetic compass indicating the heading of vehicle, on the basis of analyzing Eq.
(1), the approximate distance at different points, i.e., at different coordinate, shows various effects on heading and then a weighted factor is given as follows: Accordingly, expression ( 15) is rewritten as: where, Then an Weighted Ellipse Fitting Method (WEFM) is obtained with the estimator described by expression and equation, which is a nonlinear least squares problem and an iterative algorithm described as follows is required to compute it.
• Establish an initial condition for u i and w i .
Supposing that the ellipse to be fitted is close to circle, we have: For j = 1, 2, 3…N, then there is: And u i is initialized to a nonzero number which is set to be one in the following tests: • Calculate matrix M and Q with expression (16-18).
• Obtain a least squares estimate for F as follows: Considering the function: Using Lagrange multipliers theorem, we arrive at simultaneous equations as follows: Then F is a generalized eigenvector of matrix M with respect to matrix Q corresponding to the smallest positive eigenvalue.
• Return the Step 2 and repeat until 'best fit' (in the least squares sense) is achieved, that is, under a certain resolution, the estimate of F does not change from one iteration to the next.
Calculating the compensation coefficients of K c and B c with Eq. ( 7) and (5) after the iterations complete, we can now use the estimated calibration parameters to compute the error-free magnetic field vector h b from the raw magnetic field vector ˆb h using Eq. ( 4).
Simulation studies: A series of simulation studies is examined to assess the performance of the proposed algorithm compared with the direct ellipse fitting method.We suppose that the magnetic field is uniform at the location where the magnetic sensor is and its horizontal intensity is T. As depicted in Fig. 1, the error-free magnetic field vectors covering direction in the horizontal plane are generated as reference data represented with the line of circle and the errors of which the parameters are set as follows respectively: 1.1067 0 0.0552 0.9247 Are applied to the reference data to produce the raw magnetic field data represented with the dots on the ellipse.In each simulation, a set of data points, as the training data for fitting ellipse, are sampled in a certain region of the ellipse specified by a start and end angle and a set of test data points collected from the whole ellipse with uniform interval is used to measure the calibration accuracy.
In the first simulation, we investigate the estimator under the condition that a zero-mean Gaussian white noise with variance σ of 0.2×10 -10 T is added to the 72 training data points which are sampled from the whole ellipse uniformly.Calibration parameters are estimated with the DEFM and WEFM and used to revise the raw magnetic field data separately.Figure 2 shows a comparison for calibration accuracy in the heading domain.The heading error e φ , which is computed by taking the difference between the headings generated by the calibrated magnetic field data and the reference data, has a maximum value of 7.77° before calibration (Fig. 2a) and 0.22° with the DEFM and 0.19° with the WEFM after calibration (Fig. 2b).
In the second simulation, the performance of the estimator is studied in the case of the training data points sampled in a varied region R φ of ellipse, while a noise with variance σ of 0.2×10 -10 T is set.The varied region begins from 0°.For statistical evaluation, 1000 WEFM is noticeably better than the DEFM while data points come from a small region, the DEFM even cannot compensate properly with the angle range of the region less than 120° and both improve as the region of data points was increased.
In the final set of simulations, tests are performed when the data point region is fixed, while the noise level changes.The angle ranges of region 0°-360° and 0°-160° are selected, 1000 independent noise instances for each σ with variances range from 0 to 0.2×10 -8 T are applied.The results of the RMS heading error are illustrated in Fig. 4.
As we can see, the heading accuracy are improved obviously with both calibration method and there is almost no difference in heading error between the two methods when the training data are sampled from the whole ellipse, however, when the sampling of training data is limited to a small region (0°-160°), the WEFM is found to have superior performance.These simulations also show the proposed method to be very robust.

RESULTS AND DISCUSSION
As a final verification, the proposed calibration method is carried out with experimental platform consisted of three-axis nonmagnetic turntable and magnetic compass, which is illustrated in Fig. 5.The turntable used to evaluate the algorithm accuracy is 3SK-150 manufactured by Jiujiang Precision Measuring Technology Research Institute of China, of which the resolution is 1'.The magnetic compass is fabricated in our laboratory that has three orthogonal magnetic sensors of which the two in horizontal plan is used.The axes of the magnetic compass mounted is aligned with the turntable to minimize the misalignment error, the experimental platform is located away from ferromagnetic materials.
First, a set of training data points as represented by the dots in Fig. 6 is collected at whole directions with a substantially uniform interval and a set of test data points is sampled in 72 known headings, with the reference angles being 5° apart.The ellipse coefficients are estimated through the training data points two methods.Then the calibration parameters are calculated with Eq. ( 5) and ( 7).
The raw heading errors e φ is shown in Fig. 7a, of which the maximum value is 1.90°.Under the condition that calibration coefficients are estimated through the all training data, the heading errors corrected by the two methods are found within 0.17° (Fig. 7b).When a part of the training data points from the angle range of 160° are used to fit an ellipse, the maximum value of the heading errors is still close to 0.17°t he WEFM and 0.21° calibrated by the DEFM (Fig. 7c).axis nonmagnetic turntable and magnetic compass, which is illustrated in Fig. 5.The turntable used to evaluate the algorithm accuracy is 150 manufactured by Jiujiang Precision Measuring Technology Research Institute of China, of .The magnetic compass is fabricated in our laboratory that has three orthogonal magnetic sensors of which the two in horizontal plane is used.The axes of the magnetic compass mounted is aligned with the turntable to minimize the misalignment error, the experimental platform is located away from First, a set of training data points as represented by Fig. 6 is collected at whole directions with a substantially uniform interval and a set of test data points is sampled in 72 known headings, with the apart.The ellipse coefficients are estimated through the training data points with the two methods.Then the calibration parameters are is shown in Fig. 7a, of .Under the condition that calibration coefficients are estimated through the all training data, the heading errors corrected by the two (Fig. 7b).When a part of the training data points from the angle range of 0°sed to fit an ellipse, the maximum value of 0.17° calculated with calibrated by the DEFM (Fig. 7c).

CONCLUSION
A weighted estimation algorithm for food transporting magnetic compass used in heading determination system is presented, which requires no external reference.The proposed method is based on ellipse fitting to determine the combined effort of all linear time-invariant distortions and uses an iterative least square estimator to minimize the mean square

CONCLUSION
A weighted estimation algorithm for food transporting magnetic compass used in heading determination system is presented, which requires no external reference.The proposed method is based on ellipse fitting to determine the combined effort of all invariant distortions and uses an iterative least square estimator to minimize the mean square The DEFM The WEFM weighted approximate distance from data points to ellipse.Simulation results indicate that, the proposed method is accurate, robust and superior to the direct ellipse fitting method.Experiment test results show that, the maximum value of heading errors with the proposed calibration method is 0.17° contrasted with 1.90° before calibration.