Welcome to YDLIDAR TW3 repository
1.Lidar drive
1. Environment Setup
Before starting the environment Settings, it is necessary to install the CP210X serial port driver first. For the installation tutorial, please refer to the PC software usage tutorial. If you use the virtual machine we provide, after installing the driver and connecting the radar to the computer, you can directly execute the fourth step of driving the radar without setting up the environment.
1. Installing the SDK Driver
Based on the specifications of the radar you purchased, locate the compressed file labeled "YDLidar-SDK" in the provided source code package. Extract the YDLidar-SDK folder; this folder contains the SDK files for this radar. Since using the ROS package for this radar requires the SDK to be installed beforehand, the YDLidar-SDK folder contains the radar's driver files. Open a terminal in this folder and type:
mkdir buildcd buildcmake ..make -j4sudo make installIf no errors are reported during the process, it means that the driver has been successfully installed.
2. Creating a New Workspace and Compiling the Package
(Recommended) The first method involves extracting ydlidar_ros2_ws.zip from the source code to your root directory, and then directly using colcon build to compile.
xxxxxxxxxxcd ydlidar_ros2_wscolcon build
After successful compilation, add the workspace path to your .bashrc file.
xxxxxxxxxxsudo gedit ~/.bashrc
Copy the following content to the end of the file:
xxxxxxxxxxsource ~/ydlidar_ros2_ws/devel/setup.bash --extend
The second method involves creating a self-named workspace. For example, let's say the name is ydlidar_ros2_ws. Enter the following in the terminal:
xxxxxxxxxxmkdir ydlidar_ros2_wscd ydlidar_ros2_wsmkdir srccd src
Then copy the package files from the unzipped source code directory ydlidar_ros2_ws/src to the ydlidar_ros2_ws/src directory. Then, in the ydlidar_ros2_ws directory, use colcon build to compile.
xxxxxxxxxxcd ydlidar_ros2_wscolcon build
After successful compilation, add the workspace path to your .bashrc file.
xxxxxxxxxxsudo gedit ~/.bashrc
Copy the following content to the end of the file:
xxxxxxxxxxsource ~/ydlidar_ros2_ws/devel/setup.bash --extend
3. Bind the radar port name
Open a terminal in the ydlidar_ros2_ws workspace and enter the following command:
xxxxxxxxxxcd ~/ydlidar_ros2_ws/src/ydlidar_ros2_driver/startup/sudo sh initenv.sh
Then reconnect the radar serial port and enter ll /dev/ydlidar in the terminal.
xxxxxxxxxxll /dev/ydlidar

4. Driving the Radar
Save and exit, then open a new terminal. Enter the following command to activate the radar and display it in rviz. Terminal warnings can be ignored.
xxxxxxxxxxros2 launch ydlidar_ros2_driver ydlidar_launch_view.py
The radar node data can be viewed through the following command.
xxxxxxxxxxros2 topic echo /scan