ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
Well, yes, the code above should run. The error is in how the other code that you don't show is structured. If you want more detailed help, you need to come up with a complete minimal example.
The only guess I have from your description is that you are running the spin loop above in the constructor. This will mean that your object is actually NEVER constructed as the constructor can't finish. I have never tried what would happen in such a case, but that would be the first thing to change.