The sensor stack for mobile robots
Most indoor mobile robots need four sensing capabilities: ranging (how far is that wall?), mapping (what does the room look like?), localization (where am I in that map?), and ego-motion (how fast am I moving, which direction?). Different sensors answer different questions.
LIDAR vs ultrasonic
| LIDAR (RPLIDAR A1) | Ultrasonic (HC-SR04) | |
|---|---|---|
| Range | 0.15–5.5m | 0.02–4m |
| Coverage | 360° 2D scan | Single cone ~15° |
| Resolution | 1° angular, 2000 samp/s | Single point, ~50ms cycle |
| Maps rooms? | Yes (SLAM) | No — point detection only |
| Cost | ~$99 | ~$3.50 |
| Best for | Full room mapping, nav2 | Simple obstacle avoidance, MCU tier |
| Interface | USB (serial) | GPIO (2 pins per sensor) |
| ROS2 support | rplidar_ros2 (active) | Manual GPIO node needed |
Ultrasonic for proof-of-concept at $83. LIDAR when you need a map and nav2 integration.
Depth cameras: what “stereo” actually means
Stereo depth cameras (OAK-D Lite, RealSense D435) use two cameras with known separation (baseline) to triangulate depth from disparity — how much offset exists between the same point in left and right frames. Wider baseline = better depth at long range. Smaller baseline = better accuracy up close.
OAK-D Lite baseline: 75mm. Good for 0.3–8m range — ideal for indoor mobile robots. RealSense D435 baseline: 50mm (D435), 95mm (D455). D455 is better for large spaces; D435 is better near 0.3m.
Passive stereo fails on featureless surfaces (white walls, glass, mirrors). Both OAK-D Lite and D435 can lose depth on plain walls. Active stereo (RealSense with IR projector) handles this better. OAK-D Lite handles it at medium range (>0.5m) — close-range plain walls are a weakness.
IMU: the sensor everyone underestimates
IMU (Inertial Measurement Unit) gives acceleration + angular rate. Fuse it with wheel odometry and you get much better dead-reckoning. The MPU-6050 (RP2350 kit) gives 6DOF (gyro + accel). The MPU-9250 (Mobile-Light kit) gives 9DOF (adds magnetometer for heading).
- Gyro drift: all gyros drift over time. Fusion algorithms (Madgwick, Mahony) compensate but don't eliminate drift.
- Vibration sensitivity: motor PWM can corrupt IMU readings. Mount on dampened standoffs, sample at 100Hz.
- I2C address conflicts: MPU-6050 is 0x68/0x69. SSD1306 is 0x3C/0x3D. Scan the bus before assuming addresses.
- Calibration required: gyro bias, accelerometer scale. Do this on every power-up if precision matters.