Repository navigation
Raise a clear error for height-field generators without an origin - #8936
Conversation
Since #4470, height_field_to_mesh requires generators to return (height_field, origin). A generator that still returns only the height field failed inside the decorator with "ValueError: too many values to unpack (expected 2)", which names neither the generator nor the contract change, and left cfg.size shrunk. Check the generator's return value; if it is not a 2-tuple, restore cfg.size and raise a TypeError that names the generator and the expected (height_field, origin) return. Signed-off-by: Daniel Florea <[email protected]>
[Medium impact] The PR appears safe to merge; no actionable issues were found. SummaryThe PR gives custom height-field generators a clearer error when they omit the origin.
Reviews (1) · Last reviewed commit: "Raise a clear error for height-field gen..." · Reviewed by Greptile |
There was a problem hiding this comment.
Isaac Lab Review Bot
Needs attention: Design and architecture (1), Compatibility and deprecation (1), Test quality (1). Other reviewed categories look good.
- PR description: The body matches the guard, documentation, changelog, and regression test, but “non-breaking” is inaccurate because the tuple-only check rejects previously accepted two-item iterables; disclose that narrowing.
- Design and architecture: The new exceptional restore duplicates success-path cleanup and still leaks temporary
cfg.sizewhen the generator or border assignment raises; restore it once withtry/finally. - Scope and over-engineering: No over-engineering issues.
- API: API changes look good.
- Compatibility and deprecation: Breaking changes: the tuple-only guard rejects two-item lists and other iterable returns previously accepted by unpacking; preserve iterable unpacking or provide a complete deprecation bridge.
- Implementation: Implementation looks good.
- Style consistency: Style consistency looks good.
- Test quality: The regression test covers the error and restored size, but its unused pixel calculations repeat production logic; return any array directly and remove the extra import.
Minor fixes needed. Posted 3 inline findings.
Automated review; human maintainers own approval decisions.
Address review feedback on the height-field return check: - Unpack the generator's result and turn only an unpacking failure into the TypeError, so two-item iterables such as lists keep working as before instead of being rejected by a tuple check. - Restore cfg.size once in a finally block, which also covers a generator that raises and a failing border assignment. - Drop the unused shape setup from the regression test. Signed-off-by: Daniel Florea <[email protected]>
AntoineRichard
left a comment
There was a problem hiding this comment.
Thanks for the fix @dfloreaa LGTM!
|
run-ci |
|
Thanks for the review @AntoineRichard! The Docker tests passed. ARM CI failed on test_operational_space.py, a Franka controller test that hit the same "Failed to get DOF velocities" error on #7735 too, so I don't think it's related to this fix. Could you run it again when you get a chance? Thank you :) |
Description
Since #4470, a function decorated with
height_field_to_meshmust return the height field together with the terrain origin, and the decorator unpacks the result directly:A custom generator written against the previous contract returns only the height field, so terrain generation fails inside the decorator with
The error names neither the generator nor the contract change, and it comes after the decorator has already shrunk
cfg.sizefor the generator without restoring it. We hit this with downstream height-field generators when moving a project fromrelease/3.0.0-beta2tomain.This turns a failure to unpack the generator's result into a
TypeErrorthat names the generator and the expected(height_field, origin)return. Any two-item return that unpacked before, such as a list, still works. The decorator now restorescfg.sizein afinallyblock, so the size is also restored when the generator or the border assignment raises. The decorator's docstring now lists both errors it raises in aRaises:section. Generators that already return a tuple are unchanged, which covers all six built-in height-field terrains.release/3.0.0does not contain #4470, so no backport is needed.Type of change
Checklist
pre-commitchecks withuv run isaaclab --formatsource/<pkg>/changelog.d/for every touched package (do not editCHANGELOG.rstor bump package versions — CI handles that)CONTRIBUTORS.mdor my name already exists thereTesting
test_height_field_generator_without_origin_raises_type_errortotest/terrains/test_terrain_generator.py: a decorated generator that returns only the height field must raise theTypeErrorand leavecfg.sizeunchanged. It fails onmainwith theValueErrorabove and passes with the fix.test_terrain_generator.pypasses locally (28 passed).uv run isaaclab --formatpasses, including the changelog-fragment check.