Skip to content

Conversation

@luoye2333
Copy link

Description

Adds the rough slope terrain and its cfg, including both inverted and not inverted version. I combine the already defined pyramid_sloped_terrain and random_uniform_terrain method and their config to keep code simple.

Type of change

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

Screenshots

The rough slope terrains and the inverted version generated:

img_v3_02ub_6e035476-ea0d-4ede-aa0b-26326181bf5g

Checklist

  • I have read and understood the contribution guidelines
  • I have run the pre-commit checks with ./isaaclab.sh --format
  • I have made corresponding changes to the documentation
  • 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
  • I have added my name to the CONTRIBUTORS.md or my name already exists there

@luoye2333 luoye2333 requested a review from Mayankm96 as a code owner January 27, 2026 07:23
@github-actions github-actions bot added the isaac-lab Related to Isaac Lab team label Jan 27, 2026
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Jan 27, 2026

Greptile Overview

Greptile Summary

This PR introduces rough slope terrain generation by combining pyramid sloped terrain with random uniform noise. However, there is a critical bug in the platform clipping logic at hf_terrains.py:165 that will flatten the entire terrain instead of just preserving the center platform.

Key Changes

  • Added rough_slope_terrain() function that combines pyramid_sloped_terrain and random_uniform_terrain
  • Added config classes HfRoughSlopeTerrainCfg and HfInvertedRoughSlopeTerrainCfg using multiple inheritance
  • Updated copyright year to 2026 across modified files
  • Added contributor name to CONTRIBUTORS.md

Critical Issue

The platform preservation logic uses np.clip(hf, min(0, z_pf), max(0, z_pf)) on the entire terrain array, which will clamp all height values to a narrow range, effectively flattening the rough slope. This logic should instead set only the center platform region to a constant height.

Additional Concerns

  • Missing comprehensive docstring for rough_slope_terrain() function
  • Config class docstrings don't follow project conventions (missing triple quotes)
  • No tests added to verify the terrain generates correctly

Confidence Score: 1/5

  • This PR contains a critical bug that will cause the feature to not work as intended
  • The platform clipping logic at line 165 will flatten the entire terrain by clamping all heights to a narrow range between 0 and z_pf, completely negating both the slope and roughness. This is a fundamental logic error that breaks the core functionality.
  • Critical attention needed for hf_terrains.py - the platform preservation logic must be rewritten before merge

Important Files Changed

Filename Overview
source/isaaclab/isaaclab/terrains/height_field/hf_terrains.py Added rough_slope_terrain function with critical platform clipping bug that flattens entire terrain
source/isaaclab/isaaclab/terrains/height_field/hf_terrains_cfg.py Added config classes for rough slope terrains with incomplete docstrings

Sequence Diagram

sequenceDiagram
    participant User
    participant Decorator as height_field_to_mesh
    participant RST as rough_slope_terrain
    participant PST as pyramid_sloped_terrain.__wrapped__
    participant RUT as random_uniform_terrain.__wrapped__

    User->>Decorator: Call rough_slope_terrain(difficulty, cfg)
    Decorator->>Decorator: Modify cfg.size for border
    Decorator->>RST: Call unwrapped function
    RST->>PST: Get sloped terrain heights
    PST-->>RST: Return np.int16 array (terrain1)
    RST->>RUT: Get random noise heights
    RUT-->>RST: Return np.int16 array (terrain2)
    RST->>RST: Combine: hf = terrain1 + terrain2
    RST->>RST: Calculate platform position (x_pf, y_pf)
    RST->>RST: Get platform height: z_pf = hf[x_pf, y_pf]
    RST->>RST: ⚠️ BUG: Clip entire terrain to [min(0, z_pf), max(0, z_pf)]
    RST-->>Decorator: Return flattened height field
    Decorator->>Decorator: Convert height field to mesh
    Decorator-->>User: Return mesh and origin
Loading

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

5 files reviewed, 5 comments

Edit Code Review Agent Settings | Greptile

x_pf = width_pixels // 2 - platform_width
y_pf = length_pixels // 2 - platform_width
z_pf = hf[x_pf, y_pf]
hf = np.clip(hf, min(0, z_pf), max(0, z_pf))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This clips the entire terrain to a flat range, eliminating both the slope and roughness. The logic should only flatten the platform region, not the whole terrain.

The correct approach: calculate platform boundaries and only set hf[center_region] = z_pf, similar to how pyramid_sloped_terrain builds the platform before clipping.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the pyramid slope terrain, this clip is ok. Though the whole nparray is clipped. It is same with the pyramid_sloped_terrain method.

Comment on lines +95 to +96
class HfRoughSlopeTerrainCfg(HfRandomUniformTerrainCfg, HfPyramidSlopedTerrainCfg):
"rough slope cfg, combine the cfg of random terrain and smooth slope terrain"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing proper docstring formatting - should use triple quotes and follow the same style as other config classes (e.g., HfInvertedPyramidSlopedTerrainCfg on lines 82-89)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Comment on lines +102 to +103
class HfInvertedRoughSlopeTerrainCfg(HfRandomUniformTerrainCfg, HfInvertedPyramidSlopedTerrainCfg):
"rough slope cfg, combine the cfg of random terrain and smooth slope terrain"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing proper docstring formatting - should use triple quotes and follow the same style as other config classes

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!



@height_field_to_mesh
def rough_slope_terrain(difficulty: float, cfg: hf_terrains_cfg.HfRoughSlopeTerrainCfg) -> np.ndarray:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing docstring. Other terrain functions have comprehensive docstrings explaining parameters, return values, and behavior (see pyramid_sloped_terrain at line 83 or random_uniform_terrain at line 21).

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@height_field_to_mesh
def rough_slope_terrain(difficulty: float, cfg: hf_terrains_cfg.HfRoughSlopeTerrainCfg) -> np.ndarray:
# combine the two methods
terrain1 = pyramid_sloped_terrain.__wrapped__(difficulty, cfg)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensure both wrapped functions return arrays of matching dimensions before addition - test with various cfg.size and cfg.border_width values

@Mayankm96 Mayankm96 force-pushed the main branch 2 times, most recently from 2ef7fc8 to f3061a4 Compare January 28, 2026 16:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

isaac-lab Related to Isaac Lab team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant