Unverified Commit d8bc7256 authored by Hongwei Xiong's avatar Hongwei Xiong Committed by GitHub

Adds RayCaster rough terrain base height to reward (#1525)

# Description

Enhance `base_height_l2` function to support rough terrain adjustments:

- Added an optional `sensor_cfg` parameter to allow dynamic target
height
  adjustments based on sensor readings (e.g., RayCaster).
- Updated the function to calculate the L2 squared penalty using
adjusted
  height values for rough terrain scenarios.
- Preserved existing behavior for flat terrain by using the fixed
`target_height`.
- Improved compatibility for applications involving uneven terrain.

Fixes #1524

## Type of change

- New feature (non-breaking change which adds functionality)

## 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
- [x ] 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
- [x ] I have added my name to the `CONTRIBUTORS.md` or my name already
exists there

---------
Signed-off-by: 's avatarKelly Guo <kellyg@nvidia.com>
Signed-off-by: 's avatarKelly Guo <kellyguo123@hotmail.com>
Co-authored-by: 's avatarKelly Guo <kellyg@nvidia.com>
Co-authored-by: 's avatarKelly Guo <kellyguo123@hotmail.com>
parent c9f6ac57
......@@ -49,6 +49,7 @@ Guidelines for modifications:
* Giulio Romualdi
* Haoran Zhou
* HoJin Jeon
* Hongwei Xiong
* Jan Kerner
* Jean Tampon
* Jia Lin Yuan
......
[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"
......
Changelog
---------
0.27.26 (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.25 (2024-12-11)
~~~~~~~~~~~~~~~~~~~~
......
......@@ -18,7 +18,7 @@ from omni.isaac.lab.assets import Articulation, RigidObject
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:
......
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