How to call move_base's clear_costmap_recovery functionality manually from Python
Hello everyone!
This is my first question ever on ROS answers so please go easy on me :).
I would like to know how could I manually call the clear_costmap_recovery functionality with a custom obstacles layer from inside a custom package I developed for ROS Melodic on Ubuntu 18.04, in Python.
To give a bit of background to my specific situation, I am working on a project using the ROS 1 navigation stack which required some way of creating "virtual walls/obstacles" for the robot which would then define "artificial no-go zones" on the map for it. I managed to achieve this by implementing a package which allows me to add custom PointCloud obstacles with different shapes to a custom layer on the costmaps.
The issue I am now facing is that when I am removing those obstacles from the map, they still stick to the local/global costmaps even though they have the "clearing" parameter set to True. This is problematic for me as I would like to have them disappear entirely once I am not publishing the corresponding PointCloud to the specific topic anymore.
What worked for me thus far is I have set a custom clearing behavior using the clear_costmap_recovery functionality from move_base, to only clear my virtual obstacles layer when move_base cannot plan a specific path due to a goal being posted inside one of these "ghost" virtual obstacles. When this happens the recovery behavior manages to clear the areas that remain in the costmaps.
What I would like to do now is to somehow call the clear_costmap_recovery behavior for my custom obstacle layer from inside my virtual_walls package whenever I delete an obstacle. I have been unable to find a tutorial or some piece of info that would point me to a good solution in this direction. For now I am calling the clear_costmaps service in its place but i am not sure if this is truly okay for my situation. I would just want to be able to clear that specific layer, programmatically, from inside my package.
Sorry for the long question, if any extra-info is needed please let me know and I will update my question! Hopefully there is some kind of solution for my issue!
Thanks!
EDIT 1: I would add also some RVIZ screenshots to further clarify this issue but for now I am unable to due to low karma points .