You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

ROS2 Humble下仅LiDAR的SLAM Toolbox地图固定不更新排查

问题

在ROS2 Humble环境下仅使用TIM561 2D LiDAR(无里程计)运行SLAM Toolbox,节点已启动且扫描数据正常发布,但RViz中的地图始终固定在初始帧未更新,怀疑与YAML配置有关。

现有配置文件

针对Jetson优化的仅LiDAR建图SLAM Toolbox YAML配置:

slam_toolbox:
  ros__parameters:
    odom_frame: odom
    map_frame: map
    base_frame: base_link
    scan_topic: /scan
    mode: mapping
    debug_logging: false
    throttle_scans: 1
    use_odometry: false
    transform_publish_period: 0.02
    tf_buffer_duration: 30.0
    transform_timeout: 0.5
    map_update_interval: 2.0
    provide_odom_frame: true
    solver_plugin: solver_plugins::CeresSolver
    ceres_linear_solver: SPARSE_NORMAL_CHOLESKY
    ceres_preconditioner: SCHUR_JACOBI
    ceres_trust_strategy: LEVENBERG_MARQUARDT
    ceres_dogleg_type: TRADITIONAL_DOGLEG
    ceres_loss_function: None
    use_scan_matching: true
    use_tf_scan_transformation: false
    use_scan_barycenter: true
    minimum_travel_distance: 0.01
    minimum_travel_heading: 0.01
    scan_buffer_size: 10
    scan_buffer_maximum_scan_distance: 10.0
    link_match_minimum_response_fine: 0.1
    link_scan_maximum_distance: 1.5
    loop_search_maximum_distance: 3.0
    do_loop_closing: true
    loop_match_minimum_chain_size: 10
    loop_match_maximum_variance_coarse: 3.0
    loop_match_minimum_response_coarse: 0.35
    loop_match_minimum_response_fine: 0.45
    correlation_search_space_dimension: 0.5
    correlation_search_space_resolution: 0.01
    correlation_search_space_smear_deviation: 0.1
    loop_search_space_dimension: 8.0
    loop_search_space_resolution: 0.05
    loop_search_space_smear_deviation: 0.03
    distance_variance_penalty: 0.5
    angle_variance_penalty: 1.0
    fine_search_angle_offset: 0.00349
    coarse_search_angle_offset: 0.349
    coarse_angle_resolution: 0.0349
    minimum_angle_penalty: 0.9
    minimum_distance_penalty: 0.5
    use_response_expansion: true
    min_laser_range: 0.1
    max_laser_range: 10.0
    minimum_time_interval: 0.1
    resolution: 0.05
    enable_interactive_mode: false
    paused_new_measurements: false
    stack_size_to_use: 40000000

启动文件代码

# USB LiDAR node (publishes /scan)
usb_lidar_node = Node(
    package='sick_tim_usb_ros2',
    executable='usb_lidar_node',
    name='usb_tim_publisher',
    output='screen',
    parameters=[{
        'frame_id': 'laser_frame',
        'range_min': 0.1,
        'range_max': 10.0,  # TIM561 max range
        'angular_resolution': '1.0',
    }]
)

# Static transforms for lidar-only SLAM
# odom -> base_link (identity)
odom_to_base_tf = Node(
    package='tf2_ros',
    executable='static_transform_publisher',
    name='odom_to_base_tf',
    arguments=[
        '--x', '0.0','--y', '0.0','--z', '0.0',
        '--qx', '0.0','--qy', '0.0','--qz', '0.0','--qw', '1.0',
        '--frame-id', 'odom','--child-frame-id', 'base_link'
    ]
)

# base_link -> laser_frame (LiDAR mount)
base_to_laser_tf = Node(
    package='tf2_ros',
    executable='static_transform_publisher',
    name='base_to_laser_tf',
    arguments=[
        '--x', '0.0','--y', '0.0','--z', '0.1',  # adjust for LiDAR mount
        '--qx', '0.0','--qy', '0.0','--qz', '0.0','--qw', '1.0',
        '--frame-id', 'base_link','--child-frame-id', 'laser_frame'
    ]
)

#SLAM Toolbox node
slam_toolbox_node = IncludeLaunchDescription(
    PythonLaunchDescriptionSource([
        FindPackageShare('slam_toolbox') + '/launch/online_async_launch.py'
    ]),
    launch_arguments={
        'use_sim_time': 'false',
        'slam_params_file': 'path/to/your/mapper_params_online_async.yaml',
    }.items()
)

核心疑问:为何RViz中SLAM Toolbox的帧保持固定?是否需要重建内部状态或显式重置地图?无外部位移计时时,仅LiDAR的SLAM Toolbox是否需要特定参数?原以为scan matching可以解决问题。


分析与解决方案

1. 静态TF冲突是核心问题

你发布了odom -> base_link的静态TF,但SLAM Toolbox配置中provide_odom_frame: true,意味着SLAM Toolbox会动态推算并维护odom -> base_link的位姿关系。静态TF会覆盖SLAM Toolbox的动态结果,导致base_link相对于odom永远固定,地图自然无法随LiDAR移动更新。

解决方法:删除启动文件中的odom_to_base_tf节点,让SLAM Toolbox自行处理odom到base_link的位姿推算。

2. 扫描匹配触发阈值不合理

配置中的minimum_travel_distance: 0.01和minimum_travel_heading: 0.01阈值过小,会导致SLAM Toolbox把LiDAR的微小抖动误判为有效移动,或因频繁触发匹配产生噪声干扰,反而无法正常完成扫描匹配。

调整建议:

  • 将minimum_travel_distance改为0.1(10cm)
  • 将minimum_travel_heading改为0.05(约2.86度)
    过滤微小抖动,确保只有实际移动时才触发匹配。

3. 验证TF变换链完整性

确保TF树结构为map -> odom -> base_link -> laser_frame,无缺失或冲突。执行以下命令检查:

ros2 run tf2_tools view_frames.py

生成的frames.pdf会显示当前TF树结构,确认所有变换关系正常。

4. 地图更新间隔优化

map_update_interval: 2.0意味着每2秒才更新一次地图,可能造成“地图未更新”的视觉错觉。可临时改为0.5(500ms),观察地图是否有变化,之后再根据需求调整。

5. 无需重置地图

当前问题并非地图内部状态异常导致,无需重置地图。先解决TF和参数配置问题后,再观察地图更新情况。

仅LiDAR SLAM关键参数总结

无里程计场景下,SLAM Toolbox需满足以下核心配置:

  • use_odometry: false:禁用里程计输入
  • 禁止发布odom -> base_link静态TF:让SLAM Toolbox自行推算该变换
  • 合理设置minimum_travel_distance和minimum_travel_heading:平衡触发灵敏度与抗噪性
  • provide_odom_frame: true:保持开启,让SLAM Toolbox发布map -> odom变换

内容的提问来源于stack exchange,提问作者Boo Man

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.12 03:08:13