Create heightfield from wp.Mesh#3624
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
💤 Files with no reviewable changes (1)
📝 WalkthroughWalkthroughThe PR adds Warp-based mesh-to-heightfield rasterization, a ChangesMesh heightfield construction
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant Client
participant Heightfield.create_from_mesh
participant rasterize_mesh_to_heightfield
participant _rasterize_mesh_kernel
participant wp.Mesh
Client->>Heightfield.create_from_mesh: provide mesh and resolution
Heightfield.create_from_mesh->>rasterize_mesh_to_heightfield: rasterize mesh
rasterize_mesh_to_heightfield->>wp.Mesh: read bounds and device
rasterize_mesh_to_heightfield->>_rasterize_mesh_kernel: launch sampling grid
_rasterize_mesh_kernel->>wp.Mesh: cast downward rays
_rasterize_mesh_kernel-->>rasterize_mesh_to_heightfield: write hit or floor heights
rasterize_mesh_to_heightfield-->>Heightfield.create_from_mesh: return heights and XY bounds
Heightfield.create_from_mesh-->>Client: return Heightfield and centered transform
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@newton/_src/geometry/types.py`:
- Around line 2223-2237: Update the public docstring for the rasterization
method around the terrain description and arguments: describe supported terrain
as single-valued in Z, including sloped planes, rather than requiring constant
elevation per cell. Add “[m]” units to the mesh coordinate and placement
translation descriptions, while preserving the existing resolution and grid
behavior documentation.
In `@newton/_src/utils/heightfield.py`:
- Around line 119-120: Validate max_cells_per_axis is at least 2 before the ncol
and nrow calculations in the heightfield dimension logic, rejecting smaller
values instead of allowing the max(2, ...) expressions to exceed the configured
upper bound. Keep the existing dimension calculations unchanged for valid
inputs.
In `@newton/utils.py`:
- Around line 35-37: Remove the redundant “heightfield utils” banner comment
near the top of newton/utils.py, leaving the following import and surrounding
code unchanged.
🪄 Autofix (Beta)
❌ Autofix failed (check again to retry)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro Plus
Run ID: 89ea7a1f-de42-4479-97c9-e5bcc5ed9462
📒 Files selected for processing (6)
CHANGELOG.mddocs/api/newton_utils.rstnewton/_src/geometry/types.pynewton/_src/utils/heightfield.pynewton/tests/test_heightfield.pynewton/utils.py
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
|
Note Autofix is a beta feature. Expect some limitations and changes as we gather feedback and continue to improve it. An unexpected error occurred while generating fixes: Not Found - https://docs.github.com/rest/git/refs#get-a-reference |
Description
Downstream in IsaacLab, Terrain-based tasks handed the Newton MuJoCo solver a single huge terrain mesh (626k verts / 1.19M faces for AnymalD Rough). MuJoCo's
spec.compileruns qhull / inertia / BVH over every face, dominating solver initialization.The correct behaviour is to pass to newton a Heightfield as a Heightfield and not a mesh. This requires rasterizing the mesh terrain from USD into the correct heightfield data. This PR adds the option to create newton Heightfields from wp.Mesh inputs as an alternative construction mechanism.
Gains (
Isaac-Velocity-Rough-AnymalD, warm, 64 envs)nmesh=1, 626k vnmesh=0, nhfield=1spec.compileSummary by CodeRabbit
Heightfieldfactory that returns both the heightfield and a placement transform that centers the grid over the mesh.