Go to the documentation of this file.00001
00002 import roslib; roslib.load_manifest('axis_camera')
00003 import rospy
00004 import math
00005 from axis_camera.msg import Axis
00006 import tf
00007 from tf.transformations import quaternion_from_euler
00008
00009 base_name = "/kingfisher"
00010 base_frame = "/kingfisher/base"
00011 broadcaster = tf.TransformBroadcaster()
00012
00013 def axis_cb(data):
00014 global broadcaster, base_frame, base_name
00015 pan = math.pi + data.pan * math.pi / 180.
00016 tilt = -data.tilt * math.pi / 180.
00017 q = quaternion_from_euler(0,0,pan)
00018 now = rospy.Time.now()
00019 broadcaster.sendTransform((0,0,0),
00020 q,now,base_name+"/pan",base_frame)
00021 q = quaternion_from_euler(0,tilt,0)
00022 broadcaster.sendTransform((0,0,0),
00023 q,now,base_name+"/tilt",base_name+"/pan")
00024
00025
00026 if __name__ == '__main__':
00027 try:
00028 rospy.init_node("axis_tf_broadcaster")
00029 base_frame = rospy.get_param("~base_frame",base_frame)
00030 base_name = rospy.get_param("~base_name",base_name)
00031 axis_sub = rospy.Subscriber("/axis/state",Axis,axis_cb)
00032 rospy.loginfo("Started Axis TF broadcaster")
00033 rospy.spin()
00034 except rospy.ROSInterruptException:
00035 pass