def reset(self):
        # reset simulation
        del self.platform

        # initialize simulation
        initial_robot_position = (
            TriFingerPlatform.spaces.robot_position.default)
        initial_object_pose = self.initializer.get_initial_state()
        goal_object_pose = self.initializer.get_goal()

        self.platform = TriFingerPlatform(
            visualization=self.visualization,
            initial_robot_position=initial_robot_position,
            initial_object_pose=initial_object_pose,
        )

        self.goal = {
            "position": goal_object_pose.position,
            "orientation": goal_object_pose.orientation,
        }

        # visualize the goal
        if self.visualization:
            self.goal_marker = visual_objects.CubeMarker(
                width=0.065,
                position=goal_object_pose.position,
                orientation=goal_object_pose.orientation,
                physicsClientId=self.platform.simfinger._pybullet_client_id,
            )

        self.info = {"difficulty": self.initializer.difficulty}

        self.step_count = 0

        return self.goal_observation(self._create_observation(0))
Beispiel #2
0
    def reset(self):
        # reset simulation
        del self.platform

        # initialize simulation
        if self.initializer is None:
            # if no initializer is given (which will be the case during training),
            # we can initialize in any way desired. here, we initialize the cube always
            # in the center of the arena, instead of randomly, as this appears to help
            # training
            initial_robot_position = TriFingerPlatform.spaces.robot_position.default
            default_object_position = (
                TriFingerPlatform.spaces.object_position.default)
            default_object_orientation = (
                TriFingerPlatform.spaces.object_orientation.default)
            initial_object_pose = move_cube.Pose(
                position=default_object_position,
                orientation=default_object_orientation,
            )
            goal_object_pose = move_cube.sample_goal(difficulty=1)
        else:
            # if an initializer is given, i.e. during evaluation, we need to initialize
            # according to it, to make sure we remain coherent with the standard CubeEnv.
            # otherwise the trajectories produced during evaluation will be invalid.
            initial_robot_position = TriFingerPlatform.spaces.robot_position.default
            initial_object_pose = self.initializer.get_initial_state()
            goal_object_pose = self.initializer.get_goal()

        self.platform = TriFingerPlatform(
            visualization=self.visualization,
            initial_robot_position=initial_robot_position,
            initial_object_pose=initial_object_pose,
        )

        self.goal = {
            "position": goal_object_pose.position,
            "orientation": goal_object_pose.orientation,
        }
        # visualize the goal
        if self.visualization:
            self.goal_marker = visual_objects.CubeMarker(
                width=0.065,
                position=goal_object_pose.position,
                orientation=goal_object_pose.orientation,
                physicsClientId=self.platform.simfinger._pybullet_client_id,
            )

        self.info = {"difficulty": 1}

        self.step_count = 0

        return self._create_observation(0)
Beispiel #3
0
    def reset(self):
        # reset simulation
        del self.platform
        if hasattr(self, 'goal_marker'):
            del self.goal_marker

        # initialize simulation
        if self.initializer is None:
            # if no initializer is given (which will be the case during training),
            # we can initialize in any way desired. here, we initialize the cube always
            # in the center of the arena, instead of randomly, as this appears to help
            # training
            initial_robot_position = TriFingerPlatform.spaces.robot_position.default
            # default_object_position = (
            #     TriFingerPlatform.spaces.object_position.default
            # )
            # default_object_orientation = (
            #     TriFingerPlatform.spaces.object_orientation.default
            # )
            # initial_object_pose = move_cube.Pose(
            #     position=default_object_position,
            #     orientation=default_object_orientation,
            # )
            goal_object_pose = move_cube.sample_goal(difficulty=1)
        else:
            # if an initializer is given, i.e. during evaluation, we need to initialize
            # according to it, to make sure we remain coherent with the standard CubeEnv.
            # otherwise the trajectories produced during evaluation will be invalid.
            initial_robot_position = TriFingerPlatform.spaces.robot_position.default
            # initial_object_pose=self.initializer.get_initial_state()
            goal_object_pose = self.initializer.get_goal()

        # self.platform = TriFingerPlatform(
        #     visualization=self.visualization,
        #     initial_robot_position=initial_robot_position,
        #     initial_object_pose=initial_object_pose,
        # )
        self._reset_platform_frontend()

        self.goal = {
            "position": goal_object_pose.position,
            "orientation": goal_object_pose.orientation,
        }
        # visualize the goal
        if self.visualization:
            if self.is_level_4:
                self.goal_marker = visual_objects.CubeMarker(
                    width=0.065,
                    position=goal_object_pose.position,
                    orientation=goal_object_pose.orientation,
                )
                self.ori_goal_marker = VisualCubeOrientation(
                    goal_object_pose.position,
                    goal_object_pose.orientation
                )

            else:
                self.goal_marker = visual_objects.SphereMaker(
                    radius=0.065 / 2,
                    position=goal_object_pose.position,
                )

        self.info = dict()

        self.step_count = 0
        observation, _, _, _ = self.step(self._initial_action)
        # init_obs = self._create_observation(0)

        if self.visualization:
            self.ori_marker = VisualCubeOrientation(
                init_obs['object_position'],
                init_obs['object_orientation']
            )

        return init_obs