ravens/agents/gt_state.py
def act(self, obs, info, goal=None):
        """Run inference and return best action."""
        act = {'camera_config': self.camera_config, 'primitive': None}

        # Get observations and run predictions (second part just for visualization).
        if self.goal_conditioned:
            gt_obs = self.info_to_gt_obs(info, goal=goal)
            gt_act_center = self.info_to_gt_obs(info, goal=goal)
        else:
            gt_obs = self.info_to_gt_obs(info)
            gt_act_center = self.info_to_gt_obs(info)

        prediction = self.model(gt_obs[None, ...])

        if self.USE_MDN:
            mdn_prediction = prediction
            pi, mu, var = mdn_prediction
            #prediction = mdn_utils.pick_max_mean(pi, mu, var)
            prediction = mdn_utils.sample_from_pdf(pi, mu, var)
            prediction = prediction[:, 0, :]

        prediction = prediction[0] # unbatch

        # Just go exactly to objects, predicted. Daniel: adding 1 rotation inference case.
        p0_position = np.hstack((prediction[0:2], 0.02))
        p0_pred_rot = 0.0 if self.one_rot_inf else -prediction[2]*self.THETA_SCALE  # idx 2
        p0_rotation = utils.get_pybullet_quaternion_from_rot((0, 0, p0_pred_rot))
        p1_position = np.hstack((prediction[3:5], 0.02))
        p1_pred_rot = 0.0 if self.one_rot_inf else -prediction[5]*self.THETA_SCALE  # idx 5
        p1_rotation = utils.get_pybullet_quaternion_from_rot((0, 0, p1_pred_rot))

        # Select task-specific motion primitive.
        act['primitive'] = 'pick_place'
        if self.task == 'sweeping':
            act['primitive'] = 'sweep'
        elif self.task == 'pushing':
            act['primitive'] = 'push'
        params = {'pose0': (p0_position, p0_rotation),
                  'pose1': (p1_position, p1_rotation)}
        act['params'] = params

        # Daniel: like transporters, determine the task stage if applicable. (AND if loading only)
        if self.task in ['bag-items-easy', 'bag-items-hard', 'bag-color-goal']:
            self._determine_task_stage(p0_position, p1_position)

        return act
Run inference and return best action.
Run inference and return best action.
Run inference and return best action .
def act(self, obs, info, goal=None):
        act = {'camera_config': self.camera_config, 'primitive': None}
        if self.goal_conditioned:
            gt_obs = self.info_to_gt_obs(info, goal=goal)
            gt_act_center = self.info_to_gt_obs(info, goal=goal)
        else:
            gt_obs = self.info_to_gt_obs(info)
            gt_act_center = self.info_to_gt_obs(info)
        prediction = self.model(gt_obs[None, ...])
        if self.USE_MDN:
            mdn_prediction = prediction
            pi, mu, var = mdn_prediction
            prediction = mdn_utils.sample_from_pdf(pi, mu, var)
            prediction = prediction[:, 0, :]
        prediction = prediction[0] 
        p0_position = np.hstack((prediction[0:2], 0.02))
        p0_pred_rot = 0.0 if self.one_rot_inf else -prediction[2]*self.THETA_SCALE  
        p0_rotation = utils.get_pybullet_quaternion_from_rot((0, 0, p0_pred_rot))
        p1_position = np.hstack((prediction[3:5], 0.02))
        p1_pred_rot = 0.0 if self.one_rot_inf else -prediction[5]*self.THETA_SCALE  
        p1_rotation = utils.get_pybullet_quaternion_from_rot((0, 0, p1_pred_rot))
        act['primitive'] = 'pick_place'
        if self.task == 'sweeping':
            act['primitive'] = 'sweep'
        elif self.task == 'pushing':
            act['primitive'] = 'push'
        params = {'pose0': (p0_position, p0_rotation),
                  'pose1': (p1_position, p1_rotation)}
        act['params'] = params
        if self.task in ['bag-items-easy', 'bag-items-hard', 'bag-color-goal']:
            self._determine_task_stage(p0_position, p1_position)
        return act
def act ( self , obs , info , goal = None ) : act = { 'camera_config' : self . camera_config , 'primitive' : None } if self . goal_conditioned : gt_obs = self . info_to_gt_obs ( info , goal = goal ) gt_act_center = self . info_to_gt_obs ( info , goal = goal ) else : gt_obs = self . info_to_gt_obs ( info ) gt_act_center = self . info_to_gt_obs ( info ) prediction = self . model ( gt_obs [ None , ... ] ) if self . USE_MDN : mdn_prediction = prediction pi , mu , var = mdn_prediction prediction = mdn_utils . sample_from_pdf ( pi , mu , var ) prediction = prediction [ : , 0 , : ] prediction = prediction [ 0 ] p0_position = np . hstack ( ( prediction [ 0 : 2 ] , 0.02 ) ) p0_pred_rot = 0.0 if self . one_rot_inf else - prediction [ 2 ] * self . THETA_SCALE p0_rotation = utils . get_pybullet_quaternion_from_rot ( ( 0 , 0 , p0_pred_rot ) ) p1_position = np . hstack ( ( prediction [ 3 : 5 ] , 0.02 ) ) p1_pred_rot = 0.0 if self . one_rot_inf else - prediction [ 5 ] * self . THETA_SCALE p1_rotation = utils . get_pybullet_quaternion_from_rot ( ( 0 , 0 , p1_pred_rot ) ) act [ 'primitive' ] = 'pick_place' if self . task == 'sweeping' : act [ 'primitive' ] = 'sweep' elif self . task == 'pushing' : act [ 'primitive' ] = 'push' params = { 'pose0' : ( p0_position , p0_rotation ) , 'pose1' : ( p1_position , p1_rotation ) } act [ 'params' ] = params if self . task in [ 'bag-items-easy' , 'bag-items-hard' , 'bag-color-goal' ] : self . _determine_task_stage ( p0_position , p1_position ) return act
Run inference and return best action.
Run inference and return best action .
"""Run inference and return best action.""" # Get observations and run predictions (second part just for visualization). #prediction = mdn_utils.pick_max_mean(pi, mu, var) # unbatch # Just go exactly to objects, predicted. Daniel: adding 1 rotation inference case. # idx 2 # idx 5 # Select task-specific motion primitive. # Daniel: like transporters, determine the task stage if applicable. (AND if loading only)
self
obs
info
goal