38 NAME =
'talker_callback' 47 print(
"a peer subscribed to topic [%s]" % topic_name)
49 str =
"Hey everyone, we have a new friend!" 51 topic_publish(String(str))
52 str =
"greetings. welcome to topic "+topic_name
54 peer_publish(String(str))
57 print(
"a peer unsubscribed from topic [%s]" % topic_name)
59 print(
"I have no friends")
62 pub = rospy.Publisher(
"chatter", String, subscriber_listener=
ChatterListener(), queue_size=10)
63 rospy.init_node(NAME, anonymous=
True)
65 while not rospy.is_shutdown():
66 str =
"hello world %d"%count
68 pub.publish(String(str))
72 if __name__ ==
'__main__':
75 except rospy.ROSInterruptException:
pass
def peer_unsubscribe(self, topic_name, numPeers)
def peer_subscribe(self, topic_name, topic_publish, peer_publish)