workspace_selector.py
Go to the documentation of this file.
00001 #
00002 #
00003 # Copyright (c) 2010, Georgia Tech Research Corporation
00004 # All rights reserved.
00005 # 
00006 # Redistribution and use in source and binary forms, with or without
00007 # modification, are permitted provided that the following conditions are met:
00008 #     * Redistributions of source code must retain the above copyright
00009 #       notice, this list of conditions and the following disclaimer.
00010 #     * Redistributions in binary form must reproduce the above copyright
00011 #       notice, this list of conditions and the following disclaimer in the
00012 #       documentation and/or other materials provided with the distribution.
00013 #     * Neither the name of the Georgia Tech Research Corporation nor the
00014 #       names of its contributors may be used to endorse or promote products
00015 #       derived from this software without specific prior written permission.
00016 # 
00017 # THIS SOFTWARE IS PROVIDED BY GEORGIA TECH RESEARCH CORPORATION ''AS IS'' AND
00018 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00019 # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00020 # DISCLAIMED. IN NO EVENT SHALL GEORGIA TECH BE LIABLE FOR ANY DIRECT, INDIRECT,
00021 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00022 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
00023 # OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00024 # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
00025 # OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
00026 # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00027 #
00028 
00029 # \author Advait Jain (Healthcare Robotics Lab, Georgia Tech.)
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         #plot_workspace(pts,ha,k)
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 #ut.save_pickle(dd,fname)
00091 #mpu.legend()
00092 #mpu.savefig('workspace_npts.png')
00093 #mpu.show()
00094 
00095 


2010_icra_epc_pull
Author(s): Advait Jain, Charles C. Kemp (Healthcare Robotics Lab, Georgia Tech)
autogenerated on Wed Nov 27 2013 12:14:43