I am doing mapping using ROS2 and slam_toolbox. My robot has a toggle button to start mapping/localization. The button launches either a mapping or a localization launch.py file with the right nodes, parameters and services, etc. The idea is for the mapping launch file to store the map when it finishes. When the button is turned off a sigint is sent to the launch file. Can I call the ros2 service to save the map when receiving the sigint before closing any node in the launch file?

I have tried to use the OnShutdown event handler, but by the time the command is executed the mapping node and its services are no longer operative.



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.