ROS Resources: Documentation | Support | Discussion Forum | Service Status | Q&A answers.ros.org

How to handle node shutdown in java code?


#1

I am trying to work out how to gracefully shutdown my node, without ctrl C. I assume that “rosnode kill” should close down the node, but it doesn’t. I have the code below in my node but it is never called. Though when I run “rosnode kill” I do see in the log this “Shutdown requested by /rosnode with message “user request””.

So how should shutdwon be handled in the code?

public class PCTControl extends AbstractNodeMain {

@Override
public void onShutdown(Node node) {
// TODO Auto-generated method stub
final Log log = node.getLog();
log.info(“onShutdown called.”);
super.onShutdown(node);
}
}


#2

This forum is new, and somewhat unfamiliar to most of us.

But, I would suggest that this question can be more effectively resolved using answers.ros.org.