Another source of error is sensor bias. This constant offset
produced by the sensor is in some cases as large as about 25% of the
full signal range measured during normal operation. The amount of
bias varies from sensor to sensor, but is very repeatable from test
to test for an individual sensor. Bias in the accelerometer triad is
relatively small, and has thus far been ignored. The angular rate and
magnetic field sensors (the cheaper of the three) show significant
bias. While in the short term, bias may be assumed to be constant, in
reality it slowly changes during the duration of the test, although
most of the change occurs in the few minutes after startup. For
example, after power has been applied to the magnetic field sensor,
the magnetic field vector reported by the sensor slowly shifts and
exponentially approaches a certain direction and magnitude (assuming
that the vehicle is stationary). If the vehicle is powered down, and
immediately powered back up, the exponential change does not reset,
but instead continues on where it left off. It has been assumed that
this bias is due to temperature.
A bias in the sensed acceleration will cause errors in the estimation
of the vehicle tilt. Bias in the magnetic field can cause errors in
estimation of vehicle heading. Bias in the vehicle angular rate
sensor causes the vehicle to perceive that it is constantly rotating.
A PD controller will this imaginary error in the derivative term, and
in practice has been observed to produce up to about a
1°2° steady state error. Due to these detrimental effects,
it is good to determine and eliminate the sensor bias.
The angular rate bias may be estimated in real time by putting the
vehicle in attitude hold, and activating a simple estimation
algorithm from the user interface (Section 3.4). This estimator
simply averages all of the angular rate values over the entire time
that the estimator has been active, and upon deactivation updates the
bias with the result
The magnetometer bias is fairly large and repeatable, so its
approximate value been experimentally measured and hardcoded in the
system software. The magnetometer bias may be updated real time by
activating the magnetometer bias estimation algorithm from the user
interface (Section 3.4). This algorithm uses the fact that the
magnetic field vector is of constant magnitude. This fact indicates
that the tip of the magnetic field vector should always lie on the
surface of a sphere of radius _{ }
centered at the origin (Figure 45).
Figure 45 Effect of bias on magnetic field vector
If the value reported by the magnetometer does not lie on the surface of this sphere and noise is neglected, then the error must be due to bias, or a perturbation in the magnetic environment. Testing has shown that magnetic disturbances within the tank at the SSL are relatively small. This is due to the fact that ferrous metals are not typically used in the underwater mockups used at the SSL. Once the error in the reported magnetic field has been identified, the algorithm makes the minimum change to the estimated bias vector necessary to move the tip of the reported magnetic field vector to the surface of the sphere. If we let _{ } represent the magnetic field reported by the magnetometer, then

_{} 
(4.27) 
where _{ }
represents the actual magnetic field, and _{ }
represents the actual bias vector.
Figure 46 Minimum bias vector change
If _{ } is the estimated magnetometer bias, we want to find a new bias vector _{ } such that there is the minimum change between _{ } and _{ }, and _{ }. First form a unit vector from the tip of the estimate of the bias vector _{ } toward the center of the sphere describing the possible solutions for the bias vector that satisfy _{ }. The center of this sphere is located at the tip of _{ } (Figure 46). This is given by

_{}. 
(4.28) 
The new bias vector is back from the tip of _{ } a distance of _{ } in the opposite direction of this unit vector. Therefore, the new bias estimate is

_{}. 
(4.29) 
So to estimate the bias, the algorithm need only know the magnitude of the magnetic field vector, the current reading from the magnetometer, and an initial bias estimate. As the vehicle rotates, the estimate is continuously refined.