From b5a0f856b0ebee328729123a642b5e23f1785f62 Mon Sep 17 00:00:00 2001 From: Xiong Hongwei Date: Wed, 11 Dec 2024 23:09:46 +0800 Subject: [PATCH 1/5] Adds support for dynamic target height adjustment in base_height_l2 for rough terrain --- .../omni/isaac/lab/envs/mdp/rewards.py | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/source/extensions/omni.isaac.lab/omni/isaac/lab/envs/mdp/rewards.py b/source/extensions/omni.isaac.lab/omni/isaac/lab/envs/mdp/rewards.py index 1a68d321ab..9b3fe7440c 100644 --- a/source/extensions/omni.isaac.lab/omni/isaac/lab/envs/mdp/rewards.py +++ b/source/extensions/omni.isaac.lab/omni/isaac/lab/envs/mdp/rewards.py @@ -18,7 +18,7 @@ from omni.isaac.lab.managers import SceneEntityCfg from omni.isaac.lab.managers.manager_base import ManagerTermBase from omni.isaac.lab.managers.manager_term_cfg import RewardTermCfg -from omni.isaac.lab.sensors import ContactSensor +from omni.isaac.lab.sensors import ContactSensor, RayCaster if TYPE_CHECKING: from omni.isaac.lab.envs import ManagerBasedRLEnv @@ -98,17 +98,28 @@ def flat_orientation_l2(env: ManagerBasedRLEnv, asset_cfg: SceneEntityCfg = Scen def base_height_l2( - env: ManagerBasedRLEnv, target_height: float, asset_cfg: SceneEntityCfg = SceneEntityCfg("robot") + env: ManagerBasedRLEnv, + target_height: float, + asset_cfg: SceneEntityCfg = SceneEntityCfg("robot"), + sensor_cfg: SceneEntityCfg | None = None, ) -> torch.Tensor: """Penalize asset height from its target using L2 squared kernel. Note: - Currently, it assumes a flat terrain, i.e. the target height is in the world frame. + For flat terrain, target height is in the world frame. For rough terrain, + sensor readings can adjust the target height to account for the terrain. """ # extract the used quantities (to enable type-hinting) asset: RigidObject = env.scene[asset_cfg.name] - # TODO: Fix this for rough-terrain. - return torch.square(asset.data.root_pos_w[:, 2] - target_height) + if sensor_cfg is not None: + sensor: RayCaster = env.scene[sensor_cfg.name] + # Adjust the target height using the sensor data + adjusted_target_height = target_height + sensor.data.pos_w[:, 2] + else: + # Use the provided target height directly for flat terrain + adjusted_target_height = target_height + # Compute the L2 squared penalty + return torch.square(asset.data.root_pos_w[:, 2] - adjusted_target_height) def body_lin_acc_l2(env: ManagerBasedRLEnv, asset_cfg: SceneEntityCfg = SceneEntityCfg("robot")) -> torch.Tensor: From ea49b37806df78e787e16188722fddd48c7238a0 Mon Sep 17 00:00:00 2001 From: Xiong Hongwei Date: Wed, 11 Dec 2024 23:45:04 +0800 Subject: [PATCH 2/5] Modify changelogs, contributors --- CONTRIBUTORS.md | 1 + source/extensions/omni.isaac.lab/docs/CHANGELOG.rst | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 9b3ea57d63..bd48566556 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -49,6 +49,7 @@ Guidelines for modifications: * Giulio Romualdi * Haoran Zhou * HoJin Jeon +* Hongwei Xiong * Jan Kerner * Jean Tampon * Jia Lin Yuan diff --git a/source/extensions/omni.isaac.lab/docs/CHANGELOG.rst b/source/extensions/omni.isaac.lab/docs/CHANGELOG.rst index 48e522f1f0..6f356107c6 100644 --- a/source/extensions/omni.isaac.lab/docs/CHANGELOG.rst +++ b/source/extensions/omni.isaac.lab/docs/CHANGELOG.rst @@ -1,6 +1,17 @@ Changelog --------- +0.27.25 (2024-12-11) +~~~~~~~~~~~~~~~~~~~~ + +Changed +^^^^^^^ + +* Introduced an optional `sensor_cfg` parameter to the :meth:`~omni.isaac.lab.envs.mdp.rewards.base_height_l2` function, enabling the use of + :class:`~omni.isaac.lab.sensors.RayCaster` for height adjustments. For flat terrains, the function retains its previous behavior. +* Improved documentation to clarify the usage of the :meth:`~omni.isaac.lab.envs.mdp.rewards.base_height_l2` function in both flat and rough terrain settings. + + 0.27.24 (2024-12-09) ~~~~~~~~~~~~~~~~~~~~ From 5ace9f90242528226d063a07166b6e718c83a69e Mon Sep 17 00:00:00 2001 From: Xiong Hongwei Date: Wed, 11 Dec 2024 23:49:13 +0800 Subject: [PATCH 3/5] Modify extension version to 0.27.25 --- source/extensions/omni.isaac.lab/config/extension.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/extensions/omni.isaac.lab/config/extension.toml b/source/extensions/omni.isaac.lab/config/extension.toml index 7c9f6b73af..082ec35c24 100644 --- a/source/extensions/omni.isaac.lab/config/extension.toml +++ b/source/extensions/omni.isaac.lab/config/extension.toml @@ -1,7 +1,7 @@ [package] # Note: Semantic Versioning is used: https://semver.org/ -version = "0.27.24" +version = "0.27.25" # Description title = "Isaac Lab framework for Robot Learning" From c8ddad4d6eb72081f86bea4cea2efef6bae786a3 Mon Sep 17 00:00:00 2001 From: Xiong Hongwei Date: Thu, 12 Dec 2024 00:31:43 +0800 Subject: [PATCH 4/5] Modify changelog --- source/extensions/omni.isaac.lab/docs/CHANGELOG.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/extensions/omni.isaac.lab/docs/CHANGELOG.rst b/source/extensions/omni.isaac.lab/docs/CHANGELOG.rst index 6f356107c6..b4003d2180 100644 --- a/source/extensions/omni.isaac.lab/docs/CHANGELOG.rst +++ b/source/extensions/omni.isaac.lab/docs/CHANGELOG.rst @@ -7,7 +7,7 @@ Changelog Changed ^^^^^^^ -* Introduced an optional `sensor_cfg` parameter to the :meth:`~omni.isaac.lab.envs.mdp.rewards.base_height_l2` function, enabling the use of +* Introduced an optional ``sensor_cfg`` parameter to the :meth:`~omni.isaac.lab.envs.mdp.rewards.base_height_l2` function, enabling the use of :class:`~omni.isaac.lab.sensors.RayCaster` for height adjustments. For flat terrains, the function retains its previous behavior. * Improved documentation to clarify the usage of the :meth:`~omni.isaac.lab.envs.mdp.rewards.base_height_l2` function in both flat and rough terrain settings. From 6bddea387a7d01085d1fa1b16bd44cc33260f7ae Mon Sep 17 00:00:00 2001 From: Kelly Guo Date: Thu, 12 Dec 2024 21:48:29 -0500 Subject: [PATCH 5/5] Update extension.toml Signed-off-by: Kelly Guo --- source/extensions/omni.isaac.lab/config/extension.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/extensions/omni.isaac.lab/config/extension.toml b/source/extensions/omni.isaac.lab/config/extension.toml index 082ec35c24..9b53e611d5 100644 --- a/source/extensions/omni.isaac.lab/config/extension.toml +++ b/source/extensions/omni.isaac.lab/config/extension.toml @@ -1,7 +1,7 @@ [package] # Note: Semantic Versioning is used: https://semver.org/ -version = "0.27.25" +version = "0.27.26" # Description title = "Isaac Lab framework for Robot Learning"