Hardware lab 09 · Inertial sensing
Motion sensors disagree. Fusion makes them useful.
Rotate and shake a virtual controller while watching its accelerometer, gyroscope, register bytes, three orientation estimates, calibration bias, and drift.
Live six-axis bench
- SAMPLE
- 0 · 0.00 s
- |ACCEL|
- 1.034 g
- |ANGULAR RATE|
- 0.0 °/s
- ACCEL TRUST
- 90%
- GESTURE
- STEADY
Motion and sensor conditions
Hold a direction to command angular velocity. Release it and the controller stops, but an uncalibrated gyro estimate keeps drifting from electrical bias.
Injected gyroscope zero-rate bias
Keyboard: arrows control roll/pitch · Q/E control yaw.
Stabilization experiment
Use the fused estimate to hold roll and pitch within 3° of level. A shake temporarily makes gravity an unreliable reference.
STABILIZED
| Estimator | Roll | Pitch | Yaw | R/P error |
|---|---|---|---|---|
| True pose | 0.0° | 0.0° | 0.0° | reference |
| Accel only | -0.6° | -0.3° | not observable | 0.6° |
| Gyro only | -0.6° | -0.3° | 0.0° | 0.6° |
| Complementary | -0.6° | -0.3° | 0.0° | 0.6° to level |
Bias calibration
A still calibration averages 192 gyro samples and subtracts the measured zero-rate offset. Calibration is rejected if the controller is moving.
Raw signal scope
Six channels before fusion
| Axis | Raw accel | Gravity model | Raw gyro | Bias-corrected |
|---|---|---|---|---|
| X | 0.0055 g | 0.0000 g | 1.034 °/s | 1.034 °/s |
| Y | -0.0101 g | 0.0000 g | -1.171 °/s | -1.171 °/s |
| Z | 1.0341 g | 1.0000 g | 1.503 °/s | 1.503 °/s |
Accelerometer axes: X right · Y forward · Z up. Gyro axes: X roll · Y pitch · Z yaw.
12-byte register burst
Signed 16-bit big-endian words: AX AY AZ GX GY GZ. This bench models ±8 g at 4096 LSB/g and ±2000 °/s at 16.4 LSB/(°/s).
00 17 FF D7 10 8C 00 11 FF ED 00 19Experiments to try
- Freeze the controller without calibrating and watch gyro-only yaw drift from constant bias.
- Calibrate while still, zero the estimators, then compare the drift rate.
- Set α near 1 for smooth, fast gyro behavior; set it lower to follow noisy gravity more strongly.
- Inject a shake and watch the accelerometer angle jump while its fusion trust falls.
- Lower the sample rate and compare the stair-stepped response and integration behavior.
- Notice that an accelerometer cannot reveal yaw: gravity has no compass heading.