🔍🔩 Parts bench
19 lessons

The IMU: Two Flawed Witnesses

The accelerometer knows which way is down but trembles at every bump; the gyro turns smoothly but slowly forgets where zero was. Neither is fixable — and that's fine.

lesson 2 of 3 in this unit

Builds on: 2.1 Rangefinders: Distance by Stopwatch

Same idea, other course:Vector: acceleration, the quantity itself

The accelerometer: honest but nervous

An accelerometer feels accelerations — including gravity, a permanent 9.81 m/s² pointing down. Tilt the sensor and gravity’s pull redistributes across its axes; a little trigonometry turns that split into a tilt angle. The deep virtue: gravity never wanders, so the accelerometer’s idea of “down” is drift-free. Ask it twice a year apart and it answers the same.

The vice: it cannot tell gravity from any other acceleration. Every motor vibration, every bump, every jerk of the chassis masquerades as a momentary new “down”. The signal is truthful on average and hysterical in the moment — noisy but unbiased.

The gyroscope: smooth but forgetful

A gyroscope measures rotation rate — degrees per second — cleanly and calmly; vibration barely touches it. But you want the angle, not the rate, so you integrate: add up rate × dt, loop after loop.

angle ← angle + rate · dtintegration — and with it, every tiny error joins the sum forever

Therein the vice: the gyro’s rate reading is off by some whisker — a fraction of a degree per second. Integration never forgets a whisker. Hold the sensor perfectly still and watch its computed angle crawl away at a steady rate: drift, the signature failure of dead reckoning, smooth and confident and increasingly wrong.

Complementary vices

Look at the two failure modes side by side. The accelerometer is wrong right now but right on average. The gyro is right right now but wrong on average. Their flaws live at opposite ends of the time scale — fast noise versus slow drift — which means each has exactly what the other lacks. Merging them is next lesson’s four lines of code, and those four lines keep drones level.

Why not buy a better gyro?

You can — for navigation-grade money, the drift shrinks to degrees per hour. It never reaches zero: integration amplifies whatever error remains, however small, without limit. Drift is not a defect of cheap parts; it is the arithmetic of adding up. The cure is never a purer witness — it is a second, differently-flawed one.

⚗️ Lab — The Drift Bench

One tilting board, both witnesses reporting its angle live — with knobs for vibration and gyro bias.

  • Hold the board still: the accelerometer trace shivers around the truth while the gyro trace glides slowly away from it.
  • Crank the vibration (motors on!): the accelerometer becomes unreadable; the gyro barely notices.
  • Tilt the board sharply: the gyro follows instantly, the accelerometer panics first, settles later. Two witnesses, opposite alibis.
10°
30 %
0.40 °/s
Accelerometer
noisy now, honest on average
Gyro
smooth now, drifting 24°/min
Note
the gyro trace re-zeroes every 45 s — real drift never does

Work it by hand — 0 / 1

No multiple choice here: compute the value and type it. Suffixes like 2.5k or 20m are understood; answers within ±2% count.

1. A gyro's rate reading has a constant bias of 0.5°/s. After 4 minutes of integration, how far has the computed angle drifted, in degrees?

Check your understanding

1. How does an accelerometer measure tilt?

2. Why does a gyro-derived angle drift even when the sensor sits perfectly still?

3. Motors switch on and the chassis buzzes. Which witness suffers?

4. The two sensors' flaws are called complementary because…