Skip to content

Implemented an adaptive orientation estimation system using ESP32 and a 9-DoF IMU. Integrated Complementary Filter with real-time gyro bias compensation (FusionBiasUpdate). The system maintained stable quaternion accuracy without noticeable drift for up to 45 minutes of continuous operation.

Notifications You must be signed in to change notification settings

Armwan/Oreintation_ICM20948

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

⭐ Orientation Estimation With IMU and ESP32


Introduction

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.


Method

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.

🧠 Mathematical Explanation of FusionBiasUpdate

The FusionBiasUpdate function is part of the Fusion library's state estimation system.
It performs adaptive calibratio and gyro bias compensation in real-time.


🔹 Role of Adaptive Bias

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.


🔸 Mathematical Background

FusionBias acts as a bias tracking filter based on stationary evidence.

1. Stationary Detection (Stance Phase)

When the sensor is stationary (linear acceleration ≈ 0), the true angular rate should be near zero:

$$ω_{measured} ≈ b_g$$

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.

2. Bias Update Rule

When stationary is detected, the estimated bias is slowly updated toward the measured value:

$$b_{g,t} = b_{g,t-1} + Gain × (ω_{measured} − b_{g,t-1})$$

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.

3. Gyroscope Output Correction

The final corrected gyroscope reading is computed as:

$$ω_{corrected} = ω_{measured} - b_{g,t}$$

These steps ensure the stability of the system against drift, and the outputs of this method can be seen in the video below.


complementary filter

About

Implemented an adaptive orientation estimation system using ESP32 and a 9-DoF IMU. Integrated Complementary Filter with real-time gyro bias compensation (FusionBiasUpdate). The system maintained stable quaternion accuracy without noticeable drift for up to 45 minutes of continuous operation.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published