Estimating orientation by measuring gravitational acceleration with accelerometer is very responsive however, it generally includes unwanted noise caused by translational movements. On the other hand, we could integrate angular velocity measured by gyroscope to determine the angular position but this time, the problem is the ‘drifts’ over time,
In short,
- Orientation estimate from accelerometer over a time period can be trusted, but instantaneous data is not accurate.
- Orientation estimate from gyroscope over a time period diverges due to accumulated errors by drift, but instantaneous data is generally more accuarate than the former.
To solve this problem, we fuse these two signals to filter out noises each other,using Kalman filter.
Kalman Filter
In any place where you have uncertain information about some dynamic system, and you can make an educated guess about what the system is going to do next.
Kalman filter explanation
Kalman filter finds optimised gain(Kalman Gain) for each inputs. Using this algorithm, converged Kalman gain will be the optimal gain ratio of datas from accelerometer(input with noise) updated based on gyro data(true values)
- Time Update(Prediction) - Predict gravitational orientation based on accelerometer value and gain
- Measurement Update(Correction) - Update the measurement with gravitational orientation based on gyroscope and update gain.
-
Time update(Prediction) In Prediction, we estimate values based on input + previous state
Time Update(Prediction) -
Measurement update(Correction) In Measurement, we compare previous estimate with actual measurement and modulate Kalman Gain.
Measurement Update(Correction)
where,
: Accelerometer value X at time, k
: Prediction
: Previous : Gyroscope value U at time, k
: 2x2 Error Covariance Matrix
: Process noise Covariance ()
: Measurement Covariance (Noise)
: Actual Measurement
: 2x2 Identity Matrix
Kalman Filter - Example C Code
Quaternions
Relative orientation can be evaluated by the simple kinematic equation, = 0.5 * q Ⓧ w
There are also other IMUalgorithms oepn-source algorithms available.