Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure constant beam count for ROS2 SLAM Toolkit and Nav2 to work #3

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

slgrobotics
Copy link

I am using LD14 device with the following launch description:

    ldlidar_node = Node(
        package='ldlidar_sl_ros2',
        executable='ldlidar_sl_ros2_node',
        name='ldlidar_publisher_ld14',
        output='screen',
        respawn=True,
        respawn_delay=10,
        parameters=[
          {'product_name': 'LDLiDAR_LD14'},
          {'laser_scan_topic_name': 'scan'},
          {'point_cloud_2d_topic_name': 'pointcloud2d'},
          {'frame_id': 'laser_frame'},
          {'port_name': '/dev/ttyUSBLDR'},
          {'serial_baudrate' : 115200},
          {'laser_scan_dir': True},
          {'enable_angle_crop_func': False},
          {'angle_crop_min': 135.0},
          {'angle_crop_max': 225.0}
        ]
    )

The "demo.cpp" code passes each LIDAR head rotation "beams vector" as it comes from the driver, with the beam count dependent on the head rotation speed. In my case, the beam count varies in the range 388...393, so that the "/scan" topic is also containing variable point count. ROS2 Jazzy SLAM Toolbox treats this as error - it expects all incoming messages to contain the same amount of points.

To fix that, I added code to measure an average of 20 first valid scans (first scan is skipped as it always comes truncated), and to resize the resulting "scan vector" to that average size (if it needs expanding in the process, the last element is used to fill the void). So, all messages come to ROS2 with the same point count.

The modification is tested on Raspberry Pi 5 under Ubuntu 24.04 and ROS2 Jazzy. SLAM Toolbox and Nav2 works fine now.

More detail about that robot is here: https://github.com/slgrobotics/robots_bringup/blob/main/Docs/Dragger/README.md

fixing Ubuntu 24.04 compile error
ensure the beam count is constant between LIDAR head revolutions
@slgrobotics
Copy link
Author

See also #2 for the #include <pthread.h> issue (fixed in this PR)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant