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

How to catch nodelet shutdown signal?

asked 2011-12-22 16:30:02 -0600

K Chen gravatar image

I created a new thread in a nodelet which runs some task until the nodelet is shutdown. But I don't know how to let the new thread know when the nodelet is shutting down, so for now it will make the whole nodelet_manager crash when I only wants to end that nodelet.

I tried to use getPrivateNodeHandle() to get the ros::NodeHandle instance, and use nodehandle.ok() to test whether the new thread should stop, sometimes it works, but sometimes not.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2011-12-22 17:36:12 -0600

tfoote gravatar image

updated 2017-08-25 07:29:18 -0600

130s gravatar image

You should signal any threads started in the destructor and wait to join them before exiting the destructor.

For an example take a look at the camera1394 nodelet destructor.

edit flag offensive delete link more

Comments

Thanks! It's a good example
K Chen gravatar image K Chen  ( 2011-12-24 18:29:16 -0600 )edit

I'm not really sure if the destructor is being called correctly since I try to use ROS_INFO_STREAM or std::cout and I see nothing printed.

Matias gravatar image Matias  ( 2014-11-21 13:53:58 -0600 )edit

Question Tools

Stats

Asked: 2011-12-22 16:30:02 -0600

Seen: 1,762 times

Last updated: Aug 25 '17