ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

The static layer will size the costmap strictly speaking to its size - hence the word Static. That will resize the layered costmap to match its size when a new map comes in https://github.com/ros-planning/navigation2/blob/main/nav2_costmap_2d/plugins/static_layer.cpp#L200-L206 by design.

You don't need to use that though, you can just set the size of the costmap to use as a parameter and then that's used to size the space (so you don't need to publish a giant empty map on the map server; just set the size of the costmap in yaml to the size you'd like). Think about it like the local rolling costmap; if you set it to 3x3, then that's the size of the costmap. Instead set a non-rolling costmap of whatever size you like, preferably just larger than you know the space would realistically be so that you can explore without a problem.

If you genuinely have no idea and cannot make even a best guess of what the size is of a space, you could conceptually build a new costmap layer that is an "exploration layer" that every time you get close to an edge, extends the map in that direction using the same logic that the Static layer uses, but that's not a default provided capability. Generally speaking you're either (1) using a pre-made map which is the space you care about (2) using SLAM to generate a map on the fly so that is being fed into the costmap to expand the explored space in the Static layer. If you're not doing either of those, you'd need to create a layer to explore OR some logic that would send a new sized empty map to the Static layer (analogous to (2)) to resize the space if you want to be a little hacky about it.