NAV2-5001 ros2 runtime_error ai_generated true

[nav2_costmap_2d] Failed to initialize layer 'obstacle_layer': Topic '/scan' not found

ID: ros2/costmap-layer-initialization-failure-no-topic

Also available as: JSON · Markdown · 中文
91%Fix Rate
87%Confidence
1Evidence
2024-02-14First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
ROS2 Humble Hawksbill active
ROS2 Iron Irwini active
ROS2 Jazzy Jalisco active

Root Cause

The obstacle layer in Nav2's costmap cannot subscribe to its input topic (e.g., '/scan') because the publisher for that topic is not running or the topic name is misconfigured in the costmap parameters.

generic

中文

Nav2 代价地图中的障碍物图层无法订阅其输入话题(例如 '/scan'),因为该话题的发布者未运行,或者在代价地图参数中话题名称配置错误。

Official Documentation

https://docs.nav2.org/configuration/packages/costmap-plugins/obstacle.html

Workarounds

  1. 95% success Ensure the LiDAR or sensor node is running and publishing to the correct topic. Use `ros2 topic list` and `ros2 topic echo /scan` to verify. If the topic name differs (e.g., '/scan_raw'), update the costmap YAML config to match.
    Ensure the LiDAR or sensor node is running and publishing to the correct topic. Use `ros2 topic list` and `ros2 topic echo /scan` to verify. If the topic name differs (e.g., '/scan_raw'), update the costmap YAML config to match.
  2. 90% success If the sensor publishes on a different topic (e.g., '/lidar/points'), set the `topic` parameter in the obstacle layer configuration to that topic, and ensure the message type matches (e.g., LaserScan or PointCloud2).
    If the sensor publishes on a different topic (e.g., '/lidar/points'), set the `topic` parameter in the obstacle layer configuration to that topic, and ensure the message type matches (e.g., LaserScan or PointCloud2).

中文步骤

  1. Ensure the LiDAR or sensor node is running and publishing to the correct topic. Use `ros2 topic list` and `ros2 topic echo /scan` to verify. If the topic name differs (e.g., '/scan_raw'), update the costmap YAML config to match.
  2. If the sensor publishes on a different topic (e.g., '/lidar/points'), set the `topic` parameter in the obstacle layer configuration to that topic, and ensure the message type matches (e.g., LaserScan or PointCloud2).

Dead Ends

Common approaches that don't work:

  1. 80% fail

    Setting the topic to an empty string or a random topic name may avoid the error but will cause the costmap to have no obstacle data, making the robot blind to obstacles.

  2. 90% fail

    Disabling the obstacle layer entirely in the costmap configuration removes the error but also removes obstacle avoidance, which is critical for navigation.