YDLidarX2_Driver
Driver for the YDLIDAR X2 low-cost 2-D LiDAR connected by USB serial; outputs one full scan per revolution.
Processing
- Connects at 115200 baud to DeviceName and decodes the scan packets with the YDLIDAR driver code (MIT License).
- Inverted is passed to the YDLIDAR driver. The X2 measures its angle clockwise; Inverted = true (default) turns it into a counter-clockwise positive angle, which follows the coordinate convention of this toolkit (ROS REP-103: X forward, Y left, angle 0 on +X). Only the angle of each point is changed (2π − θ); the points stay in the measurement (time) order, so the angle decreases along the array. Set it to false only when the raw clockwise angle is needed.
- StartAtZeroAngle rotates the array so that it starts at the point closest to angle 0. The points keep the measurement (time) order and are not sorted by value; use a sorting component for that. FixedOutputSize keeps the same number of points per revolution.
Usage
- Typical outputs:
angle_num→DataViewer.input_0;angle→DataViewer.input_1;distance_in_m→laser_scan_to_xyz_points.dist_points.
Data format
- angle (rad or deg, in [-pi, pi)), distance_in_m (Float64) and distance_in_mm (Integer32) have angle_num elements (at most 2048).
- Points out of the measuring range (below 0.05 m or above 64 m) are kept with distance 0. All outputs carry the time at which the scan was received.
Notes
- Tested with X2; other YDLIDAR variants may work at your own risk.
- Version 1.01: AngleSort was renamed StartAtZeroAngle, and Inverted was added with the default true. Version 1.0 output the clockwise angle; set Inverted = false to match data recorded with it.
References
- [1] EAI (YDLIDAR), YDLidar-SDK (bundled in 3rdparty/YDLidar-SDK). https://github.com/YDLIDAR/YDLidar-SDK — Used for: sensor connection and scan acquisition (CYdLidar).
Properties
| Name | Default | Description |
|---|---|---|
DeviceName | COM1 | Serial device of the LiDAR (COMx on Windows, /dev/tty* on Linux). |
FixedOutputSize | false | If true, every revolution is output with the same number of points. |
StartAtZeroAngle | false | If true, the output starts at the point closest to angle 0 (cyclic shift, measurement order kept); otherwise the driver order is kept. |
AngleUnit | radian | Unit of the angle output. Options: radian, degree. |
Inverted | true | Passed to the YDLIDAR driver. true (default): counter-clockwise positive angle (ROS REP-103), because the X2 measures clockwise. false: raw clockwise angle of the X2. Either way the points keep the measurement (time) order. |
Outputs
| Name | Description |
|---|---|
angle_num | Number of points in the current revolution. Type: Integer32 |
angle | Angle of each point, in the unit selected by AngleUnit. Counter-clockwise positive when Inverted is true (default). Type: Float64 |
distance_in_m | Distance of each point in meter. Type: Float64 |
distance_in_mm | Distance of each point in millimeter. Type: Integer32 |
RTMaps Toolkits Documentation