Abstract:
Magnetic compasses may be affected by local disturbances in the magnetic field in their vicinity. These disturbances may be caused by the addition or removal of a metal article concerned with a vehicle in which the compass is mounted, and may also be due to local variations in the Earth&#39;s magnetic field. The system described herein compensates for such disturbances in the magnetic field to maintain the accuracy of the magnetic compass by transforming an ellipsoidal locus to a spherical locus at a different orientation in space. For example, a one-shot algorithm is employed in which data collected during a setting maneuver of the vehicle is processed to fit a generalized reduced quadric equation having six or less coefficients rather than the nine calibration points required in the prior art for fitting a generalized quadric equation for an ellipsoid. The present invention thus significantly reduces the processing power required.

Description:
This is a continuation of application Ser. No. 07/349,936, filed May 5, 1989, which was abandoned upon the filing hereof, and which was a continuation of application Ser. No. 06/902,881 filed Sep. 2, 1986 which is abandoned. 
    
    
     BACKGROUND OF THE INVENTION 
     This invention relates to the calibration of magnetic compasses to compensate for local disturbance of the magnetic field caused by the structure of the vehicle within which the compass is mounted. 
     The ideal non-disturbed locus of a vector representing the magnitude of x,y and z signals output by a 3 axis magnetometer is a sphere centered on the origin of the x,y and z axes; however, due to disturbance caused by the ferromagnetic structure of the vehicle carrying the magnetometer, the locus is transformed from a sphere to an ellipsoid offset from the origin of the x,y and z axes. Therefore, in order to take account of the transformation and offset of the locus and thus to obtain compensated x,y and z data it is necessary to apply a compensation which reverts the offset ellipsoid locus to the sphere located at the origin of the body axes. 
     As a first step in this method, it is necessary to derive data which defines the ellipsoid representing the disturbed field. In published U.K. Application 2,128,749A, for example, the vehicle is moved through a setting routine to obtain 9 calibration points to allow determination of the coefficients of x,y and z in the equation: 
     
         ax.sup.2 +by.sup.2 +cz.sup.2 +2fyz+2gzx+2hxy+2ux+2vy+2wz=d.sup.2 
    
     where 
     x is the magnetic field sensed in the x direction 
     y is the magnetic field sensed in the y direction 
     z is the magnetic field sensed in the z direction 
     This method involves finding the inverse of a 9×9 matrix and as such requires considerable computing power. In addition, it is found that with some selections of calibration points the above equation does not converge to an ellipsoid but instead fits the points to a non-ellipsoidal shape thus preventing implementation of valid compensation. Also, in U.K. Application 2,128,749A, once the coefficients have been determined they are used to determine the translation needed to bring the ellipsoidal locus to the origin of the x,y and z axes, the amount of rotation to bring the major axis of the ellipsoid into coincidence with the y axis, the amount of scaling of the x,y and z axes to bring the ellipsoid into a sphere, and the amount of rotation to return the sphere back to its original position. 
     U.S. Pat. No. 4,414,753 also discloses a similar form of magnetic compass calibration. 
     SUMMARY OF THE INVENTION 
     According to one aspect of this invention, there is provided a magnetic compass for a vehicle adapted to enable the output of the compass to be compensated by disturbance to the magnetic field caused by the vehicle, and including: 
     (i) three magnetic sensors responsive to respective nominally orthogonal components of the disturbed magnetic field acting along respective nominally orthogonal body axes of the vehicle for producing signals corresponding to the components; 
     (ii) data storage means for accumulating data output by the sensors during a setting maneuver of the vehicle; 
     (iii) data processing means for processing data stored in the data storage means to fit a generalized reduced quadric equation having six or less coefficients and defining an ellipsoid representing the locus of values of the signals and for determining the coefficients; 
     (iv) calibration means for deriving from the coefficients a calibration function for adjusting values output by the magnetic sensors so that the locus of adjusted values is a spheroid centered on the origin of the body axes, and 
     (v) compensation means for receiving raw data from the magnetic sensors and for implementing the calibration function thereby to obtain signals corresponding to orthogonal components of the magnetic field in which the disturbance has been compensated. 
     Preferably the data processing means processes data stored in the data storage means to fit a generalized reduced quadric equation of the form: 
     
         ax.sup.2 +by.sup.2 +1/2(a+b)z.sup.2 +2 hxy+2px+2qy+2sz-1=0 
    
     where x,y and z are values representing the magnetic field in the x,y and z directions, and determine the coefficients a,b,h,p,q and s. 
     By this arrangement it will be appreciated that the number of coefficients in the equation defining the ellipsoid has been reduced by 3 to 6 as compared with the arrangement disclosed in published Application No. 2,128,749A. This has the clear advantage that computing load is reduced, for in a &#34;one shot&#34; case the solution of the general quadric equation to find the values of the coefficients involves finding the inverse of a 6×6 matrix rather than the inverse of a 9×9 matrix. In addition, further work has shown that in fitting the sampled x,y and z data to the full model having 9 states, it is possible that the coefficient obtained will produce a non-ellipsoid fit. By contrast, with the reduced 6 state model it is found that in all cases the surface generated will be an ellipsoid. Furthermore, there is excellent convergence. 
     In one arrangement, referred to herein as the &#34;one-shot&#34; algorithm, data from the magnetic sensors is stored during a setting routine at the end of the which the stored data is employed to derive the coefficients a,b,h,p,q and s. In this instance, the data processing means employs a least squares method to fit the x,y,z data to the 6 state quadric equation. This gives rise to an equation of the form 
     
         a=A.sup.-1 v 
    
     where 
     a is a 6×1 vector comprising the coefficients a,b,h,p,q and s; 
     A is a 6×6 accumulation matrix array containing products of x,y and z data; and 
     v is a 6×1 accumulation vector containing products of x,y and z data. 
     According to another aspect of this invention, there is provided a magnetic compass for a vehicle adapted to enable the output of the compass to be compensated for disturbance to the magnetic field caused by the vehicle and for adjusting the compensation to allow for variation in the disturbance and including, 
     (i) three magnetic sensors responsive to respective nominally orthogonal components of the disturbed magnetic field acting along respective orthogonal body axes of the vehicle for producing signals corresponding to the components; 
     (ii) model coefficient storage means for storing initial values for the coefficients of a generalized quadric equation defining an ellipsoid representing the locus of values of signals x,y and z output by the magnetic sensors; 
     (iii) adaptive processing means for receiving and processing continuously data from the sensors to update the coefficients to compensate for variations in the disturbance of the magnetic field; 
     (iv) calibration means for deriving from the updated coefficients a,b,h,p,q and s a calibration function for adjusting the values of x,y,z output by the magnetic sensors so that the locus of values of signals x,y and z is transformed into a sphere centered on the origin of the body axes of the vehicle; 
     (v) compensation means for receiving raw data from the magnetic sensors and for implementing the calibration function thereby to obtain signals corresponding to orthogonal components of the magnetic field in which the disturbance has been compensated. 
     According to yet another aspect of this invention, there is provided a magnetic compass for a vehicle adapted to enable the output of the compass to be compensated for disturbance to the magnetic field caused by the vehicle and for adjusting the compensation to allow for variation in the disturbance and including: 
     (i) three magnetic forces responsive to respective nominally orthogonal components of the disturbed magnetic field acting along respective body axes of the vehicle for producing signals corresponding to the components; 
     (ii) accumulation data storage means for accumulating data output by the sensors; 
     (iii) calibration data storage means for storing data representing a matrix relating a vector representing the coefficients to a vector representing the accumulation data contained in the accumulation data storage means; and 
     (iv) signal processing means for processing data output by the magnetic sensors and for updating the data stored in the calibration data storage means in accordance therewith to compensate for variations in the disturbance to the magnetic field. 
     By this arrangement, the variations in disturbance in the magnetic field, due for example to changes in the magnetic signature of the vehicle caused by addition or removal of metal articles, can be compensated, and the speed with which the adaptation is made can be controlled dependent on whether the error is a slow drift or a sudden, discrete change in the magnetic signature of the vehicle. In addition, as the vehicle travels across the earth&#39;s surface, the change in the magnetic field may be compensated. Also, an irregular data rate may be used. 
    
    
     BRIEF DESCRIPTION OF THE DRAWINGS 
     Certain specific embodiments of a magnetic compass will now be described by way of example only, reference being made to the accompanying drawings, in which: 
     FIG. 1 is a block diagram showing the processes involved in a magnetic compass incorporating a one shot, reduced model algorithm for calibration; 
     FIG. 2 is a block diagram showing the processes involved in a magnetic compass incorporating an adaptive calibration technique, and 
     FIG. 3 is a block diagram illustrating an embodiment of the calibration apparatus for a magnetic compass in accordance with the invention. 
    
    
     DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS 
     Initial studies were carried out in which a full general quadric equation of the form 
     
         ax.sup.2 +by.sup.2 +cz.sup.2 +2hxy+2fxz+2gyz+2px+2qy+2sz-1=0 (equation I) 
    
     was fitted to x,y and z data received from the x,y and z axis magnetometers. The model worked well when adequate excursions were performed during the calibration maneuver, but when such excursions were not available, the model&#39;s performance suffered and in particular in the z axis. In fact, in these cases the classical characteristic of parameter unobservability was seen; two z axis parameters `fighting` each other, grossly mis-identified, yet compensating for each other&#39;s error. In many practical applications where the algorithm is required to run continuously, adequate maneuver for a full 3D calibration is unlikely for the majority of the time. In addition, solving the equations to determine the 9 parameters requires substantial computing power and places a high workload on the CPU. 
     The invention have proposed a reduced form of equation I in which, by constraining the z axis parameters, only 6 unknown parameters are involved. Two constraints are used: 
     (1) The z axis shape coefficient `c` is constrained to lie between `a` and `b`. A general constraint of this form would give a least square problem tha would be difficult to solve. Instead, a more rigid constraint is applied: 
     
         c=(a+b)/2 
    
     (2) The elimination of the modelling of rotations of the ellipsoid z axis about x or y. This is equivalent to setting 
     
         f=g=0 
    
     These constraints have the effect of limiting the model&#39;s accuracy to soft iron components in the z axis. Hard iron effects are modelled (by coefficient `s`), but the existence of soft iron effects will be absorbed by `s`. 
     The reduced model now becomes 
     
         ax.sup.2 +by.sup.2 +1/2(a+b)z.sup.2 +2hxy+2px+2qy+2sz-1=0  (equation II) 
    
     Applying the least squares fit technique to magnetometer data using this model gives the symmetric system of the form ##STR1## or 
     
         As=v                                                       (equation IV) 
    
     In this expression 
     
         λ=(x.sup.2 +z.sup.2 /2) 
    
     
         μ=(y.sup.2 +z.sup.2 /2) 
    
     In equation IV, A is an accumulation matrix comprising products of x,y,z, data up to the fourth order; a is a vector of model parameters; and v is an accumulation vector comprising products of x,y,z data up to the second power. 
     A one shot algorithm is typically solved in this equation by Gaussian elimination--effectively finding the inverse of A. 
     The benefits of the reduced model are: 
     (1) A smaller model (6 states), which therefore represents a smaller processor work-load (and memory requirement). This benefit is useful because the difference is significant: work load is proportional to N cubed in some places within the algorithm. 
     (2) A guarantee of convergence if adequate heading excursions are performed. In the x-y plane the model is as good as a 2D model, and, provided at least half of an orbit is achieved, the x,y parameters will converge to an ellipse. When excursions in the z direction are achieved, the z axis coefficients will begin to `soak up` z axis errors. 
     A number of simulation runs have been performed using this model. Figure-of-eight maneuvers and pitch excursions were used in all occasions for regions of varying magnetic dip. Convergence was achieved and the error in the identified parameters in the x-y plane gave rise to small equivalent heading errors. The error in the z axis parameters is heavily dependent on the validity of the assumption that the z axis shape coefficient lies between the x and y axes shape coefficient. With data compatible with this assumption z axis errors are small; data that are not compatible with this assumption give rise to equivalent errors in the identified parameters. 
     Once the parameters of the reduced model have been determined using the above method, the calibration coefficients--that is, the translation of the ellipsoid to the origin of the x,y and z axes and its transformation into a sphere-are determined. The calibration coefficients are then applied to all subsequent data output by the magnetometers. The determination of the calibration coefficients is discussed in detail below. 
     Referring to FIG. 1, the compass includes three magnetic sensors aligned with the x,y and z body axes of the vehicle on which the compass is mounted. The sensors supply x,y and z data which is initially processed in accumulation processor 10 to accumulate the x,y and z data--that is, to compute and store the 42 values constituting the A accumulation matrix and the v accumulation vector of equation IV. The values of A and v are then further processed in model coefficient determinator 11 effectively to find the inverse of A so as to find a in the equation 
     
         a=A.sup.-1 v 
    
     where a, the vector representing the 6 model coefficients is then used to determine in a calibration coefficient processor 12 the calibration coefficients required to translate and transform the ellipsoidal locus of raw xyz into a spherical locus centered on (0,0,0). 
     In order to allow the compass quickly to react to changes in magnetic signature or magnetic field, a second embodiment of magnetic compass incorporates an adaptive algorithm which continually updates a previous coefficient vector a. 
     Equation IV may be re-written in a way that reflects a recursive approach: 
     
         a.sub.n+1 =(A.sub.n +ΔA).sup.-1 (v.sub.n +Δv)  (equation V) 
    
     where A n  and v n  are the accumulation arrays before the n+1th update, and ΔA and Δv are the increments to be made to the accumulators at the n+1th update. It should be noted from inspection of equation III that the increment on the A matrix, ΔA can be formed from Δ v  : 
     
         A=ΔvΔv.sup.T 
    
     The matrix inversion lemma can be applied to the inverse to obtain a recursive expression in A -1 . The result is: ##EQU1## It should be noted that in this expression the denominator term is scalar and we have avoided a matrix inverse; a modification term is added to the previous iteration&#39;s calculation of A -1  to obtain the new value. 
     In order to avoid potential problems caused by matrix multiplications and additions, it is proposed to employ a `UD` (Upper Diagonal) method developed by Bierman known as Bierman&#39;s UD update algorithm. The method relies on a factorization of a matrix of the following form: 
     
         A.sub.n.sup.-1 =UDU.sup.T 
    
     where U is upper triangular with unit diagonals and D is a diagonal. 
     This factorization is only possible if the inverse of A is symmetric; this is so in our case. 
     With the inverse of A expressed in this form an update algorithm can be produced. It appears to be extremely complicated, but in practice lends itself to computer implementation very well. Such an algorithm has been developed by Bierman, and details may be found in &#34;Factorization Methods for Discrete Sequential Estimation&#34; by G. J. Bierman (Academic Press 1972). The above recursive form requires an initial matrix inverse, A o   -1 , and vector, v o , to start it off. In general these can be of any value, but the way in which the solution will converge on the true solution will be dependent on these starting conditions. With no additional information, the best starting condition is probably one where A o   -1  and v o  are chosen to give the parameter vector a values representing a spheroid. Alternatively, if a one shot calibration can be carried out then the resultant A and v can be used. 
     This second suggestion is not ideal; it would be undesireable to have both the one shot algorithm and the recursive algorithm in the computer. For this reason the former synthesized initial condition is used. 
     Since the UD algorithm works on arrays U and D, and not A -1 , in the implementation U o  and D o  are actually required. 
     So far the part of the recursive algorithm that computes the inverse of A has been discussed. To complete the process additional computation is necessary. A block diagram of a magnetic compass incorporating a complete recursive algorithm is given in FIG. 2. 
     FIG. 2 shows the first block 13 where the formulation of v and increments in v takes place. The second block 14 performs the UD update, and the third stage 15 uses the inverse matrix factors, U and D, and the accumulation vector v, to derive the model parameters a. Finally, the parameters are used in block 16 to form the calibration coefficients, details of which will be given later. 
     The above-defined algorithm has been tested; the tests were aimed at showing the following: 
     (1) That synthetic initial conditions can be used to start the recursive algorithm. 
     (2) The recursive algorithm is able to track a changing signature. 
     (3) That different rates of convergence are possible by selection of the synthetic initial conditions. 
     The tests were carried out using a figure-of-eight profile with pitch excursions in a north direction, noise of 0.5% in each axis and 600 data points. A number of different runs (different angles of dip and maneuver excursions) were used and on all occasions the recursive algorithm results maintained the correct solution. Variation in the identified calibration coefficients did occur due to noise and maneuver. The magnitude of this variation was less than 0.05% for the x and y coefficients and 0.15% for the z coefficients. 
     The first test showed the algorithm can track changes in the magnetic signature. New data were then created with different model parameters and these were fed to the algorithm. All the model parameters slowly changed values, converging towards those expected for the new model. 
     Once a has been found in either of the above methods, the values of a,b,h,p,q and s are used to determine the calibration coefficients which translate and transform the raw x,y, and z data. The origin of the fitted ellipsoid is formed by forming a symmetric matrix: ##EQU2## This is reduced to a 3×3 matrix by setting (noting that f=g=0) ##EQU3## and letting a&#39;=a/cc 
     b&#39;=b/cc 
     c&#39;=c/cc=1/2(a+b)/cc 
     h&#39;=h/cc 
     where 
     
         cc=1-ax.sub.o.sup.2 -cz.sub.o.sup.2 -2hx.sub.o y.sub.o -2px.sub.o -2y.sub.o -2sz.sub.o 
    
     The deflated matrix is now ##EQU4## 
     The calibration coefficients transformation calibration matrix is found by factorizing B to give a diagonal matrix D: 
     
         L.sup.T BL=D 
    
     where L is lower triangular. 
     Then the calibration matrix C is given by 
     
         C=D.sup.-1/2 L 
    
     where D(i,i)=1/d ii   
     Then the magnetic field vector H is given by ##EQU5## where C is a 3×3 calibration matrix. ##EQU6## is a vector representing the raw magnetic data. 
     This vector is then adjusted to allow for attitude of the vehicle to obtain a converted vector H b  : 
     
         H.sub.b =[dcm][H] 
    
     where [dcm] is the directional cosine matrix. 
     The magnetic heading ψ is then obtained from the equation ##EQU7## 
     A discussion of various modifications to the above two embodiments now follows. 
     AGE WEIGHTING 
     In the recursive algorithm, age-weighting is an important consideration. Firstly, the aim for the recursive algorithm is that it may adapt to vehicle magnetic signature changes. Secondly, because it will run continuously, without age-weighting the accumulators will overflow or underflow. 
     The means by which age-weighting is achieved is straightforward: accumulator data are periodically weighted by a factor less than unity. The choice of value for this factor is dependent on sampling rate and certain operation factors. 
     If an irregular data is used (as in the case where prolonged straight and level flight data of the vehicle are excluded), it is not possible to deduce a time-constant as such. In this case it is necessary to think of the weighting constant in terms of number of samples accumulated: 
     
         K=2.sup.m 
    
     FAST ADAPTATION 
     When there is a need for the algorithm to adapt quickly to a change in magnetic signature, the age-weighting mechanism can be used to achieve this. A discrete input to the algorithm is necessary to initiate a weighting. 
     The actual weight used to perform this function will be more severe than those suggested for continuous age-weighting. The value chosen will determine the degree of authority that is given to historic data compared with subsequent data. For example, if the value of G is chosen to be 0.5 then data collected up to the time of performing the weighting will be given half the authority compared with that given to data collected after the event. This will have the effect of halving the number of samples necessary to counteract those previously collected, thus shortening the time for the algorithm to converge to a new situation. Clearly, weighting factors between say 0.2 and 0.5 are likely to be used. The actual value chosen is dependent on the expected change of magnetic signature when stores are released. 
     EARTH&#39;S FIELD ESTIMATION 
     A prerequisite of the recursive algorithm is the ability of being able to estimate the intensity of the earth&#39;s magnetic field. Intensity is important, because it effectively defines the `size` of the ellipsoidal model. Spatial changes that cause intensity changes demand that the model adapts in sympathy. Direction of the earth&#39;s magnetic vector does not require identification. 
     DIRECT ESTIMATES 
     The principle of direct estimation of the earth&#39;s field intensity relies on being able to process calibrated data. These data can be root-sum-squared to find the intensity. This is then used to normalize incoming data, thus compensating for field changes. 
     The main difficulty with this principle is how to handle the data when initially a full calibration is not available. We propose overcoming this difficulty as follows: 
     (1) Initially, the calibration process will take place using some arbitrary normalization. In this mode the initial calibration maneuver will take place in a locality. 
     (2) This is followed by a period of field intensity estimation in the locality. 
     (3) Stored data are normalized by the newly estimated intensity in a one-shot process. 
     (4) Recursive calibration continues using current estimates of intensity for normalization. 
     These four stages require triggering. The first is triggered by a discrete input that initiates the calibration. This must continue until sufficient maneuver has occurred, and when this has occurred the second stage can take place. This stage can be allowed to continue for a predetermined time or a number of samples. At the end of this period the third stage of the one-shot normalization takes place. After this the algorithm operates in its normal running mode. 
     Referring now to FIG. 3, there is illustrated a specific embodiment of compass calibration device 20. Signals M x ,M y  and M z  from the x,y and z magnetometers are supplied from a pre-processing device 21 to a data accumulation store 22 together with initialization data from an E 2  PROM device 23. The data from accumulation store 22 (corresponding to V) is supplied to an UD update processor 24 where the values of v are used to update the UD matrix which is held in the E 2  PROM device 23 and which corresponds to A -1  mentioned earlier. The UD matrix is then processed at 25 for UD separation and vector formation. The offsets are then calculated at 26 which identify the offset of the center of the ellipsoidal locus from the origin of the x,y and z axes. The calibration matrix is calculated at 27 to determine the shaping matrix which converts the ellipsoidal locus into a spheroid. The offset data and the calibration matrix are applied as raw data to the sensor compensation device 28 to obtain compensated magnetic components H b   x ,H b   y  and H b   z . The calibration matrix and the offsets are also stored in the E 2  PROM device 23. 
     An intensity estimator 29 receiving compensated signals from the sensor compensation is operable in response to a discrete input to estimate the intensity of the magnetic field, and this data may be used thereafter to normalize the incoming data. 
     Age weighting of the data is effected at 30 in the manner previously described.