How to kill nodes in ROS2?
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.
ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
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.
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.
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).
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
Asked: 2019-05-16 06:02:43 -0600
Seen: 33,559 times
Last updated: May 16 '19