With rospy, messages don't seem to be recieved if published soon after creating the publisher
I've got an app like this:
#!/usr/bin/env python
PKG_NAME = 'straight'
import roslib; roslib.load_manifest(PKG_NAME)
import rospy
from std_msgs.msg import String
if __name__ == '__main__':
rospy.init_node("test")
speakPub = rospy.Publisher('/testing', String)
speakPub.publish(String("Hello World"))
And that message never seems to get received anywhere (my other node listening for it, or the rostopic echo i have running on another terminal). However, if I add rospy.sleep(1) between creating the publisher and using it, then the message gets through.
Am I doing something wrong? Do I need to wait between creating the publisher and using it?