Myzhar / ldrobot-lidar-ros2

ROS2 package for LDRobot lidar. Based on ROS2 Lifecycle nodes
Apache License 2.0
63 stars 23 forks source link

slam_toolbox + LD19 #14

Closed carlosdbez closed 8 months ago

carlosdbez commented 1 year ago

Hello I'm new to the ROS2 system. I would like to ask a question. I recently purchased the LIDAR LD19. I managed to configure it and it is working OK, presenting the data in the RVIZ (LaserScan).

My question is: I would like to make a SLAM process and for that I am using the slam_toolbox framework. I configured the slam_toolbox following a tutorial and apparently managed to subscribe to the /ldlidar_node/scan topic. I opened the RVIZ2, activated the map. I added the map topic, however I can't generate the map (SLAM) at all. The funny thing is that apparently ldlidar_node is being processed by slam_toolbox (you can see it in the terminal). But the map is not generated.

Could you let me know if the LD-19 Lidar is compatible with the ROS2 slam_toolbox? Is there any other framework, compatible, that I could generate the SLAM?

Thanks.

Myzhar commented 1 year ago

Hi @carlosdbez I suggest you ask on ROS 2 forum to have more information about how to configure the tool:

Chambana commented 1 year ago

@carlosdbez SLAM toolbox can make a map with the LD19, but there are issues regarding what the LD19 ROS2 driver (this one and the OEM one) output and what SLAM toolbox expects from LIDARs from Hokuyo, Velodyne, SICK, etc. I'll make a separate issue documenting that issue, but @carlosdbez here is an image showing SLAM toolbox creating a map from the LD19. Just make sure you have an odometry source feeding the slam toolbox, your frames are connected in the TF tree, and your scan topics are set correctly. image

carlosdbez commented 8 months ago

@Chambana I apologize for the discomfort. But I'm desperate with this LIDAR.

I am a beginner in ROS2. My entire life I have only used CoppeliaVREP.

I will detail the steps we followed and if you can help me, I would be grateful.

Basically I wanted to generate a map from the measurements of my LIDAR LD-19. As long as it is not connected to any type of robot. Lidar is static.

This way I got a standard yaml file template from the slam toolbox.

https://github.com/SteveMacenski/slam_toolbox/tree/ros2/config

I used mapper_params_online_async.yaml

Later I created a ROS2 package to change this default yaml file and start SLAM_toolbox

`from launch import LaunchDescription from launch_ros.actions import Node

def generate_launch_description(): config_path = '/home/carlos/ros2_ws/src/meu_slam_toolbox/config/slam_toolbox_params.yaml'

return LaunchDescription([
    Node(
        package='slam_toolbox',
        executable='async_slam_toolbox_node',
        name='slam_toolbox',
        output='screen',
        parameters=[{'use_sim_time': False}, config_path],
        remappings=[('/scan', '/lidar_node/scan')],
        # Adicione a seguinte linha para usar o quadro base como fonte de odometria
        arguments=['--odom', 'ldlidar_base']
    ),
    Node(
        package='tf2_ros',
        executable='static_transform_publisher',
        name='static_transform_publisher',
        output='screen',
        arguments=['0', '0', '0', '0', '0', '0', 'ldlidar_base', 'ldlidar_link']
    )`

I changed some Yaml parameters manually too


  # ROS Parameters
    odom_frame: odom
    map_frame: map
    base_frame: ldlidar_base
    lidar_frame: ldlidar_link
    scan_topic: /scan
    use_map_saver: true
    mode: mapping #localization

When running the launch file with the LD19 node active I had the following messages

async_slam_toolbox_node-1] [INFO] [1706802034.671548971] [slam_toolbox]: Message Filter dropping message: frame 'ldlidar_link' at time 1706802034.471 for reason 'the timestamp on the message is earlier than all the data in the transform cache'
[async_slam_toolbox_node-1] [INFO] [1706802035.169091151] [slam_toolbox]: Message Filter dropping message: frame 'ldlidar_link' at time 1706802035.069 for reason 'discarding message because the queue is full'
[async_slam_toolbox_node-1] [INFO] [1706802035.369192791] [slam_toolbox]: Message Filter dropping message: frame 'ldlidar_link' at time 1706802035.169 for reason 'the timestamp on the message is earlier than all the data in the transform cache'
[async_slam_toolbox_node-1] [INFO] [1706802035.669001600] [slam_toolbox]: Message Filter dropping message: frame 'ldlidar_link' at time 1706802035.469 for reason 'the timestamp on the message is earlier than all the data in the transform cache'

Lidar only publishes LaserScan messages. The Map is not published in the /map topic.

If you could give me some help on how I can configure it to generate the Map I would be very grateful. Thanks.

Myzhar commented 8 months ago

Can you try the code of the humble branch? I added an example launch file that correctly works. It's not yet the final version because I want to add other features, but it's a good starting point

PS you missed topic remapping and used the wrong TF frame

Myzhar commented 8 months ago

Fixed with the latest update