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

Stop the whole ros through C++ code [closed]

asked 2017-09-13 01:08:36 -0500 gravatar image

Hi all,

Does anyone know is there c++ API that can help to shut down the whole ros instead of a node? What I want to do is I plan to use shell script for automating the simualtion in ros. I use roslaunch command for spawning the environment and drones. And run another c++ file (a node) for controller. However, I do not know how to stop ros when the controling algorithm is finished. If I use ros::shutdown(), I can only shutdown the controller node but the graphic interface is still here. So, does anyone here know any way to shut down the whole ros through c++ code?


edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by ahendrix
close date 2017-09-13 05:07:42.240837

1 Answer

Sort by ยป oldest newest most voted

answered 2017-09-13 04:15:15 -0500

ahendrix gravatar image

If you run everything from a single launch file, you can add the required="true" attribute to your controller node, which will cause roslaunch to stop all of the other nodes when your controller node exits.

See for a more detailed description of all of the attributes to the <node> tag and what they do.

edit flag offensive delete link more


Thanks, sir. This is exactly what I need. Appreciate that. gravatar image  ( 2017-09-13 04:59:25 -0500 )edit

Question Tools

1 follower


Asked: 2017-09-13 01:08:36 -0500

Seen: 960 times

Last updated: Sep 13 '17