What is LiDAR? The robot sensor that sees distance
Atlasbot · 18/8/2026 · 11 min read
A mobile robot (AMR) that wants to dodge walls, people, and self-map buildings first has to "see" the distance to everything around it. LiDAR (Light Detection and Ranging) is the most common sensor to do this — measuring distance by firing a laser beam and then calculating the time or angle of reflected light return.
Key concepts
Most low-cost LiDAR robots (YDLIDAR, RPLiDAR, etc.) measure distances using the principle. triangulation: a laser beam exposes the obstacle, the reflected light is captured by an image sensor that lies at an angle from the emitter — From this angle of deviation, we can calculate the distance using triangular geometry. Industrial LiDAR/self-driving cars commonly use the other principle of Time-of-Flight (ToF): direct measurement of the time of arrival and departure of light, giving a much longer scan range but a much higher price.
How it works
An internal motor LiDAR spins its transmit/receive head continuously through 360°, each spin producing hundreds of measurement points (e.g. ~500 points/ring at ~8Hz scan frequency) — sets of these points called point cloud (with LiDAR 2D called laser scan, a point plane).
Why AMR needs LiDARs instead of cameras alone: direct distance measurement in meters/centimeters — requires no computation of depth inference like single cameras; does not depend on ambient light — works well both in the dark; point cloud/laser scan data are available for ROS2's standard SLAM and Nav2 algorithms, without complex image processing.
Technical details
Formulas
The triangulation principle calculates the distance from the disparity of the reflected light spot on the receiver:
d = (b × f) / x
Where d = distance to the obstacle, b = distance (baseline) between
transmitter beam and receiver sensor, f = focal length of receiver lens, x = position deflection
bright spot on receiver compared to reference position
The further away the object → the smaller the x deviation → the measurement accuracy decreases with distance
(This is why low - cost triangulation LiDAR has a limited effective scan range,
usually a few metres to over a dozen metres, not as far as the industrial LiDAR ToF)
Parameters
2D LiDAR data in ROS2 output in standard sensor_msgs/LaserScan:
sensor_msgs/LaserScan
angle_min, angle_max # start/end scan angles (radians)
angle_increment # angle between 2 consecutive measurement points
ranges[] # measured distances (meters), indexed by angle
| Principle | Typical scan range | Cost | Used for |
|---|---|---|---|
| Triangulation | Several metres – over tens of metres | Low | Indoor AMR, DIY robot |
| Time-of-Flight (ToF) | Tens of – hundreds of meters | High | Self - driving cars, outdoor robots |
Practical applications
A sensor_msgs/LaserScan array is sufficient for slam_toolbox/Cartographer to build maps and Nav2 to dodge obstacles as soon as plugged in, without writing its own driver — this is why LiDAR is almost the default option for a start-up AMR, instead of having to write the sensor processing pipeline from scratch like many other sensors.
Practical example
import rclpy
from rclpy.node import Node
from sensor_msgs.msg import LaserScan
class ScanReader(Node):
def __init__(self):
super().__init__("scan_reader")
self.create_subscription(LaserScan, "/scan", self.callback, 10)
def callback(self, msg):
min_dist = min(r for r in msg.ranges if r > msg.range_min)
angle_of_min = msg.angle_min + msg.ranges.index(min_dist) * msg.angle_increment
print(f"Vật cản gần nhất: {min_dist:.2f}m tại góc {angle_of_min:.2f} rad")
Typical output:
Vật cản gần nhất: 0.85m tại góc -0.35 rad
The above code illustrates the most basic operation of working with LaserScan — to find the nearest obstacle and its direction, which is fundamental to both simple obstacle avoidance and more complex algorithms at the Nav2 level.
Common mistakes
- Triangulation and Time-of-Flight confusion when comparing— parameters are two principles with significantly different scanning range/precision characteristics, comparing the parameters of the 2 different non-principles easily leads to false expectations.
- Observing uniform accuracy at all distances— as calculated in the Formula section, the triangulation accuracy decreases with distance, the more distant the object is less accurate.
- Do not check
range_minwhen processing LaserScan data— as the above example, bypassing therange_minfilter which may mix zero or nonsense values into the computed results. - Coi LiDAR is "enough" to ignore its blind spot— LiDAR only sees the correct plane it scans (more discussed in Comparative LiDAR 2D and 3D), which needs to incorporate additional sensors for the blind area.
Conclusion
LiDAR is the nearly mandatory "distance eye" for an in-house self-propelled AMR — for direct, reliable, and pre-compatible data with ROS2's SLAM/Nav2 ecosystem. The triangulation principle common to low-cost LiDAR has a trade-off of accuracy that decreases with distance, unlike industrial ToF. The next article in this column compares 2D and 3D LiDARs to see when one is needed.
Get new articles and lessons by email
When a new technical article or course module is published, Atlas Robotics sends you a short email. No spam.
Unsubscribe any time with the link in each email. See our Privacy policy.