Distance sensors: how a robot feels what is in front of it
To avoid walls and obstacles, a robot needs to measure distance. Three common technologies each have strengths and weaknesses.
Infrared (IR)
An IR sensor shines infrared light and measures the reflection. Cheap, small, fast. Good for short to medium range. Weakness: dark or angled surfaces reflect poorly, so readings can drop out. Many small robots use several IR sensors around the chassis.
Ultrasonic
An ultrasonic sensor sends a sound pulse and times the echo. Cheap and works on most surfaces regardless of color. Weakness: a wide beam (it "sees" a cone, not a point) and trouble with angled or soft surfaces that scatter the sound.
Time-of-Flight (ToF)
A ToF sensor measures how long a laser pulse takes to bounce back. Narrow beam, fast, precise at short range. More expensive, but the most accurate for pointing at a specific spot.
Choosing
Ask three questions:
- Range: how far do you need to see?
- Beam: do you need a precise point (ToF) or a rough cone (ultrasonic)?
- Surface: will you face dark, angled or soft objects?
The pro move: combine and filter
Robots often use several distance sensors, and always average readings over time rather than trusting one. A single reading can be a glitch off a shiny edge. Mounting matters too: two sensors angled slightly inward can tell you not just that something is ahead, but roughly at what angle.