ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
Don't move init_node as you suggest. The problem with your first code snippet is that you publish one single message and then exit. This means your publisher is destroyed immediately and no other nodes gets the chance of subscribing before it is too late.
Put the publish line inside a loop as the tutorials show.