Ros nodelet destructor does not run consistently

asked 2021-06-18 14:38:19 -0500

guiltySpark85 gravatar image

I have a launch file containing the following for the purpose of offline data playback:

  1. a ros nodelet manager
  2. several nodelets (A, B and C)
  3. rosbag play
  4. rviz

Everything in the launch file has the 'required' attribute set to true, so if anything dies then everything else does as well.

When I'm done playing back data, I press ctrl-c which kills rosbag play and then the nodelet manager starts unloading all the nodelets. But only nodelet C's destructor get called, and not the others. If I prevent nodelet C from running by removing it from the launch file, then the destructors of nodelet A and B DO execute. This is strange in of itself and would like to know possible reasons for how that can occur. I really need all the nodelet destructors to run because the destructors are where some important data gets saved. I noticed that if I kill the nodelet manager directly by running "rosnode kill nodeman" from the command line, then it kills all the nodelets and all of their destructors get run. That is a nice workaround, but I would rather trigger this behavior by killing the rosbag process. Can anyone help my achieve this?

I am running ros kinetic on Ubuntu 16.04.

edit retag flag offensive close merge delete

Comments

I am running ros kinetic on Ubuntu 16.04.

why? Out of curiosity: why are so many people still running Kinetic? It's been EOL for quite some time now. There are so many fixes and improvements in Melodic and Noetic it's getting strange to see so many questions on ROS Answers still mentioning Kinetic.

gvdhoorn gravatar image gvdhoorn  ( 2021-06-19 09:16:29 -0500 )edit

As to your problem: do those dtors (potentially) take a lot of time to complete? If so: it could be roslaunch is timing out on killing your nodelet manager and decides to escalate to SIGTERM, forcibly shutting down the process.

I'm not sure a dtor is the correct place to save lots of data.

gvdhoorn gravatar image gvdhoorn  ( 2021-06-19 09:17:58 -0500 )edit

Have you verified that the C destructor is not crashing? I would connect a debugger to the node manager after it is up and running, and see what messages you get when you kill the rosbag node. If you use gdb, you'll need to reissue the SIGINT signal in gdb to complete the shutdown of the node manager process.

Mike Scheutzow gravatar image Mike Scheutzow  ( 2021-06-28 20:49:56 -0500 )edit