This project utilizes a method similar to that of the previous project, with the goal of achieving high-accuracy quaternions and minimizing drift. The methodology employed in this project is designed to enhance accuracy while effectively addressing drift issues.
As is well known, gyroscopes tend to drift after a few minutes of operation, leading to inaccuracies in the sensor's orientation predictions. After a short period, the data they produce can become unreliable. To validate the effectiveness of this approach, a series of tests were conducted under various conditions. Remarkably, the system maintained accuracy without noticeable drift for approximately 45 minutes, which was the maximum duration of the tests.and continued to work without drift for about 45 minutes, which was the maximum test time.
In the previous project, a general overview of how these algorithms are combined was provided, but I did not focus much on the FusionBiasUpdate function. This function's role is to calculate the gyroscope's bias value and subtract it from the measurements.
The modifications made to this function are significant; instead of calling it just once at the beginning of the code, I now call it in a loop. This function is designed to detect whether the sensor is stationary by considering a threshold and a time frame for identifying rapid movements. If the sensor is detected as stationary, a new bias value is calculated and updated gradually to prevent sudden jumps in the data.
The FusionBiasUpdate function is part of the Fusion library's state estimation system.
It performs adaptive calibratio and gyro bias compensation in real-time.
Gyroscope data is strongly affected by bias (drift).
This bias is not constant — it varies with temperature, voltage, and sensor aging.
The main goal of FusionBiasUpdate is to continuously estimate the instantaneous gyro bias (bg) and compensate for it adaptively.
FusionBias acts as a bias tracking filter based on stationary evidence.
When the sensor is stationary (linear acceleration ≈ 0), the true angular rate should be near zero:
The algorithm uses a noise threshold (e.g., 2.0 dps from FusionBiasInitialise)to detect when the gyroscope is quiet enough to treat readings as bias instead of motion.
When stationary is detected, the estimated bias is slowly updated toward the measured value:
Where:
-
Gain→ adaptive gain (e.g., 0.01 dps) controlling the update rate -
Small gain (≈ 0.01) ensures smooth and stable adaptation
-
Prevents sudden noise spikes from being mistaken for true bias
-
To prevent error injection during fast motion, the update is skipped when angular velocity exceeds the threshold.
The final corrected gyroscope reading is computed as:
These steps ensure the stability of the system against drift, and the outputs of this method can be seen in the video below.
