Unverified Commit 64dc8745 authored by Kelly Guo's avatar Kelly Guo Committed by GitHub

Adds gym.Env to DirectMARLEnv for Gymnasium v1.0.0 (#1446)

# Description

Due to recent release of Gymnasium 1.0.0, this now becomes the Gymnasium
version that gets installed when running the installation process for
Isaac Lab. Gymnasium 1.0.0 requires all environments to be a subclass of
`gym.Env` when using the `make` interface. This change makes the
`DirectMARLEnv` a subclass of `gym.Env` to satisfy this requirement.

Fixes #1002 

## Type of change

- Bug fix (non-breaking change which fixes an issue)
- Breaking change (fix or feature that would cause existing
functionality to not work as expected)


## Checklist

- [x] I have run the [`pre-commit` checks](https://pre-commit.com/) with
`./isaaclab.sh --format`
- [x] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [x] I have updated the changelog and the corresponding version in the
extension's `config/extension.toml` file
- [ ] I have added my name to the `CONTRIBUTORS.md` or my name already
exists there

<!--
As you go through the checklist above, you can mark something as done by
putting an x character in it

For example,
- [x] I have done this task
- [ ] I have not done this task
-->
parent 4d991470
[package] [package]
# Note: Semantic Versioning is used: https://semver.org/ # Note: Semantic Versioning is used: https://semver.org/
version = "0.27.15" version = "0.27.16"
# Description # Description
title = "Isaac Lab framework for Robot Learning" title = "Isaac Lab framework for Robot Learning"
......
Changelog Changelog
--------- ---------
0.27.16 (2024-11-21)
~~~~~~~~~~~~~~~~~~~~
Changed
^^^^^^^
* Changed :class:`omni.isaac.lab.envs.DirectMARLEnv` to inherit from ``Gymnasium.Env`` due to requirement from Gymnasium v1.0.0 requiring all environments to be a subclass of ``Gymnasium.Env`` when using the ``make`` interface.
0.27.15 (2024-11-09) 0.27.15 (2024-11-09)
~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~
......
...@@ -34,7 +34,7 @@ from .ui import ViewportCameraController ...@@ -34,7 +34,7 @@ from .ui import ViewportCameraController
from .utils.spaces import sample_space, spec_to_gym_space from .utils.spaces import sample_space, spec_to_gym_space
class DirectMARLEnv: class DirectMARLEnv(gym.Env):
"""The superclass for the direct workflow to design multi-agent environments. """The superclass for the direct workflow to design multi-agent environments.
This class implements the core functionality for multi-agent reinforcement learning (MARL) This class implements the core functionality for multi-agent reinforcement learning (MARL)
......
...@@ -27,7 +27,7 @@ INSTALL_REQUIRES = [ ...@@ -27,7 +27,7 @@ INSTALL_REQUIRES = [
# devices # devices
"hidapi", "hidapi",
# reinforcement learning # reinforcement learning
"gymnasium==0.29.0", "gymnasium",
# procedural-generation # procedural-generation
"trimesh", "trimesh",
"pyglet<2", "pyglet<2",
......
...@@ -118,7 +118,9 @@ class TestEnvironments(unittest.TestCase): ...@@ -118,7 +118,9 @@ class TestEnvironments(unittest.TestCase):
with torch.inference_mode(): with torch.inference_mode():
for _ in range(num_steps): for _ in range(num_steps):
# sample actions according to the defined space # sample actions according to the defined space
actions = sample_space(env.single_action_space, device=env.unwrapped.device, batch_size=num_envs) actions = sample_space(
env.unwrapped.single_action_space, device=env.unwrapped.device, batch_size=num_envs
)
# apply actions # apply actions
transition = env.step(actions) transition = env.step(actions)
# check signals # check signals
......
...@@ -105,7 +105,7 @@ class TestEnvironments(unittest.TestCase): ...@@ -105,7 +105,7 @@ class TestEnvironments(unittest.TestCase):
# this flag is necessary to prevent a bug where the simulation gets stuck randomly when running the # this flag is necessary to prevent a bug where the simulation gets stuck randomly when running the
# test on many environments. # test on many environments.
env.sim.set_setting("/physics/cooking/ujitsoCollisionCooking", False) env.unwrapped.sim.set_setting("/physics/cooking/ujitsoCollisionCooking", False)
# reset environment # reset environment
obs, _ = env.reset() obs, _ = env.reset()
...@@ -116,7 +116,9 @@ class TestEnvironments(unittest.TestCase): ...@@ -116,7 +116,9 @@ class TestEnvironments(unittest.TestCase):
for _ in range(num_steps): for _ in range(num_steps):
# sample actions according to the defined space # sample actions according to the defined space
actions = { actions = {
agent: sample_space(env.action_spaces[agent], device=env.unwrapped.device, batch_size=num_envs) agent: sample_space(
env.unwrapped.action_spaces[agent], device=env.unwrapped.device, batch_size=num_envs
)
for agent in env.unwrapped.possible_agents for agent in env.unwrapped.possible_agents
} }
# apply actions # apply actions
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment