(1)Switch your computer to the src directory of a ROS workspace and replace catkin_ws with your ROS workspace.
$cd ~/catkin_ws/src
(2)Clone the ydlidar project into the src directory under your ROS workspace.
$git clone https://github.com/EAIBOT/ydlidar $cd ..
(3)The compiler generates ydlidar_node and ydlidar_client.
$catkin_make --pkg ydlidar
Run YDLIDAR ROS driver package
(1)Create YDLIDAR Radar Serial Alias [/dev/ydlidar].
$roscd ydlidar/startup $sudo chmod 0777 * $sudo sh initenv.sh** Reboot OS **
(2) Open lidar.launch and change the baud rate for different models of lidar. The following is the configuration of X4.
$roscd ydlidar/launch $vim lidar.launch
There are two ways to run YDLIDAR ROS driver package:
(1) Run ydlidar_node and rviz
$roslaunch ydlidar lidar_view.launch
(2) Run ydlidar_node and ydlidar_client
$roslaunch ydlidar lidar.launch $rosrun ydlidar ydlidar_client ###data output on computer

