Hi everyone!
I’d like to share nav2_virtual_layer, a Nav2 costmap plugin that lets you create virtual obstacles and dynamic cost zones in ROS 2. You can define circles, lines, or polygons and assign custom cost values, from soft-cost areas to lethal obstacles. This makes it functionally similar to a “keep out zone” plugin, giving you the ability to define restricted areas on your map.
The plugin offers full runtime control: you can add, remove, clear, or restore shapes while your navigation stack is running. No restarts are needed, and the robot responds immediately to changes. Overlapping shapes merge safely, keeping the highest cost.
You can also precisely set the cost of each shape and temporarily remove or restore them at any time. This makes it easy to adjust restricted areas or modify cost zones on the fly, without interrupting navigation. Your robot can continue operating while you experiment with different scenarios or restore original restrictions instantly.


