2D LiDAR
| Range Frequency 5000Hz | Scan Frequency 6-12Hz | ||
|---|---|---|---|
| Range Distance 0.12-10m | Scan Angle 360° | ||
| Angle Resolution 0.43-0.85° | Size 110.671.152.3mm |
SDK
https://github.com/YDLIDAR/YDLidar-SDK/tree/master You can install these packages using apt:
sudo apt install cmake pkg-config
In the YDLidar SDK directory, run the following commands to compile the project:
git clone https://github.com/YDLIDAR/YDLidar-SDK.git
cd YDLidar-SDK
mkdir build
cd build
cmake ..
make
sudo make install
ROS2 Driver
https://github.com/YDLIDAR/ydlidar_ros2_driver
| launch file | features |
|---|---|
| ydlidar.py | Connect to defualt paramters Publish LaserScan message on scan topic |
| ydlidar_launch.py | Connect ydlidar.yaml Lidar specified by configuration parameters Publish LaserScan message on scan topic |
| ydlidar_launch_view.py | Connect ydlidar.yaml Lidar specified by configuration parameters and setup RVIZ Publish LaserScan message on scan topic |
-
Clone ydlidar_ros2_driver master branch from github for old version:
git clone https://github.com/YDLIDAR/ydlidar_ros2_driver.git ydlidar_ros2_ws/src/ydlidar_ros2_driverClone ydlidar_ros2_driver humble branch from github for humble,jazzy,etc:
git clone -b humble https://github.com/YDLIDAR/ydlidar_ros2_driver.git ydlidar_ros2_ws/src/ydlidar_ros2_driver -
Build ydlidar_ros2_driver package :
cd ydlidar_ros2_ws colcon build --symlink-installNote: install colcon see
Note: If the following error occurs, Please install YDLIDAR/YDLidar-SDK first.
-
Package environment setup :
source ./install/setup.bashNote: Add permanent workspace environment variables. It’s convenientif the ROS2 environment variables are automatically added to your bash session every time a new shell is launched:
echo "source ~/ydlidar_ros2_ws/install/setup.bash" >> ~/.bashrc source ~/.bashrc -
Confirmation To confirm that your package path has been set, printenv the
grep -i ROSvariable.printenv | grep -i ROSYou should see something similar to:
OLDPWD=/home/tony/ydlidar_ros2_ws/install -
Create serial port Alias [optional]
chmod 0777 src/ydlidar_ros2_driver/startup/* sudo sh src/ydlidar_ros2_driver/startup/initenv.shNote: After completing the previous operation, replug the LiDAR again.
Configure LiDAR Default parameter file
ydlidar_ros2_driver_node:
ros__parameters:
port: /dev/ttyUSB0
frame_id: laser_frame
ignore_array: ""
baudrate: 230400
lidar_type: 1
device_type: 0
isSingleChannel: false
intensity: false
intensity_bit: 0
sample_rate: 9
abnormal_check_count: 4
fixed_resolution: true
reversion: false
inverted: false
auto_reconnect: true
support_motor_dtr: false
angle_max: 180.0
angle_min: -180.0
range_max: 64.0
range_min: 0.01
frequency: 10.0
invalid_range_is_inf: false
debug: false
Note: It needs to be modified according to LiDAR actual situation.
Run ydlidar_ros2_driver
Run ydlidar_ros2_driver using launch file
The command format is :
ros2 launch ydlidar_ros2_driver [launch file].py
-
Connect LiDAR uint(s).
ros2 launch ydlidar_ros2_driver ydlidar_launch.pyor
launch $(ros2 pkg prefix ydlidar_ros2_driver)/share/ydlidar_ros2_driver/launch/ydlidar.py -
RVIZ
ros2 launch ydlidar_ros2_driver ydlidar_launch_view.py

