IMU Basics and Attitude Estimation¶
Key Points¶
- Orientation is also referred to as Attitude
Basics of IMU¶
An IMU is a combination of sensors that can read:
- Gyroscope: Angular Velocities ω
- Accelerometer: Linear acceleration α
- Magnetometer: reads Magnetic Fields m
A 6-DoF IMU Contains Gyroscope and Accelerometer
A 9-DoF IMU contains all three and can be called as:
- Magnetic Angular Rate and Gravity Sensor (MARG)
- Attitude and Heading Reference System (AHRS)
- 9-DOF IMU
We want to estimate
We have
We can estimate the values using numerical integration of ωt. But the issue is, that we need the initial values of the quadrotor so we can get the initial values to start on.
- One option can be to have an absolute sensor like Vicon which can give you a start value.
- Another option is other sensors like the Camera.
- One of the other viable assumptions you can make is that your system starts from rest and is levelled perfectly.
Thus, the estimate of values can be made as:
Attitude Estimation from an Ideal Accelerometer¶
We work with an assumption that when we say roll, pitch and yaw, we are talking about Euler Angles.
We want to estimate
We have
We can estimate this using:
Real-World Problems with IMU¶
Both the Gyroscope and Accelerometer have noise and bias!
Bias: They don’t read zero at rest!
Noise: The values don’t remain constant when the sensor is not moving!
Mathematical Models¶
Gyroscope: Mathematical Model¶
ω = ω̂ + bg + ng
where:
- ω : Measured Value
- ω̂ : Ideal Value
- bg : Bias
- ng : White Gaussian Noise
Also, it is assumed that the derivative of bias follows gaussian distribution:
Due to this, Bias will overshadow the real values (be too big) when integrating if not compensated and Noise will make values drift from real values during integration.
Accelerometer: Mathematical Model¶
a=WRBT(â−gW) + ba + na
where:
- a : Measured Value
- ${}{_{}}{T}( - g^{}) $ : Ideal Value
- ba : Bias
- na : White Gaussian Noise
Also, it is assumed that derivative of bias follows gaussian distribution:
Accelerometer measure net linear acceleration on the device. Values change when device translates (not just when it rotates)
Due to this, Bias will overshadow the real values (be too big) when integrating if not compensated.
And Noise will make values drift from real values during integration.
Bias and Noise¶
Bias varies on device start and with external factors such as temperature!
Can be estimated by as a function of expectation of values when the device is at rest.
Noise varies with external factors such as temperature!
Can be estimated as variances of values when device is at rest.
Notes: The Bias and Noise change over time and need to be estimated on the fly.
Attitude Estimation¶
from a Real Gyroscope
- Estimate Bias at rest
- Remove Bias from Initial Value (Rest)
- Numerically Integrate
Pros: Good for Fast Movement.
Cons: Drift like crazy over time.
Attitude¶
Estimation from a Real Accelerometer
- Estimate Bias at Rest
-
Remove Bias from initial value(Rest) and estimate Orientation by decomposing the vector a.
t
-
Low Pass Filter the values for better estimate (Because Accelerometer Values cause a lot of errors at high speed but good for long term integral. This will cause the filter values to lag a bit.)
Generally, γ is chosen to be a small value like 0.2
Complementary Filter¶
flowchart LR
A[IMU] -->|omega| B[Integrate]
B --> D[x't+1,g']
D--> E[High Pass Filter]
E --> |*'1-gamma'| F[Sum]
F --> G[xhat't+1']
A[IMU] -->|acceleration a| C[Accelerations to Angle Conversion]
C --> H[x't+1,a']
H --> I[Low Pass Filter]
I --> |* gamma|F
Resources¶
-
ENAE788M: Class 2 Part 2 - IMU Basics, Attitude Estimation using CF and Madgwick
https://www.youtube.com/embed/8hRoASoBEwY?si=57a5gXdxrDgEoPRs