Skip to content
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions source/isaaclab/isaaclab/envs/mdp/terminations.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

from isaaclab.assets import Articulation, RigidObject
from isaaclab.managers import SceneEntityCfg
from isaaclab.sensors import ContactSensor
from isaaclab.sensors import ContactSensor, RayCaster

if TYPE_CHECKING:
from isaaclab.envs import ManagerBasedRLEnv
Expand Down Expand Up @@ -60,16 +60,24 @@ def bad_orientation(


def root_height_below_minimum(
env: ManagerBasedRLEnv, minimum_height: float, asset_cfg: SceneEntityCfg = SceneEntityCfg("robot")
env: ManagerBasedRLEnv,
minimum_height: float,
asset_cfg: SceneEntityCfg = SceneEntityCfg("robot"),
sensor_cfg: SceneEntityCfg | None = None,
) -> torch.Tensor:
"""Terminate when the asset's root height is below the minimum height.
Note:
This is currently only supported for flat terrains, i.e. the minimum height is in the world frame.
For rough terrain, sensor readings can adjust the asset height to account for the terrain.
"""
# extract the used quantities (to enable type-hinting)
asset: RigidObject = env.scene[asset_cfg.name]
return asset.data.root_pos_w[:, 2] < minimum_height
asset_height = asset.data.root_pos_w[:, 2]
if sensor_cfg is not None:
sensor: RayCaster = env.scene[sensor_cfg.name]
# Adjust the asset height using the sensor data
asset_height = asset_height - torch.mean(sensor.data.ray_hits_w[..., 2], dim=1)
return asset_height < minimum_height


"""
Expand Down