# Handling Gyroscopes' Bias Drift

Gyroscopes, which capture the angular velocity vector \( \overrightarrow{\omega}\), are mostly the primary source of information in tracking the orientation of a moving object in 3D space. The angular velocity vector \( \overrightarrow{\omega}\) from gyro readings can help us find the angular displacement vector \( \overrightarrow{d\alpha}\) as follows:

\( \overrightarrow{\omega} = \dfrac{\overrightarrow{d\alpha}}{dt} \),

where \(dt\) is the sampling period. Next, through continuous integration of the angular displacement vector and by applying rotation matrices, one can find the 3D orientation of the device. The problem with using integration is that if an error is present in the gyro readings, through continuous integration of angular displacements, the orientation estimate will diverge from its actual value. It is important to note that the use of other sensors, such as accelerometers and magnetometers, can definitely help to avoid the divergence problem. However, accelerometers and magnetometers are not helpful in tracking orientation under quicker motions. The logical approach should be to improve the accuracy of each individual sensor reading to achieve a better overall performance. Most physical sensing devices including accelerometers, magnetometers and gyroscopes, thus require a factory calibration procedure to remove offset and gain from their readings. The offset and gain matrices are time-invariant, and are caused by certain stationary factors, such as the manufacturing process, sensor cross-axis misalignment, soldering stress, intrinsic inaccuracy of the sensor reading, etc. The offset and gain matrices are typically calculated at the factory using two main steps. First, a set of measurements along with their reference data are collected, and secondly, a fitting method like the least-squares-method is used to map the measured data to the reference ones, while minimizing the measurement error. The offset and gain matrices are then applied to the raw sensor readings as follows:

\( X_{calib} = AX_{raw} + C \) ,

where \(A\) is the gain matrix and \(C\) is the set of constant coefficients representing the offset in sensor readings. The values of \( X_{raw} \) and \( X_{calib} \) are also the raw and calibrated sensor readings, respectively.

One of the problems with gyroscopes is that the offset matrix C is not relatively constant. In fact, quick motion, vibration, and temperature variation can shift the offset value of the sensor over time. Therefore, even if the gyros are calibrated at the factory to have a zero offset, such conditions can cause an additional drift to the initial offset. This issue is called the gyroscopes' zero-bias drift. Depending on the accuracy of gyroscopes, the drift can become considerably large over a short or long period of time, e.g., from a few seconds to a couple of hours.

Any motion tracking device that uses gyroscopes should somehow implement a mechanism to remove the zero-bias drift from gyro readings. Some methods utilize a high-pass filter for gyros to remove the very low frequency noise including the zero-bias drift. However, the problem with this approach is that motions under relatively constant angular velocities will simply be filtered out. Another common solution to remove the gyros' zero-bias drift is to detect stationary positions, where the angular velocity readings should ideally be zero. Let us assume that the device is detected to have been stationary for \(n\) consecutive samples. Now, ideally we expect the gyro readings to be zero for the past \(n\) samples. This helps us to find a new offset vector \(\overrightarrow{C}\) to apply to the raw gyroscope readings, where

\(\overrightarrow{C} = mean(\overrightarrow{\omega_{1:n}}) \)

The new offset vector \(\overrightarrow{C}\) should be applied to the calibration formula as follows:

\( \overrightarrow{\omega}_{calib} = A\overrightarrow{\omega}_{raw} + \overrightarrow{C} \),

where \( A \) is a \(3\times3\) matrix for a 3-axis gyroscope. Updating the offset vector \(\overrightarrow{C}\) in stationary positions is very effective. However, it is non-functional, when the device is in motion. More advanced adaptive methods are typically required to update the offset matrix in real-time. Kalman-based methods are among the most common solutions for that purpose. The proposed orientation filter, OMID, is also capable of tracking the bias-drift in real-time. The scientific article for this approach is available for download here

Motsai designs and builds innovative embedded systems, and is the leading Canadian developer of miniature low-power, wireless devices used in wearables and human motion analysis. Please feel free to send us an email at info@motsai.com or drop us a line at +1-888 -849-6956. Don't forget to signup for blog updates below.