Hey all,
I'm not quite sure if this is a bug, or if it is, where to file it,
but it took me forever to track down the problem.
Here's my test program based on rospy tutorials. (I'm using C-Turtle
binaries on 10.04)
#!/usr/bin/python
import roslib; roslib.load_manifest('crazy')
import rospy
from std_msgs.msg import String
def talker():
pub = rospy.Publisher('chatter', String)
rospy.init_node('talker', anonymous=True)
str = "hello world"
pub.publish(str)
if __name__ == '__main__':
try:
talker()
except rospy.ROSInterruptException: pass
Fairly standard, and it works like you would expect. However, if you
switch the order of 7th and 8th lines, i.e.
rospy.init_node('talker', anonymous=True)
pub = rospy.Publisher('chatter', String)
...it does NOT publish the message.
However, when I add a sleep(1) command after Publisher line, then it
works fine.
Is this...
A) A bug
B) A situation where I should just sleep
C) A situation where I should publish the message repeatedly until I'm
sure it's received.
Thanks,
-David!!