Skip to content

Setting Up and Running the D500 LiDAR Kit’s STL-19P on ROS 2 Jazzy

The D500 LiDAR Kit’s STL-19P offers affordable and reliable 2D scanning capabilities for autonomous robots. This guide explains how to configure, launch, and visualize LiDAR data on ROS 2 Jazzy using the official ldlidar_ros2 package from LD Robot Sensor Team.

By the end, you’ll have a fully functional LiDAR node publishing real-time /scan data viewable in Rviz2.


🧠 Prerequisites

Before starting, make sure you have:

  • ROS 2 Jazzy installed and configured.
  • A working ROS 2 workspace, ideally located on your Desktop for convenience.

🧱 Set Up Your ROS 2 Workspace

mkdir -p ~/Desktop/frata_workspace/src
cd ~/Desktop/frata_workspace
colcon build
source install/setup.bash

This creates and initializes your frata_workspace, the home for your LiDAR package.


1️⃣ Cloning and Building the LDLiDAR Package

Clone the Repository

cd ~/Desktop/frata_workspace/src
git clone https://github.com/ldrobotSensorTeam/ldlidar_ros2.git

Install Dependencies

Use rosdep to automatically install any missing packages:

cd ~/Desktop/frata_workspace
rosdep install --from-paths src --ignore-src -r -y

Build the Workspace

colcon build --symlink-install --cmake-args=-DCMAKE_BUILD_TYPE=Release

Source the Workspace

To make the environment persistent:

echo "source ~/Desktop/frata_workspace/install/local_setup.bash" >> ~/.bashrc
source ~/.bashrc

This ensures ROS 2 recognizes your newly built LiDAR package every time you open a terminal.


2️⃣ Running the LDLiDAR Node

Connect the LiDAR

Plug the STL-19P sensor into a USB port. If it isn’t recognized, try a different cable or a powered USB hub.

Identify the Serial Port

Run:

ls /dev/ttyUSB*

Example Output:

/dev/ttyUSB0

Take note of this port — you’ll use it in the launch configuration.

Launch the Node

ros2 launch ldlidar_ros2 ld19.launch.py

If necessary, edit the file to set the correct port:

port_name = '/dev/ttyUSB0'

3️⃣ Visualizing LiDAR Data in Rviz2

Once the node is running, open Rviz2:

rviz2
  • Click “Add” → “By Topic”
  • Select /scan and choose LaserScan as the display type

You should now see a real-time 360-degree laser sweep representing detected surroundings.


4️⃣ Troubleshooting Common Errors

❌ 1. “Communication Abnormal” Error

Example log:

[ERROR] [ldlidar_publisher_ld19]: ldlidar communication is abnormal.

Fixes:

  • Verify the correct serial port in ld19.launch.py (e.g., /dev/ttyUSB0).
  • Confirm baud rate = 230400.
  • Reconnect the device or use a USB extension cable if the port is unstable.

⚠️ 2. Device Not Found

If ls /dev/ttyUSB* returns nothing:

  • Make sure the LiDAR is properly powered and connected.
  • Try a different USB port or check dmesg | grep tty for detection logs.

🚫 3. No Data in Rviz2

Check whether ROS 2 is actually publishing the /scan topic:

ros2 topic list
ros2 topic echo /scan

If no data appears, restart the LiDAR node or re-check serial communication settings.


🧩 4. “Failed init_port fastrtps_port7000” Error

This is a shared memory transport issue sometimes seen in ROS 2.

Solution: Disable shared memory by adding this line to your ~/.bashrc:

export RMW_IMPLEMENTATION=rmw_cyclonedds_cpp

Then re-source it:

source ~/.bashrc

✅ Example Successful Launch Output

When everything is configured correctly, your terminal should display:

[INFO] [ldlidar_publisher_ld19]: LDLiDAR SDK Pack Version is:3.3.1
[INFO] [ldlidar_publisher_ld19]: ROS2 param input:
[INFO] [ldlidar_publisher_ld19]: ldlidar serial connect is success
[INFO] [ldlidar_publisher_ld19]: ldlidar communication is normal.
[INFO] [ldlidar_publisher_ld19]: ldlidar driver start is success.
[INFO] [ldlidar_publisher_ld19]: start normal, pub lidar data

This indicates that your LiDAR is communicating properly, and the /scan topic is being published.


🧭 Conclusion

With this setup, you can confidently run the D500 LiDAR Kit’s STL-19P on ROS 2 Jazzy, visualize live sensor data, and debug connectivity issues.

If errors occur, review your serial port, baud rate, and environment variables. Once stable, this LiDAR becomes a reliable perception tool for autonomous navigation, mapping, and obstacle detection.

For continuous updates and additional models, visit the LD Robot Sensor Team GitHub repository.

Empower your robot with vision. 🚀

Comments