Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 """
00020 This is a simple subscriber example, subscribing to the srh/shadowhand_data topic
00021 """
00022
00023 import roslib; roslib.load_manifest('sr_hand')
00024 import rospy
00025 from sr_robot_msgs.msg import joints_data, joint
00026
00027 def callback(joint_data):
00028 """
00029 The callback function for the topic srh/shadowhand_Data. It just displays the received information on the console.
00030
00031 @param joint_data: the message containing the joint data.
00032 """
00033 for joint in joint_data.joints_list:
00034 rospy.loginfo(rospy.get_name()+"[%s] : Pos = %f | Target = %f | Temp = %f | Current = %f",
00035 joint.joint_name, joint.joint_position, joint.joint_target, joint.joint_temperature,
00036 joint.joint_current)
00037
00038 def listener():
00039 """
00040 Initialize the ROS node and the topic to which it subscribes.
00041 """
00042 rospy.init_node('shadowhand_subscriber_python', anonymous=True)
00043 rospy.Subscriber("srh/shadowhand_data", joints_data, callback)
00044 rospy.spin()
00045
00046 if __name__ == '__main__':
00047 listener()