From 9673725258f592e3293bfb0b479ab559c2a0f0c8 Mon Sep 17 00:00:00 2001 From: Mayank Mittal <12863862+Mayankm96@users.noreply.github.com> Date: Wed, 25 Oct 2023 17:23:00 +0200 Subject: [PATCH] Adds observation and action spaces to the `RLEnv` class (#206) # Description Adds missing observation and action spaces to the `RLEnv` class. Some standalone scripts were using these and were erroring out since they were not implemented. ## Type of change - Bug fix (non-breaking change which fixes an issue) ## Checklist - [x] I have run the [`pre-commit` checks](https://pre-commit.com/) with `./orbit.sh --format` - [ ] 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 --- source/extensions/omni.isaac.orbit/config/extension.toml | 2 +- source/extensions/omni.isaac.orbit/docs/CHANGELOG.rst | 9 +++++++++ .../omni.isaac.orbit/omni/isaac/orbit/envs/rl_env.py | 9 +++++++++ .../isaac/orbit_envs/locomotion/locomotion_env_cfg.py | 4 +++- 4 files changed, 22 insertions(+), 2 deletions(-) diff --git a/source/extensions/omni.isaac.orbit/config/extension.toml b/source/extensions/omni.isaac.orbit/config/extension.toml index 5658259aa2..e8eaf9b3c8 100644 --- a/source/extensions/omni.isaac.orbit/config/extension.toml +++ b/source/extensions/omni.isaac.orbit/config/extension.toml @@ -1,7 +1,7 @@ [package] # Note: Semantic Versioning is used: https://semver.org/ -version = "0.9.18" +version = "0.9.19" # Description title = "ORBIT framework for Robot Learning" diff --git a/source/extensions/omni.isaac.orbit/docs/CHANGELOG.rst b/source/extensions/omni.isaac.orbit/docs/CHANGELOG.rst index 39f06c57bc..45053b23cb 100644 --- a/source/extensions/omni.isaac.orbit/docs/CHANGELOG.rst +++ b/source/extensions/omni.isaac.orbit/docs/CHANGELOG.rst @@ -1,6 +1,15 @@ Changelog --------- +0.9.19 (2023-10-25) +~~~~~~~~~~~~~~~~~~~ + +Added +^^^^^ + +* Added Gym observation and action spaces for the :class:`omni.isaac.orbit.envs.RLEnv` class. + + 0.9.18 (2023-10-19) ~~~~~~~~~~~~~~~~~~ diff --git a/source/extensions/omni.isaac.orbit/omni/isaac/orbit/envs/rl_env.py b/source/extensions/omni.isaac.orbit/omni/isaac/orbit/envs/rl_env.py index 12abad7b59..98553b6969 100644 --- a/source/extensions/omni.isaac.orbit/omni/isaac/orbit/envs/rl_env.py +++ b/source/extensions/omni.isaac.orbit/omni/isaac/orbit/envs/rl_env.py @@ -96,6 +96,15 @@ def __init__(self, cfg: RLEnvCfg): # print the environment information print("[INFO]: Completed setting up the environment...") + # setup the action and observation spaces for Gym + # -- observation space + self.observation_space = gym.spaces.Dict() + for group_name, group_dim in self.observation_manager.group_obs_dim.items(): + self.observation_space[group_name] = gym.spaces.Box(low=-np.inf, high=np.inf, shape=group_dim) + # -- action space (unbounded since we don't impose any limits) + action_dim = sum(self.action_manager.action_term_dim) + self.action_space = gym.spaces.Box(low=-np.inf, high=np.inf, shape=(action_dim,)) + # perform randomization at the start of the simulation self.randomization_manager.randomize(mode="startup") # extend UI elements diff --git a/source/extensions/omni.isaac.orbit_envs/omni/isaac/orbit_envs/locomotion/locomotion_env_cfg.py b/source/extensions/omni.isaac.orbit_envs/omni/isaac/orbit_envs/locomotion/locomotion_env_cfg.py index 7b785eb317..190cdf73ec 100644 --- a/source/extensions/omni.isaac.orbit_envs/omni/isaac/orbit_envs/locomotion/locomotion_env_cfg.py +++ b/source/extensions/omni.isaac.orbit_envs/omni/isaac/orbit_envs/locomotion/locomotion_env_cfg.py @@ -69,7 +69,9 @@ class TerrainSceneCfg(InteractiveSceneCfg): debug_vis=True, mesh_prim_paths=["/World/ground"], ) - contact_forces = ContactSensorCfg(prim_path="{ENV_REGEX_NS}/Robot/.*", history_length=3, debug_vis=True) + contact_forces = ContactSensorCfg( + prim_path="{ENV_REGEX_NS}/Robot/.*", history_length=3, track_air_time=True, debug_vis=True + ) # lights light = AssetBaseCfg( prim_path="/World/light",