예제 #1
0
    def process_observations(self, obs):
        if self.last_obs is not None:
            # t0 = self.last_obs['timestamp']
            # t1 = obs['timestamp']
            # delta = t1 - t0
            u = obs['commands']
            y0 = self.last_obs['observations']
            y1 = obs['observations']

            self.last_data = (y0, u, y1)
            # self.info('t0: %.3f t1: %.3f delta: %.3f u: %s' % (t0, t1, delta, u))
            if self.shape is not None:
                y0 = scipy_image_resample(y0, self.shape)
                y1 = scipy_image_resample(y1, self.shape)

            try:
                self.diffeosystem_estimator.update(y0=y0, u0=u, y1=y1)
            except DiffeoSystemEstimatorInterface.LearningConverged as e:
                msg = 'DiffeoSystem converged: %s' % str(e)
                raise PassiveAgentInterface.LearningConverged(msg)

        self.last_obs = obs
예제 #2
0
 def process_observations(self, obs):
     if self.last_obs is not None:
         # t0 = self.last_obs['timestamp']
         # t1 = obs['timestamp']
         # delta = t1 - t0
         u = obs['commands']
         y0 = self.last_obs['observations']
         y1 = obs['observations']
         
         self.last_data = (y0, u, y1)
         # self.info('t0: %.3f t1: %.3f delta: %.3f u: %s' % (t0, t1, delta, u))
         if self.shape is not None:
             y0 = scipy_image_resample(y0, self.shape)
             y1 = scipy_image_resample(y1, self.shape)
         
         try: 
             self.diffeosystem_estimator.update(y0=y0, u0=u, y1=y1)
         except DiffeoSystemEstimatorInterface.LearningConverged as e:
             msg = 'DiffeoSystem converged: %s' % str(e)
             raise PassiveAgentInterface.LearningConverged(msg)
     
     self.last_obs = obs
예제 #3
0
    def read_all(self):
        data_central = DataCentral(self.boot_root)
        log_index = data_central.get_log_index()
        observations = log_index.read_all_robot_streams(id_robot=self.id_robot)
        pairs = pairwise(observations)
        i = 0
        for bd1, bd2 in pairs:
            
            i += 1
            if i % 100 == 1:
                print('read %d' % i)
            y0 = bd1['observations']
            y1 = bd2['observations']
            u = bd1['commands']
            
            if self.shape is not None:
                y0 = scipy_image_resample(y0, self.shape, order=0)
                np.clip(y0, 0, 1, y0)

                y1 = scipy_image_resample(y1, self.shape, order=0)
                np.clip(y1, 0, 1, y1)
                
            log_item = LogItem(y0=y0, y1=y1, u=u, x0=None)
            yield log_item