Ask Your Question
4

How to kill nodes in ROS2?

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

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

1 Answer

Sort by ยป oldest newest most voted
4

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

gvdhoorn gravatar image

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

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 -0500 )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?

maciej-3 gravatar image maciej-3  ( 2021-02-03 17:57:02 -0500 )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 -0500 )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?

maciej-3 gravatar image maciej-3  ( 2021-02-04 08:36:07 -0500 )edit
2

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 -0500 )edit

Your Answer

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

Add Answer

Question Tools

2 followers

Stats

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

Seen: 2,502 times

Last updated: May 16 '19