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

Shutdown nodes from within a ROS node

asked 2015-09-29 10:17:32 -0600

nwanda gravatar image

updated 2015-09-29 10:37:07 -0600

This is a follow up question to Shutdown system (computer) with a ROS node.

Since the system in which the ROS is running is connected to some motors I would like to know if it is possible to close nodes from within a different ROS node.

Since the system is powered by some batteries, the shutdown procedure I would like to achieve is something like this: Once battery level is below a certain threshold:

  • Close/stop all nodes
  • Stop rosbag recording
  • Shutdown system

However I have no clue how to "Close/stop all nodes" and "Stop rosbag recording" from within a certain node (The same node used to check the battery level).

Is this possible?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2015-09-29 10:24:56 -0600

You can use rosnode.kill_nodes to shutdown nodes. I'm not sure this is necessary though - the system shutdown command (shutdown) should send SIGTERM to all processes so they can end gracefully.

edit flag offensive delete link more

Comments

Would that stop the rosbag recording properly so that I can use the bag-file after rebooting? And is there a way to select which nodes to "kill" or the only way is to shutdown every node with rosnode.kill_nodes?

nwanda gravatar image nwanda  ( 2015-09-29 10:37:48 -0600 )edit

That's a good question: I tried kill -15 with rosbag which seems like it may not properly close the file. Your best bet would just be to just try rebooting with an active rosbag record to see what happens. rosnode killing rosbag does seem to work fine though.

Dan Lazewatsky gravatar image Dan Lazewatsky  ( 2015-09-29 10:45:05 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2015-09-29 10:17:32 -0600

Seen: 2,240 times

Last updated: Sep 29 '15