ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Yes this will work. You can create nodehandles anywhere in your process after ros::init. After ros::spin() has finished, your class instance goes out of scope, thereby its destructor (possibly implicitly created by compiler) is called. It will also destruct your member NodeHandle and thereby shutdown subscribers.