ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
2

ctrl-c shutdown of nodelet manager versus calling shutdown inside of nodelet manager

asked 2015-11-13 10:20:22 -0500

barryjobrien gravatar image

I have written a camera manager node that produces a combined/tiled image from two single camera nodes being loaded as nodelet into my camera manager. The camera manager is being launched as a node (and has a Nodelet::Loader as a member var) from a launch file, and the two camera nodelets are being loaded into that camera manager using the load arg in a launch file (args="load camera_nodelet camera_manager"). This works great.

For various reasons, the cameras can stop working properly from time to time and need to be restarted. Using Ctrl-C to exit the camera manager produces relatively nice messages about "Unloading nodelet .... from manager ..." and then shutting down processing monitor. Relaunching the camera manager launch file brings the whole system back up, and everything is happy.

I want to automate this process (exiting and restarting). When the system detects it needs a restart, I call exit() from within the camera manager and rely on roslaunch to respawn the camera manager. This is technically exiting and respawning, but it does not do it nearly as gracefully as when I Ctrl-C exit, instead immediately exiting with a "process has died" message and respawning the system into a state where the camera nodelets don't come back up properly. Similarly I have tried calling ros::shutdown(), ros::requestShutdown(), and even raise(SIGINT) - all behave just like exit().

So my question is how can I internally make my node exit in the same manner that roslaunch is causing my node to exit?

edit retag flag offensive close merge delete

Comments

Great Question. I'm curious to know the answer too! None of the above seem to work as well as I would like.

emrainey gravatar image emrainey  ( 2016-03-11 16:24:33 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2016-03-11 16:31:24 -0500

emrainey gravatar image

updated 2017-08-30 17:36:15 -0500

130s gravatar image

I did find something that works! You have to configure your node launch XML to indicate that the nodelet which will call exit(x) is required. Then when it detects a failure, it will kill the entire launch file.

<node pkg.... required="true">
...
</node>

then inside nodelet you can call "exit(err);" with some error in err. Well I did the following incase there's some other path:

ros::shutdown();
raise(SIGINT);
raise(SIGABRT);
exit(-1);

I really want it to exit.

edit flag offensive delete link more

Comments

But using required="true" will affect others (launch files / nodes) as well when this launch file is integrated into the main launch file.

HappySamuel gravatar image HappySamuel  ( 2021-11-24 20:07:51 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2015-11-13 10:20:22 -0500

Seen: 1,581 times

Last updated: Aug 30 '17