Setting Up and Running D500 LiDAR Kit's STL-19P on ROS 2 Jazzy
This guide walks you through setting up the D500 LiDAR Kit's STL-19P sensor for ROS 2 Jazzy, using the ldrobotSensorTeam/ldlidar_ros2 repository. By the end of this article, you'll be able to configure, launch, and visualize LIDAR data in ROS 2.
Prerequisites
Before proceeding, ensure you have the following set up:
-
ROS 2 Jazzy Installed: Follow the official instructions to install ROS 2 Jazzy.
-
Set Up Your ROS 2 Workspace: Create a workspace if you don't already have one:
mkdir -p ~/Desktop/frata_workspace/src cd ~/Desktop/frata_workspace colcon build source install/setup.bash
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 install any missing dependencies:cd ~/Desktop/frata_workspace rosdep install --from-paths src --ignore-src -r -y
-
Build the Workspace: Compile the package:
colcon build --symlink-install --cmake-args=-DCMAKE_BUILD_TYPE=Release
-
Source the Workspace: Add the following to your
~/.bashrc
and source it:echo "source ~/Desktop/frata_workspace/install/local_setup.bash" >> ~/.bashrc source ~/.bashrc
Running the LDLiDAR Node
- Connect the LIDAR to a USB Port:
-
Ensure the LIDAR is connected to your machine. If the device isn't detected, try using a USB extension cable.
-
Identify the Serial Port: Check for the device's serial port:
Example output:ls /dev/ttyUSB*
/dev/ttyUSB0
. -
Launch the Node: Start the LDLiDAR node with the appropriate launch file:
If required, modify theros2 launch ldlidar_ros2 ld19.launch.py
port_name
in theld19.launch.py
file to match your detected port (e.g.,/dev/ttyUSB0
). -
View LIDAR Data:
- Open Rviz2 to visualize the LIDAR data:
rviz2
- Add a "LaserScan" display and set the topic to
/scan
.
Troubleshooting Common Errors
1. "Communication Abnormal" Error
If you encounter this error:
[ERROR] [ldlidar_publisher_ld19]: ldlidar communication is abnormal.
-
Check Serial Port: Ensure the correct serial port (
/dev/ttyUSB0
) is specified in the launch file. -
Verify Baud Rate: Confirm that the baud rate in the launch file matches the LIDAR's configuration (default is
230400
). -
Reconnect the Device: Use a USB extension cable if the device isn't recognized properly.
2. Device Not Found
- Run:
ls /dev/ttyUSB*
- If no device appears, ensure the LIDAR is securely connected and powered.
3. No Data in Rviz2
- Verify the
/scan
topic is being published:ros2 topic list ros2 topic echo /scan
4. "Failed init_port fastrtps_port7000" Error
This is a common shared memory transport error in ROS 2.
- Solution: Add the following to your .bashrc
to disable shared memory transport:
export RMW_IMPLEMENTATION=rmw_cyclonedds_cpp
Example Launch Output
Once everything is set up correctly, you should see the following output:
[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
Conclusion
With this guide, you can successfully set up and run the D500 LiDAR Kit's STL-19P on ROS 2 Jazzy. If you encounter the "communication abnormal" or other errors, refer to the troubleshooting section to resolve them quickly. This setup enables seamless LIDAR integration for your autonomous robotics projects.
For more information, visit the ldrobotSensorTeam GitHub repository.