Ultrasonic distance sensor
Also available in: Català · Castellano
Time of flight
d = c · t / 2: divided by 2 because the pulse goes there and back.
- Sound:
c ≈ 343 m/sat 20 °C. At 1 m, the echo takes 2 m / 343 ≈ 5.8 ms. - Light: at 1 m, 2 m / 3·10⁸ ≈ 6.7 ns.
That’s why an ultrasonic sensor costs a few euros and a lidar quite a lot more: it has to measure nanoseconds.
Temperature matters
c ≈ 331.3 + 0.606 · T (m/s, T in °C). If the sensor assumes 20 °C and it’s 0 °C, the distance is off by a few centimetres per metre.
In the demo
Change the temperature and watch the error. Compare with the lidar: sound in milliseconds, light in nanoseconds.
Interactive demo
Related concepts
Lidar and SLAM
Counting wheel turns accumulates error (drift). A lidar measures distances in many directions at once; SLAM builds the map and locates itself in it by aligning each scan, which corrects the drift.
Stereo depth
Two cameras set apart see the same object shifted; nearby things shift more. Depth comes from Z = f · B / d.