Go to the documentation of this file.00001
00002 import math, numpy as np
00003 import glob
00004 import sys, time
00005 sys.path.append('../handheld_hook/')
00006
00007 import analyse_logs as al
00008 import matplotlib_util.util as mpu
00009 import hrl_lib.util as ut
00010
00011 if __name__ == '__main__':
00012
00013 import optparse
00014 p = optparse.OptionParser()
00015 p.add_option('-d', '--dir', action='store', default='',
00016 type='string', dest='dir', help='directory with logged data')
00017 opt, args = p.parse_args()
00018
00019 ft_pkl = glob.glob(opt.dir + '/ft_log*.pkl')[0]
00020 poses_pkl = glob.glob(opt.dir + '/poses_dict*.pkl')[0]
00021
00022 ft_dict = ut.load_pickle(ft_pkl)
00023 poses_dict = ut.load_pickle(poses_pkl)
00024 mechanism_dict = poses_dict['mechanism']
00025 hand_dict = poses_dict['hand']
00026
00027 ft_time_list = ft_dict['time_list']
00028 mechanism_dict['time_list'] = ft_time_list
00029 hand_dict['time_list'] = ft_time_list
00030
00031
00032 print 'Begin synchronize'
00033 d = al.synchronize(ft_dict, mechanism_dict, hand_dict)
00034 print 'End synchronize'
00035
00036 ut.save_pickle(d, opt.dir+'/combined_log.pkl')
00037 print 'Saved pickle'
00038
00039
00040 pkl_name = glob.glob(opt.dir + '/combined_log*.pkl')[0]
00041 mech_pkl_name = glob.glob(opt.dir + '/mechanism_info*.pkl')[0]
00042
00043 md = ut.load_pickle(mech_pkl_name)
00044 cd = ut.load_pickle(pkl_name)
00045 cd['hook_checker_number'] = md['checkerboard_number']
00046 cd['radius'] = md['radius']
00047 rad, tan, ang, typ = al.compute_mechanism_properties(cd)
00048 rad, tan_b, ang, typ = al.compute_mechanism_properties(cd,
00049 bias_ft=True)
00050
00051
00052 spring_pkl = glob.glob(opt.dir+'/spring_scale*.pkl')[0]
00053 spring_list = ut.load_pickle(spring_pkl)
00054
00055 mpu.plot_yx(spring_list, label='Spring Scale', color='b', axis=None)
00056
00057 mpu.plot_yx(rad, label='Measured Radial force (unbiased)', color='r',
00058 xlabel='Reading number', ylabel='Force (N)', axis=None)
00059
00060 mpu.plot_yx(tan, label='Measured Tangential force (unbiased)', color='g',
00061 xlabel='Reading number', ylabel='Force (N)', axis=None)
00062 mpu.plot_yx(tan_b, label='Measured Tangential force (biased)', color='y',
00063 xlabel='Reading number', ylabel='Force (N)',
00064 axis=None, plot_title=opt.dir)
00065
00066 mpu.legend()
00067 mpu.savefig(opt.dir.split('/')[0]+'.png')
00068 mpu.show()
00069
00070
00071
00072
00073