Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
import rospy
rospy.init_node('node_name')
from std_msgs.msg import String
def callback(data):
rospy.loginfo("I heard %s", data.data)
def callback2(data):
rospy.loginfo("222I heard %s", data.data)
for t in ['foo', 'bar']:
if t =='foo':
rospy.Subscriber(t, String, callback)
if t =='bar':
rospy.Subscriber(t, String, callback2)
rospy.spin()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment