ROS2 lifecycle node - how to shut down cleanly?

asked 2020-02-10 11:38:12 -0600

wieset gravatar image

updated 2020-02-10 16:30:04 -0600

I am trying to implement a ROS2 lifecycle node that takes the shutdown transition when exiting via CTRL-C.

The shutdown transition in the lifecycle node state machine does not get called automatically when exiting. Thus, I am trying to find a way to call shutdown() on the lifecycle node when CTRL-C is pressed to get it to the finalized state before exiting.

Maybe I've missed something, but I could not find a way to implement this. The obvious approach of writing my own signal handler for SIGINT did not work, as the context seems to be already destroyed at the time my signal handler is called. Thanks for any help!

edit retag flag offensive close merge delete