What if your robot could instantly know where obstacles are and keep a safe distance without you lifting a finger?
Why Costmap configuration (static, obstacle, inflation) in ROS? - Purpose & Use Cases
Imagine trying to guide a robot through a room full of furniture by manually marking every obstacle and safe path on a map each time it moves.
Manually updating maps is slow, error-prone, and impossible to keep up with moving obstacles or changes in the environment.
Costmap configuration automatically marks static obstacles, detects dynamic obstacles, and inflates safety zones around them so the robot can plan safe paths without constant manual updates.
map.markObstacle(x, y) map.updatePath()
costmap:
static_layer:
enabled: true
obstacle_layer:
enabled: true
inflation_layer:
inflation_radius: 0.5This lets robots safely navigate complex, changing environments by understanding obstacles and safe distances automatically.
A delivery robot in an office uses costmap configuration to avoid desks, chairs, and people while finding the best route to deliver packages.
Manual obstacle marking is slow and unreliable.
Costmap layers handle static and dynamic obstacles automatically.
Inflation creates safe buffer zones for smooth navigation.
Practice
Solution
Step 1: Understand the role of the static layer
The static layer uses a pre-built map to mark fixed obstacles that do not change over time.Step 2: Compare with other layers
The obstacle layer updates obstacles dynamically from sensors, and the inflation layer adds safety buffers, so they do not mark fixed obstacles directly.Final Answer:
Static layer -> Option CQuick Check:
Fixed obstacles = Static layer [OK]
- Confusing obstacle layer with static layer
- Thinking inflation layer marks obstacles
- Assuming sensor data is static
Solution
Step 1: Check correct keys for inflation layer
The correct keys are 'inflation_layer' with 'enabled' and 'inflation_radius' as parameters.Step 2: Validate values and syntax
inflation_layer: enabled: true inflation_radius: 0.5 uses 'enabled: true' and 'inflation_radius: 0.5', which is correct YAML syntax and valid keys.Final Answer:
inflation_layer: enabled: true inflation_radius: 0.5 -> Option DQuick Check:
Correct keys and true enabled = inflation_layer: enabled: true inflation_radius: 0.5 [OK]
- Using wrong key names like 'enable' or 'active'
- Setting enabled to false when enabling
- Incorrect indentation or YAML syntax
obstacle_layer:
observation_sources: laser_scan_sensor
laser_scan_sensor:
data_type: LaserScan
topic: /scan
marking: true
clearing: true
inflation_layer:
inflation_radius: 0.7
cost_scaling_factor: 10.0What effect does setting
marking: true and clearing: true have on the obstacle layer?Solution
Step 1: Understand marking and clearing flags
Setting 'marking: true' means detected obstacles are added to the costmap. 'clearing: true' means free space detected is cleared from the costmap.Step 2: Apply to laser_scan_sensor
The laser scan sensor will mark obstacles and clear free space dynamically based on sensor data.Final Answer:
It marks obstacles detected by the laser and clears free space around them -> Option AQuick Check:
marking + clearing true = mark and clear obstacles [OK]
- Assuming clearing disables marking
- Thinking marking disables clearing
- Confusing cost_scaling_factor with marking
inflation_layer: inflation_radius: 0.6 cost_scaling_factor: -5.0
What is the problem with this configuration?
Solution
Step 1: Check cost_scaling_factor value
The cost_scaling_factor controls how quickly costs drop off from obstacles. It must be positive; negative values are invalid.Step 2: Understand impact of negative value
A negative cost_scaling_factor causes errors or unexpected inflation behavior in the costmap.Final Answer:
Negative cost_scaling_factor is invalid and causes inflation errors -> Option BQuick Check:
cost_scaling_factor < 0 = error [OK]
- Thinking inflation_radius must be integer
- Assuming missing enabled disables inflation
- Believing zero cost_scaling_factor disables inflation
Solution
Step 1: Verify static layer configuration
static_layer: map_topic: /map obstacle_layer: observation_sources: laser_scan laser_scan: data_type: LaserScan topic: /scan marking: true clearing: true inflation_layer: enabled: true inflation_radius: 0.8 cost_scaling_factor: 5.0 correctly sets 'static_layer' with 'map_topic: /map' to use the static map.Step 2: Check obstacle layer settings
static_layer: map_topic: /map obstacle_layer: observation_sources: laser_scan laser_scan: data_type: LaserScan topic: /scan marking: true clearing: true inflation_layer: enabled: true inflation_radius: 0.8 cost_scaling_factor: 5.0 uses 'laser_scan' with correct data_type, topic, and both marking and clearing enabled for proper obstacle detection.Step 3: Confirm inflation layer parameters
static_layer: map_topic: /map obstacle_layer: observation_sources: laser_scan laser_scan: data_type: LaserScan topic: /scan marking: true clearing: true inflation_layer: enabled: true inflation_radius: 0.8 cost_scaling_factor: 5.0 enables inflation with radius 0.8 and a positive cost_scaling_factor, matching requirements.Final Answer:
static_layer: map_topic: /map obstacle_layer: observation_sources: laser_scan laser_scan: data_type: LaserScan topic: /scan marking: true clearing: true inflation_layer: enabled: true inflation_radius: 0.8 cost_scaling_factor: 5.0 -> Option AQuick Check:
All layers correct and enabled = static_layer: map_topic: /map obstacle_layer: observation_sources: laser_scan laser_scan: data_type: LaserScan topic: /scan marking: true clearing: true inflation_layer: enabled: true inflation_radius: 0.8 cost_scaling_factor: 5.0 [OK]
- Disabling static layer or obstacle marking
- Using negative cost_scaling_factor
- Setting inflation_radius different from 0.8
Ready to prove it?
Pass the test and this pattern moves unknown
