Ask Your Question
0

rosnode kill doesn't kill a node

asked 2011-11-01 12:27:47 -0500

Paul0nc gravatar image

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.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
7

answered 2011-11-02 02:14:42 -0500

DimitriProsser gravatar image

updated 2011-11-02 02:18:23 -0500

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}')
edit flag offensive delete link more

Comments

Thanks Dimitri!
Paul0nc gravatar imagePaul0nc ( 2011-11-05 01:22:55 -0500 )edit
0

answered 2019-01-11 14:51:58 -0500

dsoike gravatar image

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>
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2011-11-01 12:27:47 -0500

Seen: 4,834 times

Last updated: Jan 11