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

- **ID:** `ros2/costmap-layer-initialization-failure-no-topic`
- **Domain:** ros2
- **Category:** runtime_error
- **Error Code:** `NAV2-5001`
- **Verification:** ai_generated
- **Fix Rate:** 91%

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

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| ROS2 Humble Hawksbill | active | — | — |
| ROS2 Iron Irwini | active | — | — |
| ROS2 Jazzy Jalisco | active | — | — |

## Workarounds

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.** (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.
   ```
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).** (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).
   ```

## Dead Ends

- **** — 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. (80% fail)
- **** — Disabling the obstacle layer entirely in the costmap configuration removes the error but also removes obstacle avoidance, which is critical for navigation. (90% fail)
