# Module 5.1: Robot Sensors and Noise Reality

- Course: [Course 5: Sensors, State Estimation & Localization (SLAM)](https://roboticsconcepts.dev/courses/sensors-state-estimation-slam.md)
- HTML Page: https://roboticsconcepts.dev/courses/sensors-state-estimation-slam/robot-sensors-and-noise-reality/
- Key Concepts: Proprioceptive vs. exteroceptive sensors, Bias, white noise & double-integration drift, Dead reckoning failure modes

If you close your eyes and try to walk a square around your living room — ten steps forward, turn ninety degrees, repeat — you'll almost never land back on the exact rug corner you started from. Even if you swear you turned cleanly and kept a steady stride, tiny missteps pile up. Robots hit that exact same wall the moment they try to navigate using only their internal sensors.

## Looking inward vs. looking outward

Robot sensors split cleanly into two camps. Proprioceptive sensors measure what is happening inside the robot's own body: wheel encoders count motor shaft rotations, and an Inertial Measurement Unit (IMU) measures linear acceleration and angular turning rate. They are fast, cheap, and work in pitch darkness or thick dust.

Exteroceptive sensors look outward at the world around the robot: 2D/3D LiDAR shoots laser pulses to time wall reflections, depth cameras estimate pixel distances, and downward-facing optical flow cameras track floor texture passing underneath. They anchor the robot to real landmarks instead of its own guesses.

## Why dead reckoning always drifts

Computing your position by adding up wheel clicks or integrating IMU rates over time is called dead reckoning. It works great for the first meter or two, and then reality shows up.

Suppose your left tire is slightly under-inflated — just 2% smaller in radius than your code assumes — or slips a bit on smooth concrete. Every wheel revolution pushes the robot slightly off its expected arc. Even worse, an IMU gyroscope almost always has a tiny constant bias (say, 0.5°/s when sitting perfectly still), and an accelerometer has to be integrated twice to get position: once to get velocity, and a second time to get distance. Any constant bias grows linearly in velocity and quadratically in position.

- Wheel encoders suffer from tire radius errors, uneven floors, and wheel slip during sharp turns.
- Gyroscope bias bends straight paths into wide, unintended curves over tens of seconds.
- Accelerometer double integration turns a tiny gravity-alignment error into meters of drift within seconds.

## Interactive Sandbox: Odometry & IMU Dead Reckoning Drift Simulator

Dial in a small wheel radius/slip error and a tiny IMU gyro bias in the simulator below. Watch the dashed estimated path peel away from the true closed loop — and notice how big the final loop-closure gap gets by the time the robot returns home.

## Reading the drift curve

Notice in the cumulative error plot that drift rarely stays flat. Early on, a small heading mistake barely shifts your X/Y coordinates. Once your estimated heading points 10° the wrong way, every forward meter you drive carries you sideways off the true track.

That is why real mobile robots never bet the farm on odometry alone. Proprioceptive sensors give smooth, high-rate updates between frames (often 100–1000 Hz), while exteroceptive sensors step in periodically to pull the drifting estimate back onto the real room.

## Why bias blows up during integration

```text
θ_err(t) = b_gyro · t   |   pos_err(t) ≈ ½ · b_accel · t²
```

A tiny constant gyro bias grows linearly in heading error over time, while an uncalibrated acceleration bias grows with the square of time.

## Check Your Intuition

**Question:** A delivery robot drives around a rectangular warehouse block and returns to its exact starting dock, yet its wheel-plus-IMU dead reckoning claims it is 2.4 meters away. What is the single biggest reason?

- [✓] Heading error from gyro bias or uneven wheel slip rotated every subsequent forward step in the wrong direction
- [ ] The LiDAR sensor slowed down the CPU clock
- [ ] Wheel encoders always drop half their ticks when driving straight

**Explanation:** Once heading drifts even a few degrees, every forward distance estimate gets projected along a tilted direction, compounding position error rapidly.

## Where You'll See This in Modern Robotics

In real deployments — from warehouse AMRs to legged humanoids — visual-inertial odometry (VIO) fuses high-rate IMU readings with camera feature tracking so the robot stays steady even when wheels slip or feet scuff.

## Companion Python Notebook: 01 · Wheel Odometry & IMU Dead-Reckoning Drift

Simulate wheel radius mismatch, white noise, and IMU gyro bias to see how fast dead reckoning drifts away from ground truth.

- Open in molab (WASM): https://molab.marimo.io/github/alchemicduncan/robotics-concepts-dev/blob/main/notebooks/course-5/01_robot_sensors_noise_drift.py/wasm
- Open in Google Colab: https://colab.research.google.com/github/alchemicduncan/robotics-concepts-dev/blob/main/notebooks/colab/course-5/01_robot_sensors_noise_drift.ipynb
- Download .py: https://roboticsconcepts.dev/downloads/notebooks/course-5/01_robot_sensors_noise_drift.py
- Download .ipynb: https://roboticsconcepts.dev/downloads/notebooks/colab/course-5/01_robot_sensors_noise_drift.ipynb
- Run locally: `uvx marimo edit --sandbox notebooks/course-5/01_robot_sensors_noise_drift.py`
