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 import hrl_lib.util as ut
00033 import matplotlib_util.util as mpu
00034 import math, numpy as np
00035 import sys
00036
00037 def plot_workspace(pts,ha,z):
00038 if pts.shape[1] == 0:
00039 return
00040 mpu.figure()
00041 good_location = pts.mean(1)
00042 mpu.plot_yx(pts[1,:].A1,pts[0,:].A1,label='ha:%.1f'%(math.degrees(ha)),
00043 axis='equal',linewidth=0)
00044 mpu.plot_yx(good_location[1,:].A1,good_location[0,:].A1,
00045 axis='equal',linewidth=0,scatter_size=90,color='k')
00046 mpu.savefig('z%.2f_ha%.1f.png'%(z,math.degrees(ha)))
00047
00048 argv = sys.argv
00049 fname = sys.argv[1]
00050 dd = ut.load_pickle(fname)
00051
00052 color_list = ['b','y','g']
00053 i = 0
00054 mpu.figure(dpi=100)
00055 for ha in dd.keys():
00056 d = dd[ha]
00057 l = []
00058 key_list = d['pts'].keys()
00059 for k in key_list:
00060 pts = d['pts'][k]
00061 l.append(pts.shape[1])
00062
00063
00064 ll = zip(key_list,l)
00065 ll.sort()
00066
00067 key_list,l = zip(*ll)
00068 if ha == 0:
00069 label = 'Hook Left'
00070 elif abs(ha-math.pi/2) < 0.01:
00071 label = 'Hook Down'
00072 continue
00073 else:
00074 label = 'Hook Up'
00075
00076 mpu.plot_yx(key_list,l,axis=None,label=label, color=color_list[i],
00077 xlabel='\# of points with IK soln',
00078 ylabel='Height (m)', scatter_size=8)
00079 i += 1
00080 max_idx = np.argmax(l)
00081 good_height = key_list[max_idx]
00082 print 'good_height:', good_height
00083
00084 mpu.plot_yx([good_height],[l[max_idx]],axis=None,
00085 color='r', xlabel='\# of points with IK soln',
00086 ylabel='Height (m)', scatter_size=8)
00087 d['height'] = good_height
00088
00089
00090
00091
00092
00093
00094
00095