0
$\begingroup$

Rosanswers logo

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?


Originally posted by nwanda on ROS Answers with karma: 47 on 2015-09-29

Post score: 1

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

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.


Originally posted by Dan Lazewatsky with karma: 9115 on 2015-09-29

This answer was ACCEPTED on the original site

Post score: 2


Original comments

Comment by nwanda on 2015-09-29:
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?

Comment by Dan Lazewatsky on 2015-09-29:
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.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.