コード例 #1
0
    def __init__(self, config, gpu_idx=0):
        self.config = self.parse_config(config)
        print(self.config["envname"])
        assert (self.config["envname"] == self.__class__.__name__
                or self.config["envname"] == "TestEnv")
        CameraRobotEnv.__init__(self,
                                self.config,
                                gpu_idx,
                                scene_type="building",
                                tracking_camera=tracking_camera)

        self.robot_introduce(Husky(self.config, env=self))
        self.scene_introduce()

        self.total_reward = 0
        self.total_frame = 0
        self.flag_timeout = 1
        self.visualid = -1
        self.lastid = None
        self.gui = self.config["mode"] == "gui"

        if self.gui:
            self.visualid = p.createVisualShape(
                p.GEOM_MESH,
                fileName=os.path.join(pybullet_data.getDataPath(), 'cube.obj'),
                meshScale=[0.2, 0.2, 0.2],
                rgbaColor=[1, 0, 0, 0.7])
        self.colisionid = p.createCollisionShape(
            p.GEOM_MESH,
            fileName=os.path.join(pybullet_data.getDataPath(), 'cube.obj'),
            meshScale=[0.2, 0.2, 0.2])

        self.lastid = None
        self.obstacle_dist = 100
コード例 #2
0
    def __init__(self, config, gpu_idx=0):
        self.config = self.parse_config(config)
        print(self.config["envname"])
        assert(self.config["envname"] == self.__class__.__name__ or self.config["envname"] == "TestEnv")
        CameraRobotEnv.__init__(self, self.config, gpu_idx,
                                scene_type="building",
                                tracking_camera=tracking_camera)

        self.robot_introduce(Humanoid(self.config, env=self))
        self.scene_introduce()

        self.gui = self.config["mode"] == "gui"
        self.total_reward = 0
        self.total_frame = 0
コード例 #3
0
    def __init__(self, config, gpu_idx=0):
        self.config = self.parse_config(config)
        assert (self.config["envname"] == self.__class__.__name__
                or self.config["envname"] == "TestEnv")

        CameraRobotEnv.__init__(self,
                                self.config,
                                gpu_idx,
                                scene_type="stadium" if self.config["model_id"]
                                == "stadium" else "building",
                                tracking_camera=tracking_camera)

        self.robot_introduce(JR2(self.config, env=self))
        self.scene_introduce()
        self.total_reward = 0
        self.total_frame = 0
コード例 #4
0
ファイル: ant_env.py プロジェクト: eg4000/ObjectRemoval
    def _step(self, a):
        state, reward, done, meta = CameraRobotEnv._step(self, a)
        if self.flag_timeout <= 0:
            self._flag_reposition()
        self.flag_timeout -= 1

        return state, reward, done, meta
コード例 #5
0
ファイル: minitaur_env.py プロジェクト: eg4000/ObjectRemoval
    def _step(self, action):
        """Step forward the simulation, given the action.

        Args:
          action: A list of desired motor angles for eight motors.

        Returns:
          observations: The angles, velocities and torques of all motors.
          reward: The reward for the current state-action pair.
          done: Whether the episode has ended.
          info: A dictionary that stores diagnostic information.

        Raises:
          ValueError: The action dimension is not the same as the number of motors.
          ValueError: The magnitude of actions is out of bounds.
        """
        #print("Env apply raw action", action)
        action = self._transform_action_to_motor_command(action)
        #print("Env apply action", action)

        #for _ in range(self._action_repeat):
        #  self.robot.ApplyAction(action)
        #  pybullet.stepSimulation()
        for i in range(len(self.Amax)):
            if action[i] > self.Amax[i]:
                self.Amax[i] = action[i]
        #print("Action max", self.Amax)
        for _ in range(self.action_repeat):
            state = CameraRobotEnv._step(self, action)
        return state
コード例 #6
0
ファイル: ant_env.py プロジェクト: eg4000/ObjectRemoval
 def _reset(self):
     self.total_frame = 0
     self.total_reward = 0
     self._randomize_target()
     self._flag_reposition()
     obs = CameraRobotEnv._reset(
         self)  ## Important: must come after flat_reposition
     return obs
コード例 #7
0
    def _step(self, a):
        state, reward, done, meta = CameraRobotEnv._step(self, a)
        if self.flag_timeout <= 0 or (self.flag_timeout < 225
                                      and self.robot.walk_target_dist < 0.8):
            self._flag_reposition()
        self.flag_timeout -= 1

        if "depth" in self.config["output"]:
            depth_obs = self.get_observations()["depth"]
            x_start = int(self.windowsz / 2 - 16)
            x_end = int(self.windowsz / 2 + 16)
            y_start = int(self.windowsz / 2 - 16)
            y_end = int(self.windowsz / 2 + 16)
            self.obstacle_dist = (np.mean(depth_obs[x_start:x_end,
                                                    y_start:y_end, -1]))

        return state, reward, done, meta
コード例 #8
0
 def _reset(self):
     self.total_frame = 0
     self.total_reward = 0
     obs = CameraRobotEnv._reset(self)
     self._flag_reposition()
     return obs
コード例 #9
0
 def _reset(self):
     CameraRobotEnv._reset(self)
     for flagId in self.semantic_flagIds:
         p.changeVisualShape(flagId, -1, rgbaColor=[1, 0, 0, 1])
コード例 #10
0
 def _reset(self):
     obs = CameraRobotEnv._reset(self)
     return obs
コード例 #11
0
ファイル: minitaur_env.py プロジェクト: eg4000/ObjectRemoval
    def __init__(self, config, gpu_idx=0):
        """Initialize the minitaur gym environment.
        Args:
            distance_weight: The weight of the distance term in the reward.
            energy_weight: The weight of the energy term in the reward.
            shake_weight: The weight of the vertical shakiness term in the reward.
            drift_weight: The weight of the sideways drift term in the reward.
            distance_limit: The maximum distance to terminate the episode.
            observation_noise_stdev: The standard deviation of observation noise.
            leg_model_enabled: Whether to use a leg motor to reparameterize the action
                space.
            hard_reset: Whether to wipe the simulation and load everything when reset
                is called. If set to false, reset just place the minitaur back to start
                position and set its pose to initial configuration.
            env_randomizer: An EnvRandomizer to randomize the physical properties
                during reset().
        """

        self.config = self.parse_config(config)
        assert (self.config["envname"] == self.__class__.__name__
                or self.config["envname"] == "TestEnv")

        CameraRobotEnv.__init__(self,
                                self.config,
                                gpu_idx,
                                scene_type="building",
                                tracking_camera=tracking_camera)

        self.robot_introduce(
            Minitaur(self.config,
                     env=self,
                     pd_control_enabled=self.pd_control_enabled,
                     accurate_motor_model_enabled=self.
                     accurate_motor_model_enabled))
        self.scene_introduce()
        self.gui = self.config["mode"] == "gui"
        self.total_reward = 0
        self.total_frame = 0

        self.action_repeat = 1
        ## Important: PD controller needs more accuracy
        '''if self.pd_control_enabled or self.accurate_motor_model_enabled:
            self.time_step = self.config["speed"]["timestep"]
            self.time_step /= self.NUM_SUBSTEPS
            self.num_bullet_solver_iterations /= self.NUM_SUBSTEPS
            self.action_repeat *= self.NUM_SUBSTEPS
            pybullet.setPhysicsEngineParameter(physicsClientId=self.physicsClientId,
              numSolverIterations=int(self.num_bullet_solver_iterations))
            pybullet.setTimeStep(self.time_step, physicsClientId=self.physicsClientId)
        '''
        pybullet.setPhysicsEngineParameter(
            physicsClientId=self.physicsClientId,
            numSolverIterations=int(self.num_bullet_solver_iterations))
        self._observation = []
        self._last_base_position = [0, 0, 0]
        self._action_bound = self.action_bound

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

        self._objectives = []
        self.viewer = None
        self.Amax = [0] * 8
コード例 #12
0
    def _reset(self):
        self.total_frame = 0
        self.total_reward = 0

        obs = CameraRobotEnv._reset(self)
        return obs