Regarding destroy_node()

Hi,

I see in the instructions, that sometimes they use node.destroy_node(), sometimes they do not use

So, When do I need to use node.destroy_node()

Thanks

Hi @NguyenDuyDuc ,

The node.destroy_node() function is only specific to python scripts and not used for C++.
This is partially based on the fact that C++ has more organised way of destroying classes, but python does not.
So, when you are using python scripting for ROS2, it is always best to implement the node.destroy_node() function, when you are done with the node.

It is always best to implement this function call before your call ROS2 shutdown().

But in some cases, it may not be required as it is understood. This is specifically in the case where you have just one node in your program (python script) and you are executing the program just once and not multiple times (that is when you don’t have any callback(s) running continuously).

I hope this clarifies your doubt.

Regards,
Girish

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.