[ros2] shutdown [closed]

asked 2019-01-30 01:36:37 -0500

Obeseturtle gravatar image

updated 2019-01-30 01:56:45 -0500


I am working on a code that contains only 1 main node which creates multiple publishers and subscribers.

Because of this and many other reasons, I am using the not_composable method.

The issue I am having now is that the node takes a while to close. If I run the code multiple times in a short duration, the same node is constantly being created. I am calling the rclcpp::shutdown(); every time the program closes but, the node does not immediately shutdown.

I created a simple code to replicate what I am experience.

std::shared_ptr<rclcpp::Node> master_node;

int main(){
rclcpp::init(0, nullptr);
master_node = std::make_shared<rclcpp::Node>("MasterNode");

return 0;

I used both the test_multi_threaded_executor.cpp link text and not_composable.cpp link text as a reference.

So, My question is: Is there a way to force the node to shutdown. Or is there a reason why the node can still be seen using ros2 node list after being shutdown?

I am sorry about the Frankenstein code but, I am still figuring out a way to create multiple subscribers without using inheritance or member_function method. This is because the publishers and subscribers will be positioned in various parts of the code. The only way I could access the main node would be through header files, and saving the class object in a global variable and finding a way to spin the node using MultiThreadExecutor for the each subscribers callback was getting a bit complicated.

I am using Linux 18.04 with ROS Crystal Clemmys.

edit retag flag offensive reopen merge delete

Closed for the following reason duplicate question by Obeseturtle
close date 2019-02-17 20:28:23.768846


It would be nice to provide the link to the duplicated question.

hubacji1 gravatar image hubacji1  ( 2022-10-18 07:55:33 -0500 )edit