What Accelerometers and Gyroscopes Measure
An IMU (Inertial Measurement Unit) typically contains a 3-axis accelerometer and a 3-axis gyroscope (often also a magnetometer, but many robotics stacks treat it as optional). These sensors output signals in the sensor frame (the IMU’s own x/y/z axes). To use them for robot attitude and motion, you must interpret the signals with respect to the robot frame and the world frame.
Accelerometer: specific force (not “pure acceleration”)
A 3-axis accelerometer measures specific force, usually denoted f, in units of m/s^2. Specific force is the non-gravitational acceleration felt by the sensor (what a scale “feels”), which means gravity appears in the measurement depending on orientation.
A common continuous-time model in the sensor frame {S} is:
f_S = R_WS^T (a_W - g_W) + b_a + n_aWhere R_WS rotates vectors from sensor frame to world frame, a_W is the sensor’s linear acceleration in the world frame, g_W is gravity (approximately [0, 0, 9.81]^T m/s^2 depending on world convention), b_a is accelerometer bias, and n_a is noise. In a static, non-accelerating case (a_W ≈ 0), the accelerometer measures approximately -R_WS^T g_W, i.e., it becomes a gravity direction sensor.
Gyroscope: angular velocity
A gyroscope measures angular velocity ω in units of rad/s (sometimes deg/s in datasheets). A typical model is:
- Listen to the audio with the screen off.
- Earn a certificate upon completion.
- Over 5000 courses for you to explore!
Download the app
ω_S = ω_true,S + b_g + n_gGyros are the short-term workhorse for orientation changes: integrate ω over time to update attitude. However, any bias b_g integrated over time becomes an ever-growing orientation error.
Frames: Sensor, Robot, and World
Correct frame handling is the difference between a stable estimator and a confusing one. Define frames explicitly:
- Sensor frame {S}: IMU axes as printed on the package or defined by the manufacturer.
- Robot/body frame {B}: a frame fixed to the robot (e.g., x forward, y left, z up or down depending on convention).
- World/inertial frame {W}: a navigation frame (e.g., ENU: x east, y north, z up; or NED: x north, y east, z down).
You need a fixed rotation (and possibly axis sign flips) between sensor and robot frames:
v_B = R_BS v_SThis R_BS is determined by how the IMU is mounted. If R_BS is wrong, roll/pitch/yaw will be mixed, and gravity compensation will inject errors into velocity/position estimates.
Units and scaling sanity checks
- Accelerometer:
m/s^2. At rest, magnitude should be close to9.81(or1 gif reported in g’s). - Gyro:
rad/sordeg/s. A slow manual rotation of ~90° in ~2 seconds corresponds to ~45°/s (≈ 0.785 rad/s). - Sampling: confirm timestamps and sample period
Δt. Integration quality depends heavily on correctΔt.
Key IMU Behaviors You Must Model
Bias
Bias is an offset present even when the true input is zero. For gyros, bias is especially damaging because orientation is obtained by integration:
θ_error(t) ≈ ∫ b_g dt = b_g * tExample: a gyro bias of 0.5 deg/s yields ~30° error after one minute if uncorrected.
Scale factor error
Scale factor error means the sensor’s gain is slightly wrong. If the true angular rate is ω, the measured might be (1+s)ω. Over time, this causes drift that grows with motion (unlike constant bias drift that grows even when stationary).
Noise density and random walk
Datasheets often specify noise density (e.g., deg/s/√Hz for gyro, m/s^2/√Hz for accel). When sampled, noise per sample depends on bandwidth and sampling rate. Integrated gyro noise produces angle random walk; integrated accelerometer noise produces velocity random walk. Practically, higher bandwidth and higher sample rates can capture fast motion but may increase noise unless filtered appropriately.
Temperature drift
Bias and scale factor vary with temperature. A robot that warms up after power-on often shows changing gyro bias for minutes. Without compensation, your estimator may appear “fine” on the bench and drift in real operation as temperature changes.
Vibration sensitivity
Vibration can corrupt accelerometer readings (and sometimes gyros) through mechanical coupling and sensor non-linearities. High-frequency vibration can alias into lower frequencies if not properly filtered, making gravity direction estimates noisy and causing false linear acceleration.
Why Pure Integration Drifts
Gyro integration drift
Orientation propagation typically integrates angular velocity:
R(t+Δt) ≈ R(t) * Exp( (ω - b_g) Δt )If b_g is unknown or changing, the integrated orientation slowly diverges. Even with perfect bias, noise integrates into a random walk.
Accelerometer integration drift (velocity/position)
If you integrate accelerometer data to get velocity and position, you must subtract gravity in the correct frame:
a_W ≈ R_WS f_S + g_WAny small attitude error causes incorrect gravity subtraction, which appears as a constant acceleration error and quickly explodes velocity/position. This is why IMUs alone are rarely sufficient for long-term position without external references.
Gravity as a Long-Term Reference: Roll/Pitch Yes, Yaw No
When the robot is not undergoing large linear accelerations, the accelerometer measures (mostly) gravity direction. That provides an absolute reference for the tilt of the sensor relative to the gravity vector, which constrains roll and pitch.
However, gravity does not contain information about rotation around the gravity axis. Rotating the robot about vertical (yaw) does not change the gravity vector in the sensor frame. Therefore:
- Roll/pitch can be stabilized long-term by fusing accelerometer (gravity direction) with gyro integration.
- Yaw cannot be corrected by accelerometer alone; it will drift unless you add another reference (e.g., magnetometer, vision, GNSS heading, wheel/leg kinematics with constraints, or map-based localization).
Practical implication: when accelerometer is “trustworthy”
Accelerometer-based tilt correction assumes the measured specific force is dominated by gravity. During aggressive maneuvers (fast starts/stops, impacts), the accelerometer includes significant linear acceleration, so treating it as gravity will mis-correct attitude. Many filters reduce accelerometer influence when |f| deviates significantly from g or when vibration metrics are high.
Hands-On Calibration and Validation Steps
1) Static bias estimation (quick baseline)
This is a practical first step before more advanced calibration.
- Setup: Place the robot/IMU rigidly on a stable surface. Ensure it is not moving. Let it warm up for a consistent time (e.g., 2–5 minutes) if your application experiences warm-up drift.
- Collect data: Record several seconds to a few minutes of raw gyro and accel samples with timestamps.
- Gyro bias estimate: Compute the mean of each gyro axis while stationary:
b_g ≈ mean(ω_S). Subtract this from subsequent readings. - Accelerometer bias (rough): If you know the orientation (e.g., z axis aligned with gravity), you can estimate bias on axes expected to be 0 and compare the gravity axis to ±9.81. A better accelerometer calibration uses multiple orientations (see next section).
Sanity checks while stationary:
- Gyro mean should be near 0 after bias removal.
- Accelerometer magnitude should be near
9.81 m/s^2(within sensor specs and noise).
2) Axis alignment and sign checks (sensor frame to robot frame)
Before any fancy estimation, verify that your axis mapping R_BS is correct.
- Step A (gravity direction): With the robot in a known pose (e.g., upright), check which accelerometer axis measures approximately ±9.81. Confirm it matches your expected robot “up/down” axis after applying
R_BS. - Step B (single-axis rotation): Rotate the robot slowly about one robot axis at a time (e.g., yaw about vertical). After applying
R_BS, the gyro should show dominant rate on the corresponding robot axis, with the correct sign. - Step C (cross-axis coupling): If rotating about one axis produces large readings on other axes, you may have mis-mapped axes or the IMU is not mounted orthogonally (mechanical misalignment).
3) Multi-position accelerometer calibration (bias + scale)
A practical approach is a “six-face” calibration (placing each axis aligned with gravity in ± directions). It improves bias and scale factor estimates.
- Collect: Place the IMU in 6 orientations: +X up, -X up, +Y up, -Y up, +Z up, -Z up (sensor frame). Record a few seconds each.
- Compute: For each axis, the expected measurement is approximately ±g when that axis is aligned with gravity, and ~0 on the other axes (ignoring small misalignment).
- Estimate: Solve for per-axis bias and scale such that corrected measurements match ±g. Many robotics teams implement a least-squares fit to enforce that the corrected accelerometer magnitude equals g across all samples.
Tip: if you cannot easily orient by sensor axes, do it by robot axes and use your current best R_BS to interpret results.
4) Temperature characterization (bias vs temperature)
If your robot experiences temperature changes (motors heating, outdoor operation), characterize drift.
- Setup: Keep the IMU stationary. Log gyro/accel and the IMU’s internal temperature (if available).
- Vary temperature: Let the system warm from cold start to steady state, or use a controlled environment if available.
- Fit a model: Plot estimated bias vs temperature for each axis. A simple linear model often helps:
b(T) = b0 + k(T - T0). Some IMUs need piecewise or quadratic fits. - Use online compensation: During operation, subtract
b(T)based on current temperature before feeding the estimator.
5) Vibration check and filtering
To assess vibration sensitivity:
- Log while motors run: Compare accelerometer spectra (or variance) with motors off vs on.
- Look for aliasing: If vibration frequency is near or above half the sampling rate, it can fold into lower frequencies. Increase sampling rate or add analog/digital low-pass filtering.
- Estimator gating: Reduce accelerometer correction weight when vibration is high (e.g., when accel magnitude deviates from g or high-frequency energy increases).
Mounting Guidelines: Getting Good Data Before Filtering
Rigid placement and lever-arm effects
Mount the IMU rigidly to the robot structure. Any flex introduces relative motion between IMU and robot frame, appearing as false acceleration/rotation. Also consider lever-arm effects: if the IMU is far from the robot’s rotation center, rotational motion produces linear accelerations at the IMU (a = α×r + ω×(ω×r)), which can complicate interpretation if you assume the IMU is at the center.
Vibration isolation trade-offs
Soft mounts (foam, rubber) can reduce high-frequency vibration but may introduce low-frequency oscillations and phase lag, harming control and estimation. Practical guidance:
- Prefer stiff mounting plus proper filtering when you need accurate dynamics and timing.
- Use isolation when vibration saturates sensors or dominates the band of interest, but validate that the mount does not resonate in your motion band.
- Keep cables strain-relieved; cable forces can transmit vibration or slowly bias orientation if they tug on the IMU board.
EMI and grounding considerations
While IMUs are not magnetic sensors, electrical noise can still couple into power and digital lines. Use clean power regulation, short signal paths, and robust digital interfaces. If using SPI, ensure signal integrity at your chosen clock rate.
Orientation Estimation in Practice: Fusing Gyro and Accelerometer
Complementary filter intuition
A common approach is to trust the gyro for short-term changes (high-frequency) and the accelerometer for long-term tilt (low-frequency). Conceptually:
- Integrate gyro to propagate orientation quickly and smoothly.
- Use accelerometer-derived gravity direction to slowly correct roll/pitch drift.
This can be implemented as a complementary filter or as part of an EKF/UKF. The key design knob is how strongly you “pull” the estimate toward the gravity direction, which should decrease during high linear acceleration or vibration.
Yaw handling
Without an external yaw reference, yaw will drift. If your application needs stable heading, plan for one of:
- Magnetometer (with careful magnetic calibration and disturbance handling).
- Vision-based heading (visual odometry/SLAM).
- GNSS heading (dual-antenna) for outdoor platforms.
- Kinematic constraints (e.g., nonholonomic ground vehicles) combined with other sensors.
Criteria for Choosing an IMU for a Robot
| Criterion | Why it matters | What to look for |
|---|---|---|
| Gyro bias stability | Dominant driver of orientation drift | Low in-run bias stability, low Allan variance; stable over temperature |
| Bandwidth | Must capture robot dynamics without excessive phase lag | Selectable low-pass filters; sufficient output data rate (ODR) |
| Dynamic range | Avoid saturation during fast motion or impacts | Gyro range (e.g., ±2000 deg/s), accel range (e.g., ±16 g or higher if needed) |
| Noise density | Sets short-term orientation/velocity noise | Lower noise density for precision; verify at your chosen bandwidth |
| Shock rating | Survivability in drops/impacts | Mechanical shock spec aligned with expected events |
| Temperature behavior | Warm-up and environment changes cause drift | Built-in temperature sensor, factory compensation, or characterizable drift |
| Synchronization capabilities | Time alignment is critical for sensor fusion | Hardware timestamping, sync input/output, deterministic latency, PPS support |
| Interface and timing | Data integrity and latency affect estimation | SPI preferred for high rates; documented FIFO behavior and timestamps |
When comparing IMUs, prioritize gyro bias stability and synchronization for state estimation, then ensure range and bandwidth match your robot’s dynamics. A high-range IMU with poor bias stability can still drift badly; a low-noise IMU that saturates during maneuvers will also fail in practice.