Go to the documentation of this file.00001
00002
00003 import rospy
00004 import tf
00005 from geometry_msgs.msg import PointStamped, TransformStamped, PoseStamped
00006 from crazyflie_driver.srv import UpdateParams
00007
00008 def onNewTransform(pose):
00009 global msg
00010 global pub
00011 global firstTransform
00012
00013 if firstTransform:
00014
00015 rospy.set_param("kalman/initialX", pose.pose.position.x)
00016 rospy.set_param("kalman/initialY", pose.pose.position.y)
00017 rospy.set_param("kalman/initialZ", pose.pose.position.z)
00018 update_params(["kalman/initialX", "kalman/initialY", "kalman/initialZ"])
00019
00020 rospy.set_param("kalman/resetEstimation", 1)
00021 update_params(["kalman/resetEstimation"])
00022 firstTransform = False
00023
00024 else:
00025 msg.header.frame_id = pose.header.frame_id
00026 msg.header.stamp = pose.header.stamp
00027 msg.header.seq += 1
00028 msg.point.x = pose.pose.position.x
00029 msg.point.y = pose.pose.position.y
00030 msg.point.z = pose.pose.position.z
00031 pub.publish(msg)
00032
00033
00034 if __name__ == '__main__':
00035 rospy.init_node('publish_external_position_vrpn', anonymous=True)
00036 topic = rospy.get_param("~topic", "/crazyflie1/vrpn_client_node/crazyflie1/pose")
00037
00038 rospy.wait_for_service('update_params')
00039 rospy.loginfo("found update_params service")
00040 update_params = rospy.ServiceProxy('update_params', UpdateParams)
00041
00042 firstTransform = True
00043
00044 msg = PointStamped()
00045 msg.header.seq = 0
00046 msg.header.stamp = rospy.Time.now()
00047
00048 pub = rospy.Publisher("external_position", PointStamped, queue_size=1)
00049 rospy.Subscriber(topic, PoseStamped, onNewTransform)
00050
00051 rospy.spin()