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

Revision history [back]

Instead of doing a System call, I'd rather use a ROS Service which then Triggers a shutdown of the node in question. This is way more portable than hard-coding a node Name that can easily be changed using a roslaunch tag.

Instead of doing a System call, I'd rather use a ROS Service which then Triggers a shutdown of the node in question. This is way more portable than hard-coding a node Name that can easily be changed using a roslaunch tag.


EDIT

Create a ServiceServer in the node you want to shut down that triggers ros::shutdown and stops the node. Ideally, you wouldn't do the shutdown in the Service "callback" itself, but rather set some flag that shuts down the node after some short time. This will allow the Service to return a Response.

Thus, your calling node requires a ServiceClient with whatever Service type you see fit. I'd suggest std_srvs/Trigger. But std_srvs/Empty would do as well.