Fixes default shape margin field name in Newton manager#5289
Fixes default shape margin field name in Newton manager#5289AntoineRichard merged 2 commits intoisaac-sim:developfrom
Conversation
Greptile SummaryFixes a silent typo in Confidence Score: 5/5Safe to merge — single-line corrective fix with no API changes, validated on multiple robots. The change is a one-line typo fix, extensively validated by the author on five robot platforms with quantitative training metrics. Changelog and version bump follow project rules. The only remaining finding (P2) is a pre-existing inconsistency in No files require special attention for merge. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[NewtonManager.create_builder] -->|Creates| B[ModelBuilder]
B -->|Before fix| C["default_shape_cfg.contact_margin = 0.01\n(dead attribute, margin stays 0.0)"]
B -->|After fix| D["default_shape_cfg.margin = 0.01\n(margin correctly applied)"]
D --> E[builder.finalize → Model]
C --> F[builder.finalize → Model]
E -->|shape margin = 0.01 m| G[Physics Simulation]
F -->|shape margin = 0.0 m| H[Degraded contact quality]
style D fill:#90EE90
style C fill:#FFB6C1
style H fill:#FFB6C1
style G fill:#90EE90
|
There was a problem hiding this comment.
🤖 Isaac Lab Review Bot
Summary
Clean, well-diagnosed one-line bug fix. The create_builder() method was setting default_shape_cfg.contact_margin = 0.01, but Newton's ModelBuilder.ShapeConfig defines the field as margin — not contact_margin. Python silently accepted the dynamic attribute, so the intended 1 cm default shape margin was never applied to the actual simulation. The fix correctly renames the attribute to margin.
Design Assessment
Design is sound. This is the right fix at the right level — correcting the field name where the default is applied. The approach is minimal and surgical. Version bump and CHANGELOG entry are included and follow the existing conventions.
Findings
🔵 Suggestion: Defensive guard against future typos — newton_manager.py:425
This class of bug (Python silently accepting dynamic attribute assignment on a config object) is insidious because there's no runtime error. The PR author's investigation confirms this went undetected across multiple commits (#4646, #4761, #4822). Consider whether ShapeConfig (upstream in Newton) could benefit from __slots__ or a frozen dataclass to prevent silent attribute creation — though that's outside this PR's scope and would be an upstream Newton change.
Test Coverage
This is a field-name typo fix with no new logic paths. The author's manual test plan is thorough (Go1, Go2, A1, H1, Cassie on rough terrain) and demonstrates a dramatic improvement (reward 1.0 → 18.77 at 300 iter). An automated regression test here would require a full Newton simulation harness and is disproportionate for a one-character-class fix. No new tests needed.
CI Status
✅ All checks passing (labeler: pass).
Verdict
Ship it 🟢
Textbook bug fix: clear diagnosis, minimal change, proper documentation, version bump, and validated across multiple robot configurations. The CHANGELOG entry is well-written and explains both the cause and the impact. Nice work.
AntoineRichard
left a comment
There was a problem hiding this comment.
LGTM, thanks @hujc7! As mentioned, make a separate PR for testing these fields!
|
@camevor do you know why the newton tests fails? It looks like the force reported are larger than expected when the contact margin are large? |
| """ | ||
| builder = ModelBuilder(up_axis=up_axis or cls._up_axis, **kwargs) | ||
| builder.default_shape_cfg.contact_margin = 0.01 | ||
| builder.default_shape_cfg.margin = 0.01 |
There was a problem hiding this comment.
ShapeConfig.margin is not the same thing as ShapeConfig.contact_margin used to be. You want to set ShapeConfig.gap or ModelBuilder.rigid_gap (fallback) instead.
|
Please note that this change does not migrate the former |
This is likely a test stability issue: The contact sensor is inherently quite noisy, so we should add some averaging for these quantitative tests. I'll prepare a PR with averaging to make the tests less flaky. It's also worth considering adding this to the sensor itself (e.g. averaging over solver substeps). |
|
Thanks, @camevor ! Running a test with updated field name. It did previous improve training so I will also investigate the impact of setting margin. Will check back |
c8bc84d to
d326ba7
Compare
|
gap alone does not fix rough env but should still remain the right fix for the intended field. |
d326ba7 to
34f4d2e
Compare
The ShapeConfig field ``contact_margin`` was renamed to ``gap`` in Newton PR isaac-sim#1732. The incorrect attribute name created a dead property that Python silently accepted, so the intended 1 cm default shape gap was never applied.
34f4d2e to
0188c28
Compare
Summary
Fix incorrect attribute name
contact_margin→gapon NewtonShapeConfiginNewtonManager.create_builder().Newton PR #1732 renamed
contact_margintogap(broad-phase AABB expansion). The IsaacLab code was never updated, creating a dead attribute that Python silently accepted. The intended 1 cm default shape gap was never applied.Newton PR #1732 rename mapping
thicknessmargincontact_margingaprigid_contact_marginrigid_gapTimeline
contact_marginvalid?51ce35e(hascontact_margin)contact_margin = 0.01contact_margin→gapv0.2.3(after rename)contact_margincontact_marginAblation: gap vs margin
We conducted an ablation study to understand the impact. Note:
margin(shape surfaceextension) is a different field from
gap(broad-phase range). The original code intendedto set
gap, but settingmarginalso has a significant positive effect on training forrough terrain locomotion.
gapmargingap=0.01onlymargin=0.01onlygap=0.01+margin=0.01This PR fixes the correct field migration (
contact_margin→gap). Themarginsettingfor rough terrain contact quality will be addressed separately in the rough terrain env PR
(#5248) via a new
default_shape_marginconfig field onNewtonCfg.Test plan
contact_marginis not a field onShapeConfig(Newton 1.1.0.dev0)gapis the correct replacement field per Newton PR [Proposal] Incorrect clipping of actions #1732