← Back to the chapter · Next detail →

Technical detail · Complementary Filters: Sensor Trust

Under the Hood: rectangle and trapezoidal integration

Each 10 ms interval contributes an area under the gyro rate curve. The following figure compares a rectangle with a trapezoid for one interval.

A rising gyro rate curve with samples every 10 milliseconds. Between the samples reading 10.0 and 12.0 degrees per second, the area under the curve is shaded as a trapezoid worth 0.11 degrees of angle. A dashed rectangle at the newer sample's height overshoots by a red triangular sliver worth 0.01 degrees. A card works the trapezoid formula, compares the 0.12 degree rectangle result, and notes that no integration rule removes bias.
The trapezoidal rule integrates the interval to 0.11°. The rectangle at the newer rate gives 0.12°, and neither rule removes sensor bias.

The shaded interval in Figure 6 runs from ω[k−1] = 10.0 °/s to ω[k] = 12.0 °/s over Δt = 0.01 s. Averaging the two rates gives a trapezoidal angle increment of 0.11°. Using the newer rate for the whole interval gives a rectangle of 0.12°, an excess of 0.01°. Starting from 8.00°, those rules give 8.11° and 8.12° respectively; the worked update uses the rectangle rule. A smaller interval reduces this geometric difference, but both rules integrate any bias in the rate samples. Better numerical integration improves the motion estimate without removing drift.

← Back to the chapter · Next detail →