Skip to main content
Open In Colab An inertial measurement unit (IMU) measures how the body it is fixed to moves. It contains a gyroscope and an accelerometer, each with three orthogonal axes, and some add a magnetometer. An IMU senses nothing outside the robot, so it never sees a wall or a landmark the way a camera or a LIDAR does. It reports the motion itself, hundreds of times a second, and the robot’s pose has to be recovered by integrating those samples. This section models the two sensors and their errors, and shows that integration alone keeps the pose for only a few seconds. A TurtleBot3 carries two IMUs once a D435i camera is mounted on it. The robot’s controller board, the OpenCR 1.0, has an InvenSense ICM-20648, which replaced the MPU9250 in 2020 (ROBOTIS). The D435i has its own Bosch BMI055, fixed to the camera (librealsense). This section uses the robot’s IMU. The camera’s IMU appears in the visual-inertial odometry section, where it is fused with the camera it is bolted to.

The gyroscope

A gyroscope measures angular velocity. A triaxial gyroscope gives the three components of the angular velocity ω\boldsymbol\omega of the body, expressed in the body frame {B}\{B\}. The sensors in phones and robots are micro-electro-mechanical systems (MEMS): a small mass vibrates at several kHz, and a rotation pushes it sideways in proportion to the rate, which is measured capacitively (Corke, 2023). Integrating the angular velocity gives orientation. If RWB,kR_{WB,k} is the rotation from the body frame {B}\{B\} to the world frame {W}\{W\} at step kk and ωk\boldsymbol\omega_k is held constant over the sample interval δt\delta t, the orientation one step later is RWB,k+1=RWB,k eδt [ωk]×,R_{WB,k+1} = R_{WB,k} \, e^{\delta t\, [\boldsymbol\omega_k]_\times}, where [ω]×[\boldsymbol\omega]_\times is the skew-symmetric matrix of ω\boldsymbol\omega and the matrix exponential is the rotation by angle ∥ω∥δt\|\boldsymbol\omega\|\delta t about ω\boldsymbol\omega. This is the exponential map from the kinematics chapter, applied in the body frame because that is where the gyroscope measures.

The accelerometer

An accelerometer is a proof mass on a spring. The spring holds the mass against gravity and against the body’s acceleration, so the displacement measures the difference between the two. With the world zz axis up and gravity g=(0,0,−9.81)\mathbf g = (0, 0, -9.81) m/s², a triaxial accelerometer reports the specific force f=RWB⊤(a−g),\mathbf f = R_{WB}^\top (\mathbf a - \mathbf g), the acceleration a\mathbf a of the body minus gravity, rotated into the body frame. A robot standing still on a level floor has a=0\mathbf a = 0, so its accelerometer reads (0,0,9.81)(0, 0, 9.81): an upward acceleration of one gg, although it is not moving. Some phone apps report the opposite sign, which adds to the confusion (Corke, 2023). To get position you invert this model. Rotate the reading into the world frame with the current orientation estimate, add gravity back, and integrate twice: ak=RWB,kfk+g,vk+1=vk+akδt,pk+1=pk+vkδt+12akδt2.\mathbf a_k = R_{WB,k} \mathbf f_k + \mathbf g, \qquad \mathbf v_{k+1} = \mathbf v_k + \mathbf a_k \delta t, \qquad \mathbf p_{k+1} = \mathbf p_k + \mathbf v_k \delta t + \tfrac12 \mathbf a_k \delta t^2 . The orientation enters this step. An error in RWB,kR_{WB,k} rotates part of the 9.81 m/s² of gravity into the horizontal plane, where the integration treats it as acceleration. The code below implements both sensor models and this integration, which is called strapdown integration because the sensors are strapped to the body rather than held level by gimbals. The last line checks the sign convention on a robot at rest.

Noise and bias

A common model for any one axis of an inertial sensor is x~=s x+b+ε,\tilde x = s\,x + b + \varepsilon, where ss is the scale factor, bb the bias and ε\varepsilon random noise (Corke, 2023). Calibration can fix the scale factor. The bias causes most of the trouble: it differs from device to device, changes with temperature and wanders slowly over time. Integration turns each error into a growing one. White noise on the accelerometer, integrated twice, gives a position error that grows like t3/2t^{3/2}. A constant accelerometer bias bb is worse: integrated twice it gives 12bt2\tfrac12 b t^2, so 0.05 m/s² becomes 2.5 m after 10 s and 90 m after a minute. A gyroscope bias acts through orientation. On a body that does not rotate, a bias bgb_g about a horizontal axis tilts the orientation estimate by bgtb_g t, and the tilt leaks 9.81sin⁡(bgt)9.81 \sin(b_g t) m/s² of gravity into the horizontal acceleration. That error is integrated twice more, so the position error grows like t3t^3. A robot that turns behaves differently, as the example below shows.

Dead reckoning a TurtleBot from its IMU

The TurtleBot below drives a counterclockwise circle of radius 1.5 m at 0.2 m/s for 60 s, a little more than one lap. Its IMU samples at 200 Hz with the white noise of the course simulator’s TurtleBot3 IMU: 2e-4 rad/s on each gyro axis and 1.7e-2 m/s² on each accelerometer axis. The integration starts from the true pose and velocity, so every error that appears comes from the sensor. Four versions of the same drive differ only in the bias. The biases are illustrative, of the size the course simulator gives the D435i’s IMU: 3, -4 and 2 mrad/s on the gyro axes and 0.04, -0.03 and 0.05 m/s² on the accelerometer axes.
For comparison, wheel odometry integrates the commanded wheel speeds of the same loop. The wheels slip by the amounts used in the EKF localization section, a standard deviation of 5% of each wheel speed plus 0.1 rad/s.
Output from cell 5 The vertical axis is logarithmic. Without bias the IMU estimate stays within 2 cm of the true position for the first 10 s and then drifts away, reaching 2.0 m after 60 s. Wheel odometry with slipping wheels ends 0.48 m off, so on a ground robot even a bias-free IMU loses to the wheels within a minute. With bias the estimate is 7.8 m off after 10 s and 643 m after 60 s. The two single-bias curves show where the error comes from. The accelerometer bias alone gives 3.5 m after 10 s, close to the 12bt2\tfrac12 b t^2 estimate. The gyroscope bias alone gives almost all of the final error. Because the robot keeps turning, the horizontal part of the bias points in a different world direction as the lap goes on, so the tilt does not grow without bound: it is 2.7° after 10 s, 3.8° after 30 s and 3.4° after 60 s, rising and falling below 5° as the robot turns. Even 3° leaks about 0.5 m/s² of gravity into the horizontal acceleration, and that integrated twice gives the hundreds of meters in the plot. Output from cell 6 The path plot shows the same thing in space. The bias-free estimate follows the circle for most of the lap and then drifts outward. The biased estimate leaves the circle within seconds; the dot marks where it is after 10 s. An IMU alone therefore keeps the pose for only a few seconds. It is still worth carrying: it samples hundreds of times a second and needs nothing from the environment, so it keeps working in the dark or in front of a blank wall. Navigation systems pair it with a sensor that measures the world, such as a camera, and estimate the biases online. The visual-inertial odometry section builds that filter. The TurtleBot3 IMU in the course simulator has white noise but no bias, so dead reckoning in Gazebo drifts like the blue curve above, far less than a real robot does. The simulated D435i IMU has both noise and a drifting bias. Key references: (Corke, 2023)

References

  • Corke, P. (2023). Robotics, vision and control: Fundamental algorithms in python.

Found an error on this page? Report an issue.