English| 简体中文
YDLIDAR ROS2 driver sends LiDAR data in ROS2 standard message format.
For a comprehensive list of product models, please refer to YDLIDAR official website. Here we use YDLIDAR X3 as an example for demonstration.
| Item Options | List |
|---|---|
| RDK X3 | Purchase Link |
| YDLIDAR X3 | Purchase Link |
-
Horizon RDK has been pre-installed with the provided Ubuntu 20.04 system image.
-
YDLIDAR is properly connected to RDK X3.
Connect to RDK X3 via terminal or VNC, and execute the following commands:
tros foxy:
sudo apt update
sudo apt install -y tros-ydlidar-ros2-drivertros humble:
sudo apt update
sudo apt install -y tros-humble-ydlidar-ros2-driverNote: If YDLIDAR is connected to RDK X3 during the installation, it needs to be reconnected after installation
tros foxy:
source /opt/tros/setup.bash
ros2 launch ydlidar_ros2_driver ydlidar_launch.pytros humble:
source /opt/tros/humble/setup.bash
ros2 launch ydlidar_ros2_driver ydlidar_launch.pyOpen a new terminal and input the following command to view LiDAR output data:
tros foxy:
source /opt/tros/setup.bash
ros2 topic echo /scantros humble:
source /opt/tros/humble/setup.bash
ros2 topic echo /scanInstall ROS2 on a PC or environment supporting RVIZ. Here is an example using the foxy version, run the following commands:
tros foxy:
source /opt/ros/foxy/setup.bash
ros2 run rviz2 rviz2tros humble:
source /opt/ros/humble/setup.bash
ros2 run rviz2 rviz2Add LaserScan and configure the Reliability Policy as System Default.
Set the Fixed Frame as base_link or laser_link to see the data collected by the LiDAR.
| Topic | Type | Description |
|---|---|---|
scan |
sensor_msgs/LaserScan | Two-dimensional LaserScan data |
| Service | Type | Description |
|---|---|---|
stop_scan |
std_srvs::Empty | Stop the LiDAR |
start_scan |
std_srvs::Empty | Start the LiDAR |
| Parameter name | Data Type | detail |
|---|---|---|
| port | string | Set the port of the LiDAR device Example: /dev/ttyUSB0 for serial port, 192.168.1.11 for ethernet port, default value: /dev/ydlidar |
| frame_id | string | Frame name, default value: laser_frame |
| ignore_array | string | Filter measurement points eg: -90, -80, 30, 40 |
| baudrate | int | Serial port baudrate Default value: 230400 |
| lidar_type | int | LiDAR model 0 -- TYPE_TOF 1 -- TYPE_TRIANGLE 2 -- TYPE_TOF_NET Default value: 1 |
| device_type | int | Device communication type 0 -- YDLIDAR_TYPE_SERIAL 1 -- YDLIDAR_TYPE_TCP 2 -- YDLIDAR_TYPE_UDP Default value: 0 |
| sample_rate | int | Sampling frequency. Default value: 9 |
| abnormal_check_count | int | Retry count when startup fails. Default value: 4 |
| fixed_resolution | bool | Enable correction of angular resolution. Default value: true |
| reversion | bool | Change scan direction. Default value: true |
| inverted | bool | Change scan direction, clockwise or counterclockwise. false -- Clockwise. true -- CounterClockwise Default value: true |
| isSingleChannel | bool | Whether it is a single channel. Default value: false |
| intensity | bool | Whether the LiDAR outputs measurement intensity. true -- G2 LiDAR. Default value: false |
| support_motor_dtr | bool | Whether the LiDAR can be started and stopped via serial DTR. Default value: false |
| angle_min | float | Minimum measurement angle. Default value: -180 |
| angle_max | float | Maximum measurement angle. Default value: 180 |
| range_min | float | Minimum measurement range. Default value: 0.1 |
| range_max | float | Maximum measurement range. Default value: 16.0 |
| frequency | float | Scanning frequency. Default value: 10.0 |
| invalid_range_is_inf | bool | Invalid Range is inf. true -- inf. false -- 0.0. Default value: false |


