Skip to content

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:

  1. ROS 2 Jazzy Installed: Follow the official instructions to install ROS 2 Jazzy.

  2. 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

  1. Clone the Repository:

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

  2. Install Dependencies: Use rosdep to install any missing dependencies:

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

  3. Build the Workspace: Compile the package:

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

  4. 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

  1. Connect the LIDAR to a USB Port:
  2. Ensure the LIDAR is connected to your machine. If the device isn't detected, try using a USB extension cable.

  3. Identify the Serial Port: Check for the device's serial port:

    ls /dev/ttyUSB*
    
    Example output: /dev/ttyUSB0.

  4. Launch the Node: Start the LDLiDAR node with the appropriate launch file:

    ros2 launch ldlidar_ros2 ld19.launch.py
    
    If required, modify the port_name in the ld19.launch.py file to match your detected port (e.g., /dev/ttyUSB0).

  5. View LIDAR Data:

  6. Open Rviz2 to visualize the LIDAR data:
    rviz2
    
  7. 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.



Created 2025-01-23, Updated 2025-01-24
Authors: Harminder Singh Nijjar (5)

Comments