ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
I think it's a known problem. The thing is that when you create a publisher, it's not connect yet to ROS master server. That's why you are not able to publish the message. You can try to "sleep" for a while, like 1~5 seconds, and the publisher will be connected.
If you need to publish something just once, I'd recommend you to use a ROS service.
You can check other related questions: