Fusion of Engineering, Control, Coding, Machine Learning, and Science

How to Install and Run Lidar (Slamtec lidars) in ROS2 Jazzy on Raspberry Pi

In this tutorial, we explain how to install, run, and use a lidar (Slamtec lidar) on Raspberry Pi, ROS2, and Linux Ubuntu. We explain how to clone the ROS2 package for running the lidar and how to build it. Then, we explain how to run the lidar in Raspberry Pi.

Install and Run Lidar In ROS2, Ubuntu, and Raspberry Pi - Complete Tutorial

Prerequisites and Important Notes

Installation Instructions

Open a terminal, source the ROS2 environment, and create a workspace directory:

source /opt/ros/jazzy/setup.bash
cd ~
mkdir -p ~/ws_lidar/src
cd ~/ws_lidar/src

Then, clone the remote repository:

git clone https://github.com/Slamtec/sllidar_ros2.git

Then, build the ROS2 package:

cd ~/ws_lidar/
colcon build --symlink-install

You will see some compilation warnings. You can ignore these compilation errors. Then, you need to source the created package:

source ~/ws_lidar/install/setup.bash

Then, attach your lidar to the Raspberry Pi. The next step is to assign the proper permission to the USB port to which the lidar is connected. Type this:

ls -la /dev | grep USB

The output should look something like this

crw-rw----   1 root   dialout 188,   0 Sep 29 22:33 ttyUSB0

This means that the name of our device is “ttyUSB0”. In your case, you might see some other name and number, and you need to use that name. To set the permissions, we need to execute this:

sudo chmod 777 /dev/ttyUSB0

This will allow everyone to read, write, and execute this file. This is all we need.

Finally, we can run our lidar. To run our RPLIDAR A1 lidar, we need to execute this:

ros2 launch sllidar_ros2 view_sllidar_a1_launch.py

Rviz will open, and you will see the screen shown below showing the measurements performed by the Lidar:

On the other hand, if you want to run some other Slamtec lidars, you need to execute the launch files in this folder:

~/ws_lidar/src/sllidar_ros2/launch

You can list all the files by typing this:

ls -la ~/ws_lidar/src/sllidar_ros2/launch

You just need to select the launch Python file.

For example,

To run RPLIDAR A2M7:

ros2 launch sllidar_ros2 view_sllidar_a2m7_launch.py

To run RPLIDAR A2M8

ros2 launch sllidar_ros2 view_sllidar_a2m8_launch.py

To run RPLIDAR A2M12 :

ros2 launch sllidar_ros2 view_sllidar_a2m12_launch.py

To run RPLIDAR A3:

ros2 launch sllidar_ros2 view_sllidar_a3_launch.py

To run RPLIDAR C1 :

ros2 launch sllidar_ros2 view_sllidar_c1_launch.py

To run RPLIDAR S1:

ros2 launch sllidar_ros2 view_sllidar_s1_launch.py

To run RPLIDAR S2:

ros2 launch sllidar_ros2 view_sllidar_s2_launch.py
ros2 launch sllidar_ros2 view_sllidar_s2e_launch.py

To run RPLIDAR S3:

ros2 launch sllidar_ros2 view_sllidar_s3_launch.py

To run RPLIDAR T1 :

ros2 launch sllidar_ros2 view_sllidar_t1_launch.py

To run RPLIDAR S1(TCP connection):

ros2 launch sllidar_ros2 view_sllidar_s1_tcp_launch.py
Exit mobile version