ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
The hint from @NEngelhard was correct, using the option latch=True results in what I had expected before. Thanks a lot!
import rospy
from std_msgs.msg import String
def callback(data):
rospy.loginfo("I heard %s",data.data)
rospy.init_node('node_name')
pub = rospy.Publisher('topic_name', String, queue_size=10, latch=True) # working as expected
#pub = rospy.Publisher('topic_name', String, queue_size=10) # not working as expected
sub = rospy.Subscriber("topic_name", String, callback)
pub.publish("no delay")
rospy.sleep(1)
pub.publish("with delay")
rospy.spin()