1. Preparation before use

1、Install SDK

Unzip the YDLidar-SDK-master.zip file in the folder,Get a file YDLidar-SDK-master,Copy this file to your own file directory,Here, taking the installation in the/home directory as an example, and then entering it one by one,

2.Compile ROS feature package

ROS1

Unzip the ydlidar_ros_ws.rar file in the folder,get a file ydlidar_ros_ws,Copy this feature package to the root directory of your own environment, then open the terminal in the workspace and enter the following command to compile,

ROS2

Extract the ydlidar_ros2_ws.rar file from the folder and obtain a file ydlidar_ros2_ws. Copy this feature package to the root directory of your own environment, then open the terminal in the workspace and enter the following command to compile,

3. Create a serial port alias

To prevent recognition errors when multiple USB devices are connected, we create a module serial port alias.

The ~/catkin_ws/src/ydlidar_ros_driver here is the location for installing the feature pack and needs to be modified according to the actual situation. Take care:

After completing the previous operation, please reinsert the module again

Enter the following command to check if the recognition was successfully created,

If the following screen appears, it indicates success,

Note: This may not necessarily be ttyUSB0, the assigned serial number based on system identification shall prevail.

4. Running programs

Terminal input,

ROS1,

The screenshot of successful operation is as follows,

image-20240411094934126

You can enter the following command to view specific data,

image-20240411095028398

The data in ranges is the actual measured distance, measured in meters.

ROS2

The following screenshot appears when running successfully,

image-20240410143207682

You can enter the following command to view specific data,

image-20240410143514105

The data in ranges is the actual measured distance, measured in meters.