Skip to content

Commit

Permalink
Merge pull request #2 from Farama-Foundation/main
Browse files Browse the repository at this point in the history
 `gymnasium==1.0` support (Farama-Foundation#211)
  • Loading branch information
Kallinteris-Andreas authored Feb 17, 2024
2 parents 7638294 + 12a336a commit 889ba7a
Show file tree
Hide file tree
Showing 25 changed files with 121 additions and 8 deletions.
3 changes: 3 additions & 0 deletions docs/content/multi-goal_api.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ goal, e.g. state derived from the simulation.

```python
import gymnasium as gym
import gymnasium_robotics

gym.register_envs(gymnasium_robotics)

env = gym.make("FetchReach-v2")
env.reset()
Expand Down
3 changes: 3 additions & 0 deletions docs/envs/franka_kitchen/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ The tasks can be selected when the environment is initialized passing a list of
```python

import gymnasium as gym
import gymnasium_robotics

gym.register_envs(gymnasium_robotics)

env = gym.make('FrankaKitchen-v1', tasks_to_complete=['microwave', 'kettle'])
```
Expand Down
3 changes: 3 additions & 0 deletions docs/envs/shadow_dexterous_hand/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ These environments are instanceated by adding the following strings to the Hand

```python
import gymnasium as gym
import gymnasium_robotics

gym.register_envs(gymnasium_robotics)

env = gym.make('HandManipulateEgg_BooleanTouchSensors-v1')
```
Expand Down
4 changes: 4 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ The creation and interaction with the robotic environments follow the Gymnasium
```{code-block} python
import gymnasium as gym
import gymnasium_robotics
gym.register_envs(gymnasium_robotics)
env = gym.make("FetchPickAndPlace-v2", render_mode="human")
observation, info = env.reset(seed=42)
for _ in range(1000):
Expand Down
2 changes: 2 additions & 0 deletions gymnasium_robotics/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

__version__ = "1.2.4"

__version__ = "1.2.4"


def register_robotics_envs():
"""Register all environment ID's to Gymnasium."""
Expand Down
3 changes: 3 additions & 0 deletions gymnasium_robotics/envs/adroit_hand/adroit_door.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,9 @@ class AdroitHandDoorEnv(MujocoEnv, EzPickle):
```python
import gymnasium as gym
import gymnasium_robotics
gym.register_envs(gymnasium_robotics)
env = gym.make('AdroitHandDoor-v1', max_episode_steps=400)
```
Expand Down
3 changes: 3 additions & 0 deletions gymnasium_robotics/envs/adroit_hand/adroit_hammer.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,9 @@ class AdroitHandHammerEnv(MujocoEnv, EzPickle):
```python
import gymnasium as gym
import gymnasium_robotics
gym.register_envs(gymnasium_robotics)
env = gym.make('AdroitHandHammer-v1', max_episode_steps=400)
```
Expand Down
3 changes: 3 additions & 0 deletions gymnasium_robotics/envs/adroit_hand/adroit_pen.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,9 @@ class AdroitHandPenEnv(MujocoEnv, EzPickle):
```python
import gymnasium as gym
import gymnasium_robotics
gym.register_envs(gymnasium_robotics)
env = gym.make('AdroitHandPen-v1', max_episode_steps=400)
```
Expand Down
3 changes: 3 additions & 0 deletions gymnasium_robotics/envs/adroit_hand/adroit_relocate.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,9 @@ class AdroitHandRelocateEnv(MujocoEnv, EzPickle):
```python
import gymnasium as gym
import gymnasium_robotics
gym.register_envs(gymnasium_robotics)
env = gym.make('AdroitHandRelocate-v1', max_episode_steps=400)
```
Expand Down
6 changes: 6 additions & 0 deletions gymnasium_robotics/envs/fetch/pick_and_place.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ class MujocoFetchPickAndPlaceEnv(MujocoFetchEnv, EzPickle):
```python
import gymnasium as gym
import gymnasium_robotics
gym.register_envs(gymnasium_robotics)
env = gym.make('FetchPickAndPlaceDense-v2')
```
Expand All @@ -118,6 +121,9 @@ class MujocoFetchPickAndPlaceEnv(MujocoFetchEnv, EzPickle):
```python
import gymnasium as gym
import gymnasium_robotics
gym.register_envs(gymnasium_robotics)
env = gym.make('FetchPickAndPlace-v2', max_episode_steps=100)
```
Expand Down
6 changes: 6 additions & 0 deletions gymnasium_robotics/envs/fetch/push.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ class MujocoFetchPushEnv(MujocoFetchEnv, EzPickle):
```python
import gymnasium as gym
import gymnasium_robotics
gym.register_envs(gymnasium_robotics)
env = gym.make('FetchPushDense-v2')
```
Expand All @@ -146,6 +149,9 @@ class MujocoFetchPushEnv(MujocoFetchEnv, EzPickle):
```python
import gymnasium as gym
import gymnasium_robotics
gym.register_envs(gymnasium_robotics)
env = gym.make('FetchPush-v2', max_episode_steps=100)
```
Expand Down
6 changes: 6 additions & 0 deletions gymnasium_robotics/envs/fetch/reach.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ class MujocoFetchReachEnv(MujocoFetchEnv, EzPickle):
```python
import gymnasium as gym
import gymnasium_robotics
gym.register_envs(gymnasium_robotics)
env = gym.make('FetchReachDense-v2')
```
Expand All @@ -104,6 +107,9 @@ class MujocoFetchReachEnv(MujocoFetchEnv, EzPickle):
```python
import gymnasium as gym
import gymnasium_robotics
gym.register_envs(gymnasium_robotics)
env = gym.make('FetchReach-v2', max_episode_steps=100)
```
Expand Down
6 changes: 6 additions & 0 deletions gymnasium_robotics/envs/fetch/slide.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ class MujocoFetchSlideEnv(MujocoFetchEnv, EzPickle):
```python
import gymnasium as gym
import gymnasium_robotics
gym.register_envs(gymnasium_robotics)
env = gym.make('FetchSlideDense-v2')
```
Expand All @@ -145,6 +148,9 @@ class MujocoFetchSlideEnv(MujocoFetchEnv, EzPickle):
```python
import gymnasium as gym
import gymnasium_robotics
gym.register_envs(gymnasium_robotics)
env = gym.make('FetchSlide-v2', max_episode_steps=100)
```
Expand Down
4 changes: 4 additions & 0 deletions gymnasium_robotics/envs/franka_kitchen/kitchen_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ class KitchenEnv(GoalEnv, EzPickle):
```python
import gymnasium as gym
import gymnasium_robotics
gym.register_envs(gymnasium_robotics)
env = gym.make('FrankaKitchen-v1', tasks_to_complete=['microwave', 'kettle'])
```
Expand Down
8 changes: 8 additions & 0 deletions gymnasium_robotics/envs/maze/ant_maze.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,3 +122,11 @@ def render(self):
def close(self):
super().close()
self.ant_env.close()

@property
def model(self):
return self.ant_env.model

@property
def data(self):
return self.ant_env.data
17 changes: 17 additions & 0 deletions gymnasium_robotics/envs/maze/ant_maze_v4.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ class AntMazeEnv(MazeEnv, EzPickle):
```python
import gymnasium as gym
import gymnasium_robotics
gym.register_envs(gymnasium_robotics)
example_map = [[1, 1, 1, 1, 1],
[1, C, 0, C, 1],
Expand Down Expand Up @@ -158,6 +161,9 @@ class AntMazeEnv(MazeEnv, EzPickle):
```python
import gymnasium as gym
import gymnasium_robotics
gym.register_envs(gymnasium_robotics)
env = gym.make('AntMaze_UMaze-v4')
```
Expand Down Expand Up @@ -192,6 +198,9 @@ class AntMazeEnv(MazeEnv, EzPickle):
```python
import gymnasium as gym
import gymnasium_robotics
gym.register_envs(gymnasium_robotics)
env = gym.make('AntMaze_UMaze-v4', max_episode_steps=100)
```
Expand Down Expand Up @@ -319,3 +328,11 @@ def render(self):
def close(self):
super().close()
self.ant_env.close()

@property
def model(self):
return self.ant_env.model

@property
def data(self):
return self.ant_env.data
17 changes: 17 additions & 0 deletions gymnasium_robotics/envs/maze/point_maze.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,9 @@ class PointMazeEnv(MazeEnv, EzPickle):
```python
import gymnasium as gym
import gymnasium_robotics
gym.register_envs(gymnasium_robotics)
example_map = [[1, 1, 1, 1, 1],
[1, C, 0, C, 1],
Expand Down Expand Up @@ -253,6 +256,9 @@ class PointMazeEnv(MazeEnv, EzPickle):
```python
import gymnasium as gym
import gymnasium_robotics
gym.register_envs(gymnasium_robotics)
env = gym.make('PointMaze_UMazeDense-v3')
```
Expand Down Expand Up @@ -286,6 +292,9 @@ class PointMazeEnv(MazeEnv, EzPickle):
```python
import gymnasium as gym
import gymnasium_robotics
gym.register_envs(gymnasium_robotics)
env = gym.make('PointMaze_UMaze-v3', max_episode_steps=100)
```
Expand Down Expand Up @@ -415,3 +424,11 @@ def render(self):
def close(self):
super().close()
self.point_env.close()

@property
def model(self):
return self.point_env.model

@property
def data(self):
return self.point_env.data
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,9 @@ class MujocoHandBlockEnv(MujocoManipulateEnv, EzPickle):
```python
import gymnasium as gym
import gymnasium_robotics
gym.register_envs(gymnasium_robotics)
env = gym.make('HandManipulateBlock-v1')
```
Expand Down Expand Up @@ -193,6 +196,9 @@ class MujocoHandBlockEnv(MujocoManipulateEnv, EzPickle):
```python
import gymnasium as gym
import gymnasium_robotics
gym.register_envs(gymnasium_robotics)
env = gym.make('HandManipulateBlock-v1', max_episode_steps=100)
```
Expand All @@ -203,7 +209,6 @@ class MujocoHandBlockEnv(MujocoManipulateEnv, EzPickle):
* v1: the environment depends on the newest [mujoco python bindings](https://mujoco.readthedocs.io/en/latest/python.html) maintained by the MuJoCo team in Deepmind.
* v0: the environment depends on `mujoco_py` which is no longer maintained.
"""

def __init__(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@ class MujocoHandEggEnv(MujocoManipulateEnv, EzPickle):
```python
import gymnasium as gym
import gymnasium_robotics
gym.register_envs(gymnasium_robotics)
env = gym.make('HandManipulateEgg-v1')
```
Expand Down Expand Up @@ -196,6 +199,9 @@ class MujocoHandEggEnv(MujocoManipulateEnv, EzPickle):
```
import gymnasium as gym
import gymnasium_robotics
gym.register_envs(gymnasium_robotics)
env = gym.make('HandManipulateEgg-v1', max_episode_steps=100)
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,9 @@ class MujocoHandPenEnv(MujocoManipulateEnv, EzPickle):
```python
import gymnasium as gym
import gymnasium_robotics
gym.register_envs(gymnasium_robotics)
env = gym.make('HandManipulatePen-v1')
```
Expand Down Expand Up @@ -195,6 +198,9 @@ class MujocoHandPenEnv(MujocoManipulateEnv, EzPickle):
```python
import gymnasium as gym
import gymnasium_robotics
gym.register_envs(gymnasium_robotics)
env = gym.make('HandManipulatePen-v1', max_episode_steps=100)
```
Expand All @@ -205,7 +211,6 @@ class MujocoHandPenEnv(MujocoManipulateEnv, EzPickle):
* v1: the environment depends on the newest [mujoco python bindings](https://mujoco.readthedocs.io/en/latest/python.html) maintained by the MuJoCo team in Deepmind.
* v0: the environment depends on `mujoco_py` which is no longer maintained.
"""

def __init__(
Expand Down
4 changes: 2 additions & 2 deletions tests/envs/franka_kitchen/test_kitchen_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def test_task_completion(remove_task_when_completed, terminate_on_tasks_complete
# Complete a task sequentially for each environment step
for task in TASKS:
# Force task to be achieved
env.data.qpos[OBS_ELEMENT_INDICES[task]] = OBS_ELEMENT_GOALS[task]
env.unwrapped.data.qpos[OBS_ELEMENT_INDICES[task]] = OBS_ELEMENT_GOALS[task]
_, _, terminated, _, info = env.step(env.action_space.sample())
completed_tasks.add(task)

Expand Down Expand Up @@ -91,7 +91,7 @@ def test_task_completion(remove_task_when_completed, terminate_on_tasks_complete
# Complete a task sequentially for each environment step
for task in TASKS:
# Force task to be achieved
env.data.qpos[OBS_ELEMENT_INDICES[task]] = OBS_ELEMENT_GOALS[task]
env.unwrapped.data.qpos[OBS_ELEMENT_INDICES[task]] = OBS_ELEMENT_GOALS[task]
completed_tasks.add(task)

_, _, terminated, _, info = env.step(env.action_space.sample())
Expand Down
2 changes: 1 addition & 1 deletion tests/envs/hand/test_manipulate.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def test_serialize_deserialize(environment_id):
env1.reset()
env2 = pickle.loads(pickle.dumps(env1))

assert env1.target_position == env2.target_position, (
assert env1.unwrapped.target_position == env2.unwrapped.target_position, (
env1.target_position,
env2.target_position,
)
2 changes: 1 addition & 1 deletion tests/envs/hand/test_manipulate_touch_sensors.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def test_serialize_deserialize(environment_id):
env1.reset()
env2 = pickle.loads(pickle.dumps(env1))

assert env1.target_position == env2.target_position, (
assert env1.unwrapped.target_position == env2.unwrapped.target_position, (
env1.target_position,
env2.target_position,
)
2 changes: 1 addition & 1 deletion tests/envs/hand/test_reach.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def test_serialize_deserialize():
env1.reset()
env2 = pickle.loads(pickle.dumps(env1))

assert env1.distance_threshold == env2.distance_threshold, (
assert env1.unwrapped.distance_threshold == env2.unwrapped.distance_threshold, (
env1.distance_threshold,
env2.distance_threshold,
)
Loading

0 comments on commit 889ba7a

Please sign in to comment.