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 import sys
00035 from load_bag import BagLoader
00036 from timeseries import uniform_resample, quaternion_to_eulerypr
00037 import scipy.io as sio
00038 import numpy as np
00039
00040 in_bag, out_mat = sys.argv[1:3]
00041
00042 input_bag = BagLoader(in_bag)
00043
00044 quats = (input_bag.estimator_output_pose_pose_orientation_w,
00045 input_bag.estimator_output_pose_pose_orientation_x,
00046 input_bag.estimator_output_pose_pose_orientation_y,
00047 input_bag.estimator_output_pose_pose_orientation_z)
00048 yaw, pitch, roll = [np.degrees(x) for x in quaternion_to_eulerypr(quats)]
00049
00050 resample_inputs = (('linear',
00051 input_bag.estimator_output___header__time[1:],
00052 input_bag.estimator_output_pose_pose_position_x[1:],
00053 input_bag.estimator_output_pose_pose_position_y[1:],
00054 input_bag.estimator_output_pose_pose_position_z[1:],
00055 input_bag.estimator_output_twist_twist_linear_x[1:],
00056 input_bag.estimator_output_twist_twist_linear_y[1:],
00057 input_bag.estimator_output_twist_twist_linear_z[1:],
00058 ),
00059 ('zero',
00060 input_bag.estimator_output___header__time[1:],
00061 input_bag.estimator_output_pose_pose_orientation_w[1:],
00062 input_bag.estimator_output_pose_pose_orientation_x[1:],
00063 input_bag.estimator_output_pose_pose_orientation_y[1:],
00064 input_bag.estimator_output_pose_pose_orientation_z[1:],
00065 ),
00066 ('zero',
00067 input_bag.estimator_output___header__time[1:],
00068 yaw[1:],
00069 pitch[1:],
00070 roll[1:],
00071 ),
00072 ('linear',
00073 input_bag.asctec_imu___header__time[1:],
00074 input_bag.asctec_imu_angular__velocity_x[1:],
00075 input_bag.asctec_imu_angular__velocity_y[1:],
00076 input_bag.asctec_imu_angular__velocity_z[1:]
00077 ),
00078 ('zero',
00079 input_bag.controller__mux_output___header__time[1:],
00080 input_bag.controller__mux_output_yaw__cmd[1:],
00081 input_bag.controller__mux_output_pitch__cmd[1:],
00082 input_bag.controller__mux_output_roll__cmd[1:],
00083 input_bag.controller__mux_output_alt__cmd[1:]
00084 )
00085 )
00086
00087 t_out, resample_outputs = uniform_resample(resample_inputs, 0.02)
00088
00089 mdict = {'t': t_out,
00090
00091
00092 'x': resample_outputs[0][0],
00093 'y': resample_outputs[0][1],
00094 'z': resample_outputs[0][2],
00095 'vx': resample_outputs[0][3],
00096 'vy': resample_outputs[0][4],
00097 'vz': resample_outputs[0][5],
00098
00099 'qw': resample_outputs[1][0],
00100 'qx': resample_outputs[1][1],
00101 'qy': resample_outputs[1][2],
00102 'qz': resample_outputs[1][3],
00103
00104 'yaw': resample_outputs[2][0],
00105 'pitch': resample_outputs[2][1],
00106 'roll': resample_outputs[2][2],
00107
00108 'wx': resample_outputs[3][0],
00109 'wy': resample_outputs[3][1],
00110 'wz': resample_outputs[3][2],
00111
00112
00113 'u_yaw': resample_outputs[4][0],
00114 'u_pitch': resample_outputs[4][1],
00115 'u_roll': resample_outputs[4][2],
00116 'u_alt': resample_outputs[4][3],
00117 }
00118
00119 print "Saving %s..." % out_mat
00120 sio.savemat(out_mat, mdict, long_field_names=True)