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

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

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

jasonwang538@gmail.com 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?

Thanks

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
3

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 http://wiki.ros.org/roslaunch/XML/node for a more detailed description of all of the attributes to the <node> tag and what they do.

edit flag offensive delete link more

Comments

Thanks, sir. This is exactly what I need. Appreciate that.

jasonwang538@gmail.com gravatar image jasonwang538@gmail.com  ( 2017-09-13 04:59:25 -0500 )edit

Question Tools

1 follower

Stats

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

Seen: 960 times

Last updated: Sep 13 '17