# Merge multiple static_layer costmaps in Foxy

Hello,

I'm trying to define keepout zones in ROS2 Foxy. The idea was to draw the keepout zones manually as obstacles on a PNG map, publish this map with a map_server, and use it in a static_layer plugin of the global_costmap to generate high cost area on the keepout zones (the same as here in ROS1).

But the final published costmap corresponds to only one of the static map, and not a merging/stacking of the two. In rviz both maps can be visualized correctly (when displaing the Maps published by the map servers).

Here is my configuration of the global_cosmap:

global_costmap:
global_costmap:
ros__parameters:
update_frequency: 1.0
publish_frequency: 1.0
global_frame: map
map_topic: ""
use_sim_time: false
footprint: "[ [-0.48, -0.29], [0.46, -0.29], [0.46, 0.29], [-0.48, 0.29] ]"
resolution: 0.05
track_unknown_space: true
always_send_full_costmap: true
use_maximum: true           # Tried to play with this param, also trying at the level of the static_layers
plugins: ["static_layer", "keepout_layer", "obstacle_layer", "inflation_layer"]
static_layer:
plugin: "nav2_costmap_2d::StaticLayer"
map_topic: /map
keepout_layer:
plugin: "nav2_costmap_2d::StaticLayer"    # The second static_layer
obstacle_layer:
plugin: "nav2_costmap_2d::ObstacleLayer"
observation_sources: scan
scan:
topic: /scan
data_type: "LaserScan"
clearing: true
marking: true
inf_is_valid: true
obstacle_range: 4.0
raytrace_range: 4.5
max_obstacle_height: 2.0
inflation_layer:
plugin: "nav2_costmap_2d::InflationLayer"
cost_scaling_factor: 5.0

global_costmap_client:
ros__parameters:
use_sim_time: false
global_costmap_rclcpp_node:
ros__parameters:
use_sim_time: false


Am I missing something in the configuration for ROS2, or do you see any issue ?

NB1: I made sure to apply 'use_maximum' as suggested here (again for ROS1), both at the global_costmap node level and static_layers plugins levels.

NB2: Also when my ros stack starts, I briefly see that the costmap corresponds one map (my keepout map), then few second later, it is overriden by the costmap corresponding to the environment (maybe one is loaded faster than the other, but the last map loaded overrides the first one in the costmap).