예제 #1
0
    def calculate_pose(self, action: Action,
                       images: List[OrthographicImage]) -> None:
        if action.type == 'grasp':
            self.grasp_convert(action, images)
            is_safe = self.grasp_check_safety(action, images)

        elif action.type == 'shift':
            self.shift_convert(action, images)
            is_safe = self.shift_check_safety(action, images)

        elif action.type == 'place':
            self.place_convert(action, images)
            is_safe = self.place_check_safety(action, images)

        else:
            raise Exception('Unknown action type f{action.type}.')

        if not self.action_should_be_safe:
            is_safe = True

        if not is_safe:
            action.safe = -1
        elif not np.isfinite(action.pose.translation()).all():
            action.safe = 0
        else:
            action.safe = 1
예제 #2
0
    def calculate_pose(self, action: Action,
                       images: List[OrthographicImage]) -> None:
        if action.type == 'grasp':
            self.grasp_convert(action, images)
            is_safe = self.grasp_check_safety(action, images)

        elif action.type == 'shift':
            self.shift_convert(action, images)
            is_safe = self.shift_check_safety(action, images)

        elif action.type == 'place':
            self.place_convert(action, images)
            is_safe = self.place_check_safety(action, images)

        if not self.action_should_be_safe:
            is_safe = True

        if is_safe and np.isfinite(action.pose.translation()).all():
            action.safe = 1
        elif not is_safe:
            logger.warning('Action is not safe (probably not within box).')
            action.safe = -1
        else:
            action.safe = 0