// it's for Latex

pages

[ROS] How to import and use Custom Message Subscriber in Python

#from MsgCenter.msg import *from opencv.msg import MsgAngle
from opencv.msg import MsgCenter

## END_SUB_TUTORIAL
def callback_angle(angle):
  rospy.loginfo(rospy.get_caller_id() + "I heard %f", angle.angle)

def callback_center(center):
  rospy.loginfo(rospy.get_caller_id() + "I heard %f, %f", center.x, center.y)

def listener():
  # In ROS, nodes are uniquely named. If two nodes with the same  # name are launched, the previous one is kicked off. The  # anonymous=True flag means that rospy will choose a unique  # name for our 'listener' node so that multiple listeners can  # run simultaneously.  #rospy.init_node('listener', anonymous=True)
  rospy.Subscriber("angle", MsgAngle, callback_angle)
  rospy.Subscriber("center", MsgCenter, callback_center)

  # spin() simply keeps python from exiting until this node is stopped  rospy.spin()

댓글 없음:

댓글 쓰기