Note: This section supports the following lidar models: A1/A2/A3/S1/S2; The baud rates are different between A1/A2<115200>, A3/S1<256000> and S2<1000000>
SLAM Lidar ROS21、Remap the USB serial port2、Terminal test3、rviz2 Visual test4、gmapping Build diagram test
ROS 2 official website:https://docs.ros.org/
Lidar ROS2:https://www.slamtec.com/cn/Support#rplidar-a-series
Lidar official website:http://www.slamtec.com/cn/Support
Device : PC;A1M8
Environment :Ubuntu18.04;ROS2(eloquent)
New Workspace
mkdir -p my_ws/src
When the lidar is used, it is necessary to enter the workspace each time the command is executed
xxxxxxxxxx
cd ~/my_ws
Decompress the [silanlidar_ros2.zip] function package and put it in the src folder of your workspace. Open the terminal in the workspace
xxxxxxxxxx
colcon build # compile
source install/setup.bash # Update the environment
Note: Every time a new terminal is opened, it needs to [update the environment]. Every time the code in the function pack is changed, it needs to [re-compile] and then update the environment.
To perform this step, run the installation USB port remapping command in the scripts folder of the sllidar_ros2 function package
xxxxxxxxxx
cd ~/my_ws/src/sllidar_ros2/scripts
sudo chmod 777 *
./create_udev_rules.sh
Use the following command to view the modified remapping
xxxxxxxxxx
ls -l /dev | grep ttyUSB
Step one, activate the corresponding lidar
xxxxxxxxxx
ros2 launch sllidar_ros2 sllidar_launch.py # RPLIDAR A1/A2
ros2 launch sllidar_ros2 sllidar_a3_launch.py # RPLIDAR A3
ros2 launch sllidar_ros2 sllidar_s1_launch.py # RPLIDAR S1
ros2 launch sllidar_ros2 sllidar_s2_launch.py # RPLIDAR S2
Second, start the test application
xxxxxxxxxx
rosrun rplidar_ros rplidarNodeClient
You should see the rPLidar scan results in the console
xxxxxxxxxx
ros2 launch sllidar_ros2 view_sllidar_launch.py # RPLIDAR A1/A2
ros2 launch sllidar_ros2 view_sllidar_a3_launch.py # RPLIDAR A3
ros2 launch sllidar_ros2 view_sllidar_s1_launch.py # RPLIDAR S1
ros2 launch sllidar_ros2 view_sllidar_s2_launch.py # RPLIDAR S2
You should see the lidar scan results in rviz2
Note: the [Fixed Frame] coordinate system and [LaserScan] topics should be consistent with those published.
Step one, activate the corresponding lidar
xxxxxxxxxx
ros2 launch sllidar_ros2 sllidar_launch.py # RPLIDAR A1/A2
ros2 launch sllidar_ros2 sllidar_a3_launch.py # RPLIDAR A3
ros2 launch sllidar_ros2 sllidar_s1_launch.py # RPLIDAR S1
ros2 launch sllidar_ros2 sllidar_s2_launch.py # RPLIDAR S2
Second, start gmapping
xxxxxxxxxx
ros2 launch sllidar_ros2 gmapping_launch.py # Other
ros2 launch sllidar_ros2 gmapping_s2_launch.py # S2
You should see the result in rviz2
Note: [Fixed Frame] coordinate system, [LaserScan] topic, [map] topic should be the same as published.