Skip to content

Fix star terrain crash on NumPy 2 - #6910

Merged
AntoineRichard merged 2 commits into
isaac-sim:developfrom
j3soon:j3soon/fix/star-terrain-numpy2
Sep 3, 2026
Merged

Fix star terrain crash on NumPy 2#6910
AntoineRichard merged 2 commits into
isaac-sim:developfrom
j3soon:j3soon/fix/star-terrain-numpy2

Conversation

@j3soon

@j3soon j3soon commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Description

star_terrain computed the bar lengths with np.math.cos and np.math.sin. np.math was an alias for the standard library math module; it was deprecated in NumPy 1.25 and removed in NumPy 2.0. Since Isaac Lab 3.0 ships NumPy 2, any terrain configuration containing the star sub-terrain raised AttributeError: module 'numpy' has no attribute 'math', making MeshStarTerrainCfg unusable.

Use the standard library math module instead. The alias was the same module object, so the generated geometry is unchanged.

The regression went unnoticed because ROUGH_TERRAINS_CFG, the only config covered by the terrain generator tests, has no star sub-terrain. Add a test that generates a star-only terrain, with a bar count that exercises all three branches of the bar-length computation.

Note: The testcase is written by Claude. I've confirmed the code fix myself.

Fixes #6909

Type of change

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

Release backport

  • Backport this pull request to the active release branch after it merges into develop

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 added a changelog fragment under source/<pkg>/changelog.d/ for every touched package (do not edit CHANGELOG.rst or bump extension.toml — CI handles that)
  • I have added my name to the CONTRIBUTORS.md or my name already exists there

`star_terrain` computed the bar lengths with `np.math.cos` and
`np.math.sin`. `np.math` was an alias for the standard library `math`
module; it was deprecated in NumPy 1.25 and removed in NumPy 2.0. Since
Isaac Lab 3.0 ships NumPy 2, any terrain configuration containing the
star sub-terrain raised `AttributeError: module 'numpy' has no attribute
'math'`, making `MeshStarTerrainCfg` unusable.

Use the standard library `math` module instead. The alias was the same
module object, so the generated geometry is unchanged.

The regression went unnoticed because `ROUGH_TERRAINS_CFG`, the only
config covered by the terrain generator tests, has no star sub-terrain.
Add a test that generates a star-only terrain, with a bar count that
exercises all three branches of the bar-length computation.
@j3soon
j3soon requested a review from a team August 5, 2026 12:36
@github-actions github-actions Bot added bug Something isn't working isaac-lab Related to Isaac Lab team labels Aug 5, 2026
@greptile-apps

greptile-apps Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR restores star-terrain generation on NumPy 2 by replacing the removed np.math alias with Python’s standard math module.

  • Updates all three trigonometric bar-length branches without changing their geometry.
  • Adds a star-only terrain generation test that exercises every branch and validates mesh dimensions and origin shape.
  • Documents the NumPy 2 compatibility fix in a changelog fragment.

Confidence Score: 5/5

The PR appears safe to merge with no actionable defects identified.

The standard-library functions are equivalent to the removed NumPy aliases, and the new regression configuration and assertions align with the terrain-generation pipeline.

Important Files Changed

Filename Overview
source/isaaclab/isaaclab/terrains/trimesh/mesh_terrains.py Replaces removed NumPy aliases with equivalent standard-library trigonometric functions, preserving the existing bar-length calculations.
source/isaaclab/test/terrains/test_terrain_generator.py Adds valid star-terrain regression coverage whose five bars exercise all three changed branches and whose assertions match the generator’s 1x1 output.
source/isaaclab/changelog.d/j3soon-star-terrain-numpy2.rst Accurately documents the NumPy 2 failure and compatibility fix.

Reviews (1): Last reviewed commit: "Fix star terrain crash on NumPy 2" | Re-trigger Greptile

@isaaclab-review-bot isaaclab-review-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Isaac Lab Review Bot

The patch replaces the NumPy 2-incompatible np.math access in star_terrain with the equivalent standard-library math functions, adds focused star-terrain generator coverage, and includes the required patch changelog fragment.

  • Design and architecture: The change remains localized to the existing bar-length calculation and preserves terrain configuration, registration, and generator ownership. The regression test appropriately exercises the public TerrainGenerator path with MeshStarTerrainCfg.
  • API: No public API signatures, symbols, or return contracts change. Because np.math previously exposed the standard-library math module, switching to math.cos and math.sin preserves the intended scalar computation while restoring NumPy 2 compatibility.
  • Implementation: The num_bars=5 test configuration reaches all three yaw branches and validates successful generation through mesh dimensions and terrain-origin shape. NumPy remains required elsewhere in the implementation. The changelog fragment is correctly categorized and formatted. Pre-commit was not reported as run, so CI formatting and lint verification remains outstanding.

No blocking issues. No inline issue met the actionable-evidence threshold; the assessment above records the review feedback.

Automated review; human maintainers own approval decisions.

@AntoineRichard AntoineRichard left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for fixing this and adding focused regression coverage! I verified that the new test passes on this commit and fails on the base with the expected NumPy 2 error, and the full pre-commit suite passes. Approved.

@AntoineRichard

Copy link
Copy Markdown
Collaborator

@StafaH @ooctipus can we get one more review to get it merged in.

@ooctipus
ooctipus requested a review from fatimaanes as a code owner September 3, 2026 08:30
@AntoineRichard

Copy link
Copy Markdown
Collaborator

run-ci

@isaaclab-bot isaaclab-bot Bot added ci:run-docker Trigger the on-demand Docker and GPU CI workflow and removed ci:run-docker Trigger the on-demand Docker and GPU CI workflow labels Sep 3, 2026
@AntoineRichard
AntoineRichard merged commit b44ea65 into isaac-sim:develop Sep 3, 2026
50 of 51 checks passed
@isaaclab-bot

isaaclab-bot Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Backported to release/3.0.0 as c7fd163.

isaaclab-bot Bot pushed a commit that referenced this pull request Sep 3, 2026
# Description

`star_terrain` computed the bar lengths with `np.math.cos` and
`np.math.sin`. `np.math` was an alias for the standard library `math`
module; it was deprecated in NumPy 1.25 and removed in NumPy 2.0. Since
Isaac Lab 3.0 ships NumPy 2, any terrain configuration containing the
star sub-terrain raised `AttributeError: module 'numpy' has no attribute
'math'`, making `MeshStarTerrainCfg` unusable.

Use the standard library `math` module instead. The alias was the same
module object, so the generated geometry is unchanged.

The regression went unnoticed because `ROUGH_TERRAINS_CFG`, the only
config covered by the terrain generator tests, has no star sub-terrain.
Add a test that generates a star-only terrain, with a bar count that
exercises all three branches of the bar-length computation.

> Note: The testcase is written by Claude. I've confirmed the code fix
myself.

Fixes #6909

<!-- As a practice, it is recommended to open an issue to have
discussions on the proposed pull request.
This makes it easier for the community to keep track of what is being
developed or added, and if a given feature
is demanded by more than one party. -->

## Type of change

<!-- As you go through the list, delete the ones that are not
applicable. -->

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

## Release backport

- [x] <!-- backport-active-release --> Backport this pull request to the
active release branch after it merges into `develop`

## Checklist

- [x] I have read and understood the [contribution
guidelines](https://isaac-sim.github.io/IsaacLab/main/source/refs/contributing.html)
- [ ] I have run the [`pre-commit` checks](https://pre-commit.com/) with
`./isaaclab.sh --format`
- [ ] I have made corresponding changes to the documentation
- [ ] 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 added a changelog fragment under
`source/<pkg>/changelog.d/` for every touched package (do **not** edit
`CHANGELOG.rst` or bump `extension.toml` — CI handles that)
- [ ] I have added my name to the `CONTRIBUTORS.md` or my name already
exists there

<!--
As you go through the checklist above, you can mark something as done by
putting an x character in it

For example,
- [x] I have done this task
- [ ] I have not done this task
-->

Co-authored-by: ooctipus <zhengyuz@nvidia.com>

(cherry picked from commit b44ea65)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working isaac-lab Related to Isaac Lab team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants