Пример #1
0
    def reset(self):
        if self._hard_reset:
            self._pybullet_client.resetSimulation()
            self._pybullet_client.setPhysicsEngineParameter(
                numSolverIterations=int(self._num_bullet_solver_iterations))
            self._pybullet_client.setTimeStep(self._time_step)
            plane = self._pybullet_client.loadURDF("%s/plane.urdf" %
                                                   self._urdf_root)
            self._pybullet_client.changeVisualShape(plane,
                                                    -1,
                                                    rgbaColor=[1, 1, 1, 0.9])
            self._pybullet_client.configureDebugVisualizer(
                self._pybullet_client.COV_ENABLE_PLANAR_REFLECTION, 0)
            self._pybullet_client.setGravity(0, 0, -10)
            acc_motor = self._accurate_motor_model_enabled
            motor_protect = self._motor_overheat_protection
            self.minitaur = (minitaur.Minitaur(
                pybullet_client=self._pybullet_client,
                urdf_root=self._urdf_root,
                time_step=self._time_step,
                self_collision_enabled=self._self_collision_enabled,
                motor_velocity_limit=self._motor_velocity_limit,
                pd_control_enabled=self._pd_control_enabled,
                accurate_motor_model_enabled=acc_motor,
                motor_kp=self._motor_kp,
                motor_kd=self._motor_kd,
                torque_control_enabled=self._torque_control_enabled,
                motor_overheat_protection=motor_protect,
                on_rack=self._on_rack,
                kd_for_pd_controllers=self._kd_for_pd_controllers))
        else:
            self.minitaur.Reset(reload_urdf=False)

        if self._env_randomizer is not None:
            self._env_randomizer.randomize_env(self)

        self._env_step_counter = 0
        self._last_base_position = [0, 0, 0]
        self._objectives = []
        self._pybullet_client.resetDebugVisualizerCamera(
            self._cam_dist, self._cam_yaw, self._cam_pitch, [0, 0, 0])
        if not self._torque_control_enabled:
            for _ in range(100):
                if self._pd_control_enabled or self._accurate_motor_model_enabled:
                    self.minitaur.ApplyAction([math.pi / 2] * 8)
                self._pybullet_client.stepSimulation()
        if self._velocity_weight > 0:
            self.target_velocity = np.random.uniform(
                0, self.target_velocity_range)

        # if self._distance_weight > 0:
        #     self.target_position = np.random.uniform(-self.target_position_range, self.target_position_range)

        return self._noisy_observation()
Пример #2
0
    def _reset(self):
        if self._hard_reset:
            self._pybullet_client.resetSimulation()
            self._pybullet_client.setPhysicsEngineParameter(
                numSolverIterations=int(self._num_bullet_solver_iterations))
            self._pybullet_client.setTimeStep(self._time_step)
            self._groundId = self._pybullet_client.loadURDF("%s/plane.urdf" %
                                                            self._urdf_root)
            #self._ballId = self._pybullet_client.loadURDF("%s/sphere_small.urdf" % self._urdf_root,ballStartPos,ballStartOrn)
            rel_path = os.path.split(os.path.realpath(__file__))[0]
            #self._ballId = self._pybullet_client.loadURDF("%s/urdf/sphere_small.urdf" % rel_path,ballStartPos,ballStartOrn)
            self._ballId = self._pybullet_client.loadURDF(
                "%s/urdf/custom_sphere.urdf" % rel_path, ballStartPos,
                ballStartOrn)
            self._pybullet_client.setGravity(0, 0, -10)
            acc_motor = self._accurate_motor_model_enabled
            motor_protect = self._motor_overheat_protection
            self.minitaur = (minitaur.Minitaur(
                pybullet_client=self._pybullet_client,
                urdf_root=self._urdf_root,
                time_step=self._time_step,
                self_collision_enabled=self._self_collision_enabled,
                motor_velocity_limit=self._motor_velocity_limit,
                pd_control_enabled=self._pd_control_enabled,
                accurate_motor_model_enabled=acc_motor,
                motor_kp=self._motor_kp,
                motor_kd=self._motor_kd,
                torque_control_enabled=self._torque_control_enabled,
                motor_overheat_protection=motor_protect,
                on_rack=self._on_rack,
                kd_for_pd_controllers=self._kd_for_pd_controllers))
        else:
            self.minitaur.Reset(reload_urdf=False)
            self._pybullet_client.resetBasePositionAndOrientation(
                self._ballId, ballStartPos, ballStartOrn)
        if self._env_randomizer is not None:
            self._env_randomizer.randomize_env(self)

        self._env_step_counter = 0
        self._last_base_position = [0, 0, 0]
        self._objectives = []
        self._pybullet_client.resetDebugVisualizerCamera(
            self._cam_dist, self._cam_yaw, self._cam_pitch, [0, 0, 0])
        if not self._torque_control_enabled:
            for _ in range(100):
                if self._pd_control_enabled or self._accurate_motor_model_enabled:
                    self.minitaur.ApplyAction([math.pi / 2] * 8)
                self._pybullet_client.stepSimulation()
        return self._noisy_observation()