rosnode kill
I want to kill all nodes in one command. Now ,we can use rosnode kill 1 step by step to end all the node .
but i want to use one command to kill all node.
ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
I want to kill all nodes in one command. Now ,we can use rosnode kill 1 step by step to end all the node .
but i want to use one command to kill all node.
Seems the answer is out-dated.
In kinetic, you could simply kill all node with
rosnode kill -a
or
rosnode kill --all
And actually you kill roscore, you will not kill all nodes. the nodes will keep exchanging msgs but we cannot access the topics any more.
I don't know if it is what you want to do but if you kill the roscore, you kill at the same time all nodes.
But if you want to kill all nodes without killing the roscore, you can create your own script like this:
#!/usr/bin/env python
import os
nodes = os.popen("rosnode list").readlines()
for i in range(len(nodes)):
nodes[i] = nodes[i].replace("\n","")
for node in nodes:
os.system("rosnode kill "+ node)
I have written this script in python. I tested it, it works properly. You can modify it as you wish.
I want to notice that the node /rosout will relaunch itself automatically after being killed by this script.
I hope it helps you,
lfr
Try this:
rosnode list | grep -v rosout | xargs rosnode kill
It should kill all nodes except /rosout
Asked: 2016-06-23 04:38:51 -0600
Seen: 30,743 times
Last updated: Dec 26 '18