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
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 import tf.transformations as tft
00036 import numpy as np
00037 r = Rate(50)
00038 dummy_msg = msg.geometry_msgs.TransformStamped()
00039 dummy_msg.transform.rotation.w = 1.0
00040 dummy_msg.header.frame_id = '/enu'
00041 dummy_msg.child_frame_id = '/pelican1/flyer_vicon'
00042 tfl=transforms._config.listener
00043 while (True):
00044 dummy_msg.header.stamp = now()
00045 try:
00046 t_imu_vicon, q_imu_vicon = tfl.lookupTransform('/pelican1/flyer_imu','/pelican1/flyer_vicon',now())
00047 T_imu_vicon = np.dot(tft.translation_matrix(t_imu_vicon),tft.quaternion_matrix(q_imu_vicon))
00048 except:
00049 loginfo('exception trying to get vicon-imu')
00050 try:
00051 latest_autosequence_info = topics.pelican1.control_mode_autosequence.info[0]
00052 if latest_autosequence_info is not None:
00053
00054 T_ned_imu_norot = tft.translation_matrix([latest_autosequence_info.north_cmd,
00055 latest_autosequence_info.east_cmd,0])
00056 T_ned_imu = np.dot(T_ned_imu_norot,tft.quaternion_matrix(tft.quaternion_from_euler(np.radians(latest_autosequence_info.yaw_cmd), 0, 0, 'rzyx')))
00057 T_enu_ned = tft.euler_matrix(np.radians(180),0,np.radians(-90),'rxyz')
00058 T_enu_imu = np.dot(T_enu_ned, T_ned_imu)
00059 T_enu_vicon = np.dot(T_enu_imu,T_imu_vicon)
00060 q = tft.quaternion_from_matrix(T_enu_vicon)
00061 dummy_msg.transform.translation.x = T_enu_vicon[0,3]
00062 dummy_msg.transform.translation.y = T_enu_vicon[1,3]
00063
00064 dummy_msg.transform.rotation.x = q[0]
00065 dummy_msg.transform.rotation.y = q[1]
00066 dummy_msg.transform.rotation.z = q[2]
00067 dummy_msg.transform.rotation.w = q[3]
00068 except:
00069 loginfo('exception 2')
00070
00071 topics['/pelican1/vicon_recv_direct/output'](dummy_msg)
00072 r.sleep()