[ros2] shutdown [closed]
Hi,
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");
rclcpp::shutdown();
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.
It would be nice to provide the link to the duplicated question.