/ydlidar_ros_driver

ydlidar driver package under ros

Primary LanguageC++OtherNOASSERTION

YDLIDAR

YDLIDAR ROS Driver

ydlidar_ros_driver is a new ros package, which is designed to gradually become the standard driver package for ydlidar devices in the ros environment.

Compile & Install YDLidar SDK

ydlidar_ros_driver depends on YDLidar-SDK library. If you have never installed YDLidar-SDK library or it is out of date, you must first install YDLidar-SDK library. If you have installed the latest version of YDLidar-SDK, skip this step and go to the next step.

  1. Download or clone the YDLIDAR/YDLidar-SDK repository on GitHub.
  2. Compile and install the YDLidar-SDK under the build directory following README.md of YDLIDAR/YDLidar-SDK.

Clone ydlidar_ros_driver

  1. Clone ydlidar_ros_driver package for github :

    git clone https://github.com/YDLIDAR/ydlidar_ros_driver.git ydlidar_ws/src/ydlidar_ros_driver

  2. Build ydlidar_ros_driver package :

    cd ydlidar_ws
    catkin_make
    

    >Note: If the following error occurs, Please install YDLIDAR/YDLidar-SDK first.

    CMAKE ERROR

  3. Package environment setup :

    source ./devel/setup.sh

    Note: Add permanent workspace environment variables. It's convenientif the ROS environment variables are automatically added to your bash session every time a new shell is launched:

    $echo "source ~/ydlidar_ws/devel/setup.bash" >> ~/.bashrc
    $source ~/.bashrc
    
  4. Confirmation To confirm that your package path has been set, echo the ROS_PACKAGE_PATH variable.

    $ echo $ROS_PACKAGE_PATH
    

    You should see something similar to: /home/tony/ydlidar_ws/src:/opt/ros/melodic/share

  5. Create serial port Alias [optional]

    $chmod 0777 src/ydlidar_ros_driver/startup/*
    $sudo sh src/ydlidar_ros_driver/startup/initenv.sh
    

    Note: After completing the previous operation, replug the LiDAR again.

Run ydlidar_ros_driver

Run ydlidar_ros_driver using launch file

The command format is :

roslaunch ydlidar_ros_driver [launch file]

  1. Connect Triangle LiDAR uint(s).

    # G4, G5
    roslaunch ydlidar_ros_driver lidar_view.launch 
    
  2. Connect to TOF LiDAR uint(s).

    # TG15, TG30, TG50
    roslaunch ydlidar_ros_driver TG.launch 
    # TX8, TX20
    roslaunch ydlidar_ros_driver TX.launch 
    
  3. Connect to TOF NET LiDAR uint(s).

    # T5, T15
    roslaunch ydlidar_ros_driver T15.launch 
    
Launch file introduction

The driver offers users a wealth of options when using different launch file. The launch file directory

is "ydlidar_ws/src/ydlidar_ros_driver/launch". All launch files are listed as below :

launch file features
G1.launch Connect to G1 LiDAR
Publish LaserScan message on scan topic
G2.launch Connect to G2 LiDAR
Publish LaserScan message on scan topic
G6_G7.launch Connect to G6/G7 LiDAR
Publish LaserScan message on scan topic
lidar.launch Connect to G4/G5 LiDAR
Publish LaserScan message on scan topic
lidar_view.launch Connect to G4/G5 LiDAR
Publish LaserScan message on scan topic
Automatically load rviz
T15.launch Connect to T5/T15 LiDAR
Publish LaserScan message on scan topic
TG.launch Connect to TG15/TG30/TG50 LiDAR
Publish LaserScan message on scan topic
TX.launch Connect to TX8/TX20 LiDAR
Publish LaserScan message on scan topic
X2.launch Connect to X2/X2L LiDAR
Publish LaserScan message on scan topic
X4.launch Connect to X4 LiDAR
Publish LaserScan message on scan topic

Publish Topic

Topic Type Description
scan sensor_msgs/LaserScan 2D laser scan of the 0-angle ring
point_cloud sensor_msgs/PointCloud 2D point cloud of the 0-angle ring
laser_fan(removed in version 1.0.1) ydlidar_ros_driver::LaserFan 2D Raw laser fan of the 0-angle ring

Subscribe Service

Service Type Description
stop_scan std_srvs::Empty turn off lidar
start_scan std_srvs::Empty turn on lidar

Configure ydlidar_ros_driver internal parameter

The ydlidar_ros_driver internal parameters are in the launch file, they are listed as below :

Parameter name Data Type detail
port string Set Lidar the serial port or IP address
it can be set to /dev/ttyUSB0, 192.168.1.11, etc.
default: /dev/ydlidar
frame_id string Lidar TF coordinate system name.
default: laser_frame
ignore_array string LiDAR filtering angle area
eg: -90, -80, 30, 40
baudrate int Lidar baudrate or network port.
default: 230400
lidar_type int Set lidar type
0 -- TYPE_TOF
1 -- TYPE_TRIANGLE
2 -- TYPE_TOF_NET
default: 1
device_type int Set device type
0 -- YDLIDAR_TYPE_SERIAL
1 -- YDLIDAR_TYPE_TCP
2 -- YDLIDAR_TYPE_UDP
default: 0
sample_rate int Set Lidar Sample Rate.
default: 9
abnormal_check_count int Set the number of abnormal startup data attempts.
default: 4
fixed_resolution bool Fixed angluar resolution.
default: true
reversion bool Reversion LiDAR.
default: true
inverted bool Inverted LiDAR.
false -- ClockWise.
true -- CounterClockWise
default: true
auto_reconnect bool Automatically reconnect the LiDAR.
true -- hot plug.
default: true
isSingleChannel bool Whether LiDAR is a single-channel.
default: false
intensity bool Whether LiDAR has intensity.
true -- G2 LiDAR.
default: false
support_motor_dtr bool Whether the Lidar can be started and stopped by Serial DTR.
default: false
angle_min float Minimum Valid Angle.
default: -180
angle_max float Maximum Valid Angle.
default: 180
range_min float Minimum Valid range.
default: 0.1
range_max float Maximum Valid range.
default: 16.0
frequency float Set Scanning Frequency.
default: 10.0
invalid_range_is_inf bool Invalid Range is inf.
true -- inf.
false -- 0.0.
default: false
point_cloud_preservative bool Keep invalid range.
true -- Keep.
false -- Reject.
default: false
More paramters details, see here

Contact EAI

Development Path

If you have any extra questions, please feel free to contact us