High-performance Rust driver for YDLidar sensors with support for multiple models.
- YDLidar T-mini Plus
- YDLidar X2/X2L
- YDLidar X4
- YDLidar G2/G4
- YDLidar S2/S4
- Scanning Range: 0.1 - 12m
- Scan Rate: 5Hz - 10Hz (adjustable)
- Ranging Frequency: 3000Hz
- Angle Resolution: 0.5° - 1.5°
- Measurement Resolution: 1mm
- Scan Angle: 360°
- Protocol: YDLidar Protocol v1.3
- Interface: UART
- Baud Rate: 230400 bps
- Data Bits: 8
- Stop Bits: 1
- Parity: None
- Flow Control: None
- USB Chip: CP2102 (Silicon Labs)
- VID: 0x10c4
- PID: 0xEA60
- Auto-detection: Supported
- Packet Size: 5 bytes per point
- Angle Encoding: 14-bit (0.0055° resolution)
- Distance Encoding: 16-bit (mm)
- Quality: 6-bit (0-63)
use ydlidar_rust_driver::{Lidar, TMiniPlus, LidarError};
fn main() -> Result<(), LidarError> {
// Auto-detect USB port
let mut lidar = Lidar::<TMiniPlus>::new()?;
// Start scanning
lidar.start_scan()?;
loop {
let points = lidar.get_scan_points()?;
for point in points {
println!("{}°: {}mm (Q:{})", point.angle, point.distance, point.quality);
}
}
}
use ydlidar_rust_driver::{Lidar, TMiniPlus, LidarError};
fn main() -> Result<(), LidarError> {
let mut lidar = Lidar::<TMiniPlus>::new()?;
lidar.start_scan()?;
loop {
let points = lidar.get_scan_points()?;
for point in points.iter().filter(|p| p.quality >= 40) {
let (x, y) = point.to_cartesian();
println!("Point: ({:.1}, {:.1}) mm", x, y);
}
}
}
This repository includes several example applications:
Real-time ASCII visualization of LiDAR data in your terminal:
cargo run --bin monitor_pcl
Device configuration and parameter:
cargo run --bin config
use ydlidar_rust_driver::{Lidar, TMiniPlus};
let mut lidar = Lidar::<TMiniPlus, UART>::new(uart);
lidar.start_scan()?;
loop {
lidar.read_scan_data()?;
let points = lidar.get_scan_points()?;
// Process points...
}