create_workspace_dict.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 mekabot.hrl_robot as hr
00033 import hrl_lib.util as ut, hrl_lib.transforms as tr
00034 
00035 import math, numpy as np
00036 import copy
00037 
00038 import sys
00039 sys.path.append('../')
00040 import compliant_trajectories as ct
00041 import segway_motion_calc as smc
00042 
00043 
00044 def compute_workspace(z, hook_angle):
00045     firenze = hr.M3HrlRobot(connect=False)
00046     rot_mat = tr.Rz(hook_angle)*tr.Rx(math.radians(0))*tr.Ry(math.radians(-90))
00047     delta_list = [math.radians(d) for d in [0.,0.,0.,0.,10.,10.,10.]]
00048     x_list,y_list = [],[]
00049     if z < -0.4:
00050         xmin = 0.10
00051         xmax = 0.65
00052     else:
00053         xmin = 0.15
00054         xmax = 0.65
00055 
00056     for x in np.arange(xmin,xmax,.01):
00057         for y in np.arange(-0.1,-0.50,-0.01):
00058             if x<0.3 and y>-0.2:
00059                 continue
00060             q = firenze.IK('right_arm',np.matrix([x,y,z]).T,rot_mat)
00061             if q != None and firenze.within_physical_limits_right(q,delta_list)==True:
00062                 x_list.append(x)
00063                 y_list.append(y)
00064     return np.matrix([x_list,y_list])
00065 
00066 def create_workspace_dict():
00067     dd = {}
00068     ha_list = [math.radians(d) for d in [0.,90.,-90.]]
00069     for ha in ha_list:
00070         d = {}
00071         for z in np.arange(-0.1,-0.55,-0.01):
00072             print 'z:',z
00073             pts2d = compute_workspace(z,hook_angle=ha)
00074             d[z] = pts2d
00075         dd[ha] = {}
00076         dd[ha]['pts'] = d
00077 
00078     ut.save_pickle(dd,'workspace_dict_'+ut.formatted_time()+'.pkl')
00079 
00080 
00081 def create_workspace_boundary(pkl_name):
00082     dd = ut.load_pickle(pkl_name)
00083     for ha in dd.keys():
00084         pts_dict = dd[ha]['pts']
00085         bndry_dict = {}
00086         for z in pts_dict.keys():
00087             print 'z:',z
00088             wrkspc = pts_dict[z]
00089             if wrkspc.shape[1] < 100:
00090                 pts_dict.pop(z)
00091                 continue
00092             bndry = smc.compute_boundary(wrkspc)
00093             bndry_dict[z] = bndry
00094         dd[ha]['bndry'] = bndry_dict
00095     ut.save_pickle(dd, pkl_name)
00096 
00097 
00098 
00099 create_workspace_dict()
00100 
00101 #if len(sys.argv) != 2:
00102 #    print 'Usage:', sys.argv[0], '<wrkspc dict pkl>'
00103 #    print 'Exiting ...'
00104 #    sys.exit()
00105 #create_workspace_boundary(sys.argv[1])
00106 
00107 
00108 


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