IsaacLab icon indicating copy to clipboard operation
IsaacLab copied to clipboard

Support root_height_below_minimum for rough terrain

Open hany606 opened this issue 1 month ago • 1 comments

Description

Similar to rewards.base_height_l2 https://github.com/isaac-sim/IsaacLab/blob/7e8ebe67ef3e3c280eb3fda39443d643317fdeca/source/isaaclab/isaaclab/envs/mdp/rewards.py#L100-L122

I have added the support of rough terrains to terminations.root_height_below_minimum

Fixes #3986

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Checklist

  • [X] I have read and understood the contribution guidelines
  • [x] I have run the pre-commit checks 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
  • [ ] 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

hany606 avatar Nov 10 '25 13:11 hany606

Greptile Overview

Greptile Summary

This PR adds support for rough terrain to the root_height_below_minimum termination function in IsaacLab's MDP module. The change introduces an optional sensor_cfg parameter that allows the function to use RayCaster sensor data to calculate asset height relative to the terrain surface, rather than using absolute world coordinates. This follows the same pattern as the existing rewards.base_height_l2 function, providing consistent terrain-aware height calculations across the codebase.

The modification addresses a limitation where the termination function only worked on flat terrains. In rough terrain scenarios like Inverted Pyramid Stairs, assets start from bases placed below the flat terrain level, making absolute world height comparisons ineffective. With this change, when a sensor configuration is provided, the function adjusts the asset height by subtracting the mean height of the sensor's ray hits from the asset's world position, enabling proper height-based terminations on uneven surfaces.

Important Files Changed

Filename Score Overview
CONTRIBUTORS.md 5/5 Added "Hany Hamed" to the contributors list in alphabetical order
source/isaaclab/isaaclab/envs/mdp/terminations.py 4/5 Added RayCaster support and sensor_cfg parameter to root_height_below_minimum function for rough terrain compatibility

Confidence score: 4/5

  • This PR makes a focused change that addresses a specific terrain-handling limitation with minimal risk
  • Score reflects well-structured implementation following existing patterns, though missing comprehensive tests for the new functionality
  • Pay close attention to the terminations.py file to ensure the sensor data handling logic is correct and robust

Sequence Diagram

sequenceDiagram
    participant User
    participant "ManagerBasedRLEnv" as Env
    participant "RigidObject" as Asset
    participant "RayCaster" as Sensor
    participant "torch" as Torch

    User->>Env: "Call root_height_below_minimum(env, minimum_height, asset_cfg, sensor_cfg)"
    Env->>Asset: "Get asset from scene[asset_cfg.name]"
    Asset->>Env: "Return asset object"
    Env->>Asset: "Get asset.data.root_pos_w[:, 2]"
    Asset->>Env: "Return asset height (z-coordinate)"
    
    alt sensor_cfg is not None
        Env->>Sensor: "Get sensor from scene[sensor_cfg.name]"
        Sensor->>Env: "Return RayCaster sensor object"
        Env->>Sensor: "Get sensor.data.ray_hits_w[..., 2]"
        Sensor->>Env: "Return ray hit z-coordinates"
        Env->>Torch: "Calculate mean(ray_hits_w[..., 2], dim=1)"
        Torch->>Env: "Return mean sensor readings"
        Env->>Env: "Adjust asset_height = asset_height - mean_sensor_readings"
    end
    
    Env->>Torch: "Compare asset_height < minimum_height"
    Torch->>Env: "Return boolean tensor"
    Env->>User: "Return termination condition tensor"

greptile-apps[bot] avatar Nov 12 '25 10:11 greptile-apps[bot]