Preparation

1. Install SDK

Unzip YDLidar-SDK-master.tar.xz in the source code folder to get YDLidar-SDK-master.

Input following command:

2.Compilation Function Package

Unzip ydlidar in the source folder_ ROS2_ Driver master, obtain ydlidar_ ROS2_ Driver master feature pack.

Copy ydlidar_ ROS2_ Drive master to the src directory of your own workspace

Using the workspace ydlidar_ Ws is an example, rplidar_ Ws is located in the ~ directory.

Then, go back to the workspace directory and compile it,

image-20231113194725249

The above screen indicates that the compilation has passed.

Input following command to set the environment variable.

Input the following command to bind lidar port name

Then, re-plug the lidar wiring and enter the command ll /dev/rplidar in the terminal.

image-20231113194946385

The above content indicates that the binding is successful. The end is not necessarily 0 and changes according to the order in which the devices are inserted.

3. Run launch

Input following command:

View lidar data with rostopic tool.

image-20231113195409691

ctrl+ c closes the terminal that just drove the lidar.

Then enter the following statement in the terminal to drive the lidar, and open rviz to display the point cloud.

image-20231113195627143