def perfrom_experiment(self, experiment_name='test', movement_list=[]): # 1. We save the background image: dc = DataCollector(only_one_shot=False, automatic=True) dc.get_data(get_cart=False, get_gs1=(1 in self.gs_id), get_gs2=(2 in self.gs_id), get_wsg=False, save=True, directory=experiment_name+'/air', iteration=-1) print "Air data gathered" # 2. We perfomr the experiment: i = 0 if not os.path.exists(experiment_name): # If the directory does not exist, we create it os.makedirs(experiment_name) for movement in movement_list: path = experiment_name + '/p_' + str(i) + '/' self.palpate(speed=40, force_list=self.force_list, save=True, path=path) self.move_cart_mm(movement[0], movement[1], movement[2]) time.sleep(6) i += 1 path = experiment_name + '/p_' + str(i) + '/' self.palpate(speed=40, force_list=self.force_list, save=True, path=path)
def palpate(self, speed=40, force_list=[1, 10, 20, 40], save=False, path=''): # 0. We create the directory if save is True and not os.path.exists(path): # If the directory does not exist, we create it os.makedirs(path) # 1. We get and save the cartesian coord. dc = DataCollector(only_one_shot=False, automatic=True) cart = dc.getCart() if save is True: np.save(path + '/cart.npy', cart) # 2. We get wsg forces and gs images at every set force and store them i = 0 for force in force_list: self.close_gripper_f(grasp_speed=speed, grasp_force=force) print "Applying: " + str(force) time.sleep(1.0) dc.get_data(get_cart=False, get_gs1=(1 in self.gs_id), get_gs2=(2 in self.gs_id), get_wsg=True, save=save, directory=path, iteration=i) self.open_gripper() time.sleep(1.0) i += 1