Ask Your Question

What difference between ros::shutdown() and ros::requestShutdown() ?

asked 2020-02-13 05:41:07 -0600

standmit gravatar image

When I have to use ros::shutdown() and when I have to use ros::requestShutdown()?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2020-02-13 06:28:36 -0600

pavel92 gravatar image

updated 2020-02-13 07:39:47 -0600

gvdhoorn gravatar image

From the documentation:

  • void ros::requestShutdown ( )

    Request that the node shut itself down from within a ROS thread. This method signals a ROS thread to call shutdown().

  • void ros::shutdown( )

    Disconnects everything and unregisters from the master. It is generally not necessary to call this function, as the node will automatically shutdown when all NodeHandles destruct. However, if you want to break out of a spin() loop explicitly, this function allows that.

From the definition:

the requestShutdown() just sets a global bool (g_shutdown_requested) to true, which is later processed in the checkForShutdown() method which runs from within a mutex inside a PollManager. The point is to prevent from deadlocking with another thread that's already in the middle of shutdown()

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2020-02-13 05:41:07 -0600

Seen: 24 times

Last updated: Feb 13