Working Principle
The RPLIDAR A1/A2 from SLAMTEC is a 2D laser triangulation scanner that spins a laser rangefinder module at high speed to sweep 360° and produce a point cloud of distances. A laser diode emits a narrow beam; the reflected light hits a position-sensitive detector (PSD) at an offset angle. The distance is calculated from the reflected spot’s position via triangulation geometry.
By rotating this optical assembly continuously (5–10 Hz for A1, up to 15 Hz for A2), the sensor produces thousands of distance points per second, building a complete 2D map of the surrounding environment.
Electrical Characteristics
| Parameter | RPLIDAR A1 | RPLIDAR A2 |
|---|---|---|
| Range | 0.15–12 m | 0.2–18 m |
| Sample Rate | 8,000 pts/sec | 16,000 pts/sec |
| Angular Resolution | ~1° | ~0.45° |
| Scan Rate | 1–10 Hz | 5–15 Hz |
| Interface | UART (115200 baud) | UART (256000 baud) |
| Supply Voltage | 5 V (motor + core) | 5 V |
| Current Draw | ~500 mA | ~700 mA |
| Laser Class | Class 1 (eye-safe) | Class 1 |
Interfacing with an MCU
Connect RPLIDAR via its UART adapter (included) to a Raspberry Pi or MCU serial port. The motor control pin (MOTOCTL) is a PWM pin controlling spin speed. The protocol is binary packets containing angle, distance, and quality data.
Calibration
- Motor speed: Adjust PWM duty cycle for desired scan rate; faster = lower angular resolution per sample
- Health check: Use the health request command at startup to verify sensor status
- Quality filtering: Each measurement includes a quality flag (0–15); discard points with quality < 10 for cleaner maps
Code Example
# RPLIDAR A1 example — Raspberry Pi + Python
# Install: pip install rplidar-roboticia
from rplidar import RPLidar
lidar = RPLidar('/dev/ttyUSB0') # UART adapter
info = lidar.get_info()
print("RPLIDAR Info:", info)
health = lidar.get_health()
print("Health:", health)
# Collect 5 full 360° scans
for i, scan in enumerate(lidar.iter_scans(max_buf_meas=500)):
print(f"Scan {i}: {len(scan)} points")
# Each point: (quality, angle_deg, distance_mm)
for quality, angle, distance in scan[:5]:
print(f" {angle:.1f}° → {distance:.0f} mm (q={quality})")
if i >= 4:
break
lidar.stop()
lidar.stop_motor()
lidar.disconnect()
Real-World Applications
Robot Navigation, SLAM & Autonomous Vehicles
RPLIDAR is the de facto standard lidar for hobbyist and educational robots running ROS navigation stacks. Roomba-style vacuum robots, warehouse AGVs, drone obstacle avoidance, and indoor mapping projects all use 2D lidar for SLAM (Simultaneous Localization and Mapping). The point cloud enables obstacle detection, path planning, and real-time map building.
Limitations
- 2D only: Scans a single horizontal plane; cannot detect obstacles above or below the scan plane.
- Outdoor performance: Sunlight IR noise reduces effective range significantly outdoors.
- Mechanical wear: Spinning motor has finite lifetime (~10,000+ hours).
- Power hungry: 500–700 mA is significant for battery-powered robots.
- Transparent/reflective surfaces: Glass, mirrors, and very dark surfaces can cause missed or phantom points.