Add open ai gym environments
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
from alr_envs.open_ai.continuous_mountain_car.positional_wrapper import PositionalWrapper
|
||||
from alr_envs.open_ai.continuous_mountain_car.mp_wrapper import MPWrapper
|
||||
@@ -0,0 +1,17 @@
|
||||
from typing import Union
|
||||
|
||||
from mp_env_api.env_wrappers.mp_env_wrapper import MPEnvWrapper
|
||||
|
||||
|
||||
class MPWrapper(MPEnvWrapper):
|
||||
@property
|
||||
def start_pos(self):
|
||||
raise ValueError("Start position is not available")
|
||||
|
||||
@property
|
||||
def goal_pos(self):
|
||||
raise ValueError("Goal position is not available and has to be learnt based on the environment.")
|
||||
|
||||
@property
|
||||
def dt(self) -> Union[float, int]:
|
||||
return 1.
|
||||
@@ -0,0 +1,13 @@
|
||||
from typing import Union
|
||||
import numpy as np
|
||||
from mp_env_api.env_wrappers.positional_env_wrapper import PositionalEnvWrapper
|
||||
|
||||
|
||||
class PositionalWrapper(PositionalEnvWrapper):
|
||||
@property
|
||||
def current_vel(self) -> Union[float, int, np.ndarray]:
|
||||
return np.array([self.state[1]])
|
||||
|
||||
@property
|
||||
def current_pos(self) -> Union[float, int, np.ndarray]:
|
||||
return np.array([self.state[0]])
|
||||
@@ -0,0 +1,2 @@
|
||||
from alr_envs.open_ai.fetch.positional_wrapper import PositionalWrapper
|
||||
from alr_envs.open_ai.fetch.mp_wrapper import MPWrapper
|
||||
@@ -0,0 +1,18 @@
|
||||
from typing import Union
|
||||
|
||||
from gym import spaces
|
||||
from mp_env_api.env_wrappers.mp_env_wrapper import MPEnvWrapper
|
||||
|
||||
|
||||
class MPWrapper(MPEnvWrapper):
|
||||
@property
|
||||
def start_pos(self):
|
||||
return self.initial_gripper_xpos
|
||||
|
||||
@property
|
||||
def goal_pos(self):
|
||||
raise ValueError("Goal position is not available and has to be learnt based on the environment.")
|
||||
|
||||
@property
|
||||
def dt(self) -> Union[float, int]:
|
||||
return self.env.dt
|
||||
@@ -0,0 +1,13 @@
|
||||
from typing import Union
|
||||
import numpy as np
|
||||
from mp_env_api.env_wrappers.positional_env_wrapper import PositionalEnvWrapper
|
||||
|
||||
|
||||
class PositionalWrapper(PositionalEnvWrapper):
|
||||
@property
|
||||
def current_vel(self) -> Union[float, int, np.ndarray]:
|
||||
return self._get_obs()["observation"][-5:-1]
|
||||
|
||||
@property
|
||||
def current_pos(self) -> Union[float, int, np.ndarray]:
|
||||
return self._get_obs()["observation"][:4]
|
||||
@@ -0,0 +1,2 @@
|
||||
from alr_envs.open_ai.reacher_v2.positional_wrapper import PositionalWrapper
|
||||
from alr_envs.open_ai.reacher_v2.mp_wrapper import MPWrapper
|
||||
@@ -0,0 +1,18 @@
|
||||
from typing import Union
|
||||
|
||||
from mp_env_api.env_wrappers.mp_env_wrapper import MPEnvWrapper
|
||||
|
||||
|
||||
class MPWrapper(MPEnvWrapper):
|
||||
|
||||
@property
|
||||
def start_pos(self):
|
||||
raise ValueError("Start position is not available")
|
||||
|
||||
@property
|
||||
def goal_pos(self):
|
||||
return self.goal
|
||||
|
||||
@property
|
||||
def dt(self) -> Union[float, int]:
|
||||
return self.env.dt
|
||||
@@ -0,0 +1,13 @@
|
||||
from typing import Union
|
||||
import numpy as np
|
||||
from mp_env_api.env_wrappers.positional_env_wrapper import PositionalEnvWrapper
|
||||
|
||||
|
||||
class PositionalWrapper(PositionalEnvWrapper):
|
||||
@property
|
||||
def current_vel(self) -> Union[float, int, np.ndarray]:
|
||||
return self.sim.data.qvel[:2]
|
||||
|
||||
@property
|
||||
def current_pos(self) -> Union[float, int, np.ndarray]:
|
||||
return self.sim.data.qpos[:2]
|
||||
Reference in New Issue
Block a user