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

How to kill nodes in ROS2?

asked 2019-05-16 06:02:43 -0600

askkvn gravatar image

In ROS we have rosnode kill -a. Do we have something like this in ROS2?

I tried ros2 node kill, but it didn't work.

I am using Ubuntu 18.04 LTS | ROS2 Crystal | Gazebo 9.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
6

answered 2019-05-16 06:27:29 -0600

gvdhoorn gravatar image

updated 2019-05-16 06:27:46 -0600

Afaik there is no rosnode kill in ROS 2.

ROS 2 introduces the concept of managed nodes, which have a node lifecycle (ROS2 Design: Managed nodes).

With nodes that support it you can then use

ros2 lifecycle set <nodename> shutdown

which should make the node with name nodename transition to its shutdown state and consequently shutdown the process.

edit flag offensive delete link more

Comments

Can confirm, there is no feature to kill nodes remotely. This feature was related to enforcing node name uniqueness (duplicate names would cause one of the nodes to be killed), but we haven't addressed that yet.

William gravatar image William  ( 2019-05-17 14:51:20 -0600 )edit

@gvdhoorn It does not work in my system. I do ros2 node list which gives me /pp/cam0. Then I do ros2 lifecycle set /pp/cam0 shutdown and the response is Node not found. Any idea how to fix this?

mac137 gravatar image mac137  ( 2021-02-03 17:57:02 -0600 )edit

I have no idea.

I would suggest to first make sure /pp/cam0 is actually a lifecycle node. If it isn't, then ros2 lifecycle is not going to be of any help.

gvdhoorn gravatar image gvdhoorn  ( 2021-02-04 05:44:46 -0600 )edit

@gvdhoorn Thanks! Does that mean that there is no command in ROS2 foxy to shut down a node if the node does not have its lifecycle implemented? Nothing has really changed since May 2019 when you answered this question?

mac137 gravatar image mac137  ( 2021-02-04 08:36:07 -0600 )edit
3

Nothing has really changed since May 2019 when you answered this question?

well, 'nothing' is a bit strong, but I don't believe there is a "kill node" command in ROS 2 in general, and I doubt it will ever be added.

See the rationale added by @William.

Killing nodes is process management, which is something the OS does best. ROS should not duplicate that (unloading components is something else).

gvdhoorn gravatar image gvdhoorn  ( 2021-02-04 08:49:47 -0600 )edit
0

answered 2022-06-30 02:36:28 -0600

jimmy_hawkins gravatar image

in order to kill a node that is not a lifecycle node, i have used the killall command, $killall "name_of_the_node" the name of the node is the one you use to launch the node and not the one you see after running $ros2 node list example: start: $ros2 run may_package my_node stop: $killall my_node

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2019-05-16 06:02:43 -0600

Seen: 33,559 times

Last updated: May 16 '19