ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
2

rosnode kill

asked 2016-06-23 04:38:51 -0600

ligang gravatar image

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.

edit retag flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted
5

answered 2018-12-26 19:58:34 -0600

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.

edit flag offensive delete link more

Comments

More up-to-date, better answer. I marked this as an answer (and gave +1 for the previous marked answer :)

130s gravatar image 130s  ( 2019-11-12 19:27:24 -0600 )edit
3

answered 2016-06-23 05:03:55 -0600

lfr gravatar image

updated 2016-06-23 05:55:33 -0600

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

edit flag offensive delete link more

Comments

thank you, It's best!

ligang gravatar image ligang  ( 2016-06-24 03:03:09 -0600 )edit

You're welcome

lfr gravatar image lfr  ( 2016-06-24 03:49:32 -0600 )edit
0

answered 2018-12-26 19:45:55 -0600

dsoike gravatar image

Try this:

rosnode list | grep -v rosout | xargs rosnode kill

It should kill all nodes except /rosout

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2016-06-23 04:38:51 -0600

Seen: 30,743 times

Last updated: Dec 26 '18