Skip to content

Instantly share code, notes, and snippets.

@tfoote
Created November 27, 2017 07:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tfoote/496139213ff8904fc00c65274e3fdd81 to your computer and use it in GitHub Desktop.
Save tfoote/496139213ff8904fc00c65274e3fdd81 to your computer and use it in GitHub Desktop.
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