编写一个发布器和接收器(python) 12345678910111213141516171819202122232425#!/usr/bin/env pythonimport rospyfrom std_msgs.msg import Stringdef talker(): rospy.init_node('talker',anonymous=True) pub = rospy.Publisher('chatter', String, queue_size=10) rate = rospy.Rate(10) while not rospy.is_shutdown(): hello_str ="hello world %s" % rospy.get_time() rospy.loginfo(hello_str) pub.publish(hello_str) rate.sleep()if __name__ == '__main__ ': try: talker() except rospy.ROSInterruptException: pass