rosnode kill doesn't kill a node
I have created a rosnode in C++. It will not be killed by rosnode kill <nodename>.
Can anyone tell me why this might this might be happening?
Thanks, Paul.
ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
I have created a rosnode in C++. It will not be killed by rosnode kill <nodename>.
Can anyone tell me why this might this might be happening?
Thanks, Paul.
On the rosnode page, it states that rosnode kill
is not guaranteed to succeed. If your node is set to "respawn", rosnode kill
won't kill it properly. The other (more likely) cause of this problem is that your node is "hanging". What this means is that you're trapped in some infinite loop that does not check for the continued existence of ROS.
For example, instead of
while (1) {}
use
while (ros::ok()) {}
I've also run into problems with nodes hanging due to socket connections that fail to close properly.
In the case that you must shut down a node immediately, you can use the following command to kill it less nicely (provided that you're on a *Nix operating system):
kill $(ps aux | grep your_node | grep -v grep | awk '{print $2}')
If you're using roslaunch
to start your nodes and rosnode kill <my_node>
isn't working, try re-roslaunching first. This will replace the existing nodes with freshly-launched ones, which you should be able to kill.
roslaunch <my_package> <launch_file>
rosnode kill <my_node>
Asked: 2011-11-01 12:27:47 -0600
Seen: 9,152 times
Last updated: Jan 11 '19