all_sim_capture.py
Go to the documentation of this file.
00001 import numpy as np,math
00002 import sim_capture
00003 import glob
00004 import pickle as pkl
00005 import time
00006 
00007 class request():
00008     def __init__( self, x, y, ang ):
00009         self.x = x
00010         self.y = y
00011         self.z = 0
00012         self.ang = ang
00013 
00014 def has_item( lst, item ):
00015     try:
00016         lst.index( item )
00017         return True
00018     except:
00019         return False
00020     
00021 
00022 X,Y = np.meshgrid( range(0,11), range(0,7) )
00023 xy = np.column_stack([ X.flatten(), Y.flatten() ]).tolist()
00024 xy.remove( [7,3] )
00025 xy.remove( [6,3] )
00026 
00027 d_func = lambda lst: ( lst[0] - 7 )**2 + ( lst[1] - 3 )**2
00028 cmp_func = lambda x,y : cmp(d_func(x),d_func(y))
00029 xy.sort( cmp=cmp_func )
00030 
00031 xya = []
00032 for ang in [ math.radians(p) for p in [0.0, 90.0, 180.0, 270.0]]:
00033     for x,y in xy:
00034         xya.append( [x,y,ang] )
00035 
00036 if not glob.glob( 'trajectory_caps/resutls.pkl' ):
00037     print 'Creating pickle file'
00038     d = { 'desired_pts': xya,
00039           'capture_pts': [],
00040           'captures': []
00041           }
00042     f = open( 'trajectory_caps/resutls.pkl', 'w' )
00043     pkl.dump( d, f )
00044     f.close()
00045 
00046 
00047 f = open( 'trajectory_caps/resutls.pkl', 'r' )
00048 d = pkl.load( f )
00049 f.close()
00050 
00051 remaining = [ x for x in d['desired_pts'] if not has_item( d['capture_pts'], x )]
00052 print 'Remaining to capture: %d' % len( remaining )
00053 
00054 sc = sim_capture.SimCapture()
00055 
00056 for x,y,ang in remaining:
00057     fname = 'trajectory_caps/' + str(int(time.time())) + '_cap.pkl'
00058     sc.capture( request( x, y, ang ), fname )
00059     d[ 'capture_pts' ].append( [x,y,ang] )
00060     d[ 'captures' ].append( [x,y,ang,fname] )
00061     
00062     f = open( 'trajectory_caps/resutls.pkl', 'w' )
00063     pkl.dump( d, f )
00064     f.close()
00065     
00066 
00067 


rfid_people_following
Author(s): Travis Deyle (Healthcare Robotics Lab, Georgia Tech)
autogenerated on Wed Nov 27 2013 11:38:30