ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
The trouble here is that you don't have a persistent NodeHandle throughout the scope of your program.
As explained on the NodeHandle wiki page, once all NodeHandles go out of scope, the internal node is shut down.
Private NodeHandles with limited scope are generally a good idea, but you should also maintain a NodeHandle (public or private) that lasts for the entire duration of your program.