Honor selfCollisionEnabled on imported cables - #3709
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthrough
ChangesCable self-collision handling
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Sequence Diagram(s)sequenceDiagram
participant USDParser
participant CableImporter
participant SchemaResolver
participant ModelBuilder
USDParser->>CableImporter: pass enable_self_collisions
CableImporter->>SchemaResolver: resolve cable self-collision setting
SchemaResolver-->>CableImporter: authored value or default
CableImporter->>ModelBuilder: register non-adjacent shape filter pairs
🚥 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: 1
🧹 Nitpick comments (1)
newton/tests/test_import_usd_deformable_cable.py (1)
979-1015: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winCover the remaining self-collision resolution paths.
Add cases for
physxArticulation:enabledSelfCollisionsand unauthored cables imported withenable_self_collisions=False. Current coverage would not catch a fallback-priority or context-default propagation regression.🤖 Prompt for 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. In `@newton/tests/test_import_usd_deformable_cable.py` around lines 979 - 1015, Add coverage to test_welded_graph_self_collision_disabled_filters_non_adjacent_pairs for both physxArticulation:enabledSelfCollisions and unauthored cables imported with enable_self_collisions=False. Exercise each resolution path on the welded cable graph and assert the same within-curve and cross-curve pair filtering, including any expected warning behavior, so fallback priority and context-default propagation are validated.
🤖 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/utils/import_usd_deformable_cable.py`:
- Around line 786-797: Update the curve-articulation import loop so the
self-collision setting is resolved once, then call
_apply_cable_self_collision_filter immediately after each add_rod(...,
wrap_in_articulation=True) using that loop’s local bodies list. Remove the
aggregate cable_bodies filtering so independent curve articulations are never
filtered against one another.
---
Nitpick comments:
In `@newton/tests/test_import_usd_deformable_cable.py`:
- Around line 979-1015: Add coverage to
test_welded_graph_self_collision_disabled_filters_non_adjacent_pairs for both
physxArticulation:enabledSelfCollisions and unauthored cables imported with
enable_self_collisions=False. Exercise each resolution path on the welded cable
graph and assert the same within-curve and cross-curve pair filtering, including
any expected warning behavior, so fallback priority and context-default
propagation are validated.
🪄 Autofix (Beta)
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: 89ebab8b-9727-4b44-b8b1-1a58a440f46b
📒 Files selected for processing (5)
CHANGELOG.mdnewton/_src/utils/import_usd.pynewton/_src/utils/import_usd_deformable_cable.pynewton/_src/utils/import_usd_deformable_utils.pynewton/tests/test_import_usd_deformable_cable.py
889c144 to
35869ff
Compare
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 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/tests/test_import_usd_deformable_cable.py`:
- Around line 988-1002: Update the test around _author_attached_cable_pair and
its case parameterization to exercise both CableA and CableB as the authored
self-collision-disabled member. Apply the attribute to the selected member,
retain the warning assertion for the authored-disabled case, and capture
warnings in the default case to assert that no mixed-settings warning is
emitted.
- Around line 957-964: Extend the parameterized cases in the test around
_deformable_stage and _add_cable_curve to cover PhysX-only self-collision set to
False and conflicting Newton/PhysX authored values. Author
physxArticulation:enabledSelfCollisions for those cases, and assert the resolved
behavior verifies PhysX fallback when Newton is absent and Newton’s
newton:selfCollisionEnabled value takes precedence when both are authored.
🪄 Autofix (Beta)
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: c0792c2d-a200-4502-b69d-4a45015a6088
📒 Files selected for processing (5)
CHANGELOG.mdnewton/_src/utils/import_usd.pynewton/_src/utils/import_usd_deformable_cable.pynewton/_src/utils/import_usd_deformable_utils.pynewton/tests/test_import_usd_deformable_cable.py
🚧 Files skipped from review as they are similar to previous changes (4)
- CHANGELOG.md
- newton/_src/utils/import_usd.py
- newton/_src/utils/import_usd_deformable_utils.py
- newton/_src/utils/import_usd_deformable_cable.py
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
28a22d5 to
a5ee16a
Compare
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 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 `@docs/concepts/usd_parsing.rst`:
- Around line 147-150: Update the self-collision resolution descriptions at both
referenced passages to mention the PhysX fallback attribute
physxArticulation:enabledSelfCollisions alongside newton:selfCollisionEnabled,
or link to the complete priority rule at the later documented section. Ensure
the text explains that the fallback is considered when resolving authored values
and that enable_self_collisions no longer applies once either supported
attribute authors a value.
- Around line 147-150: Update CHANGELOG.md with an imperative [Unreleased] entry
in the appropriate category documenting the self-collision behavior change: any
member-authored value controls the graph, conflicting values warn, and the
enable_self_collisions argument is ignored thereafter.
🪄 Autofix (Beta)
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: df5e7953-d766-4718-afaf-953167e0c274
📒 Files selected for processing (5)
CHANGELOG.mddocs/concepts/usd_parsing.rstnewton/_src/utils/import_usd_deformable_cable.pynewton/_src/utils/import_usd_deformable_utils.pynewton/tests/test_import_usd_deformable_cable.py
🚧 Files skipped from review as they are similar to previous changes (4)
- newton/_src/utils/import_usd_deformable_utils.py
- CHANGELOG.md
- newton/_src/utils/import_usd_deformable_cable.py
- newton/tests/test_import_usd_deformable_cable.py
a5ee16a to
89758c3
Compare
89758c3 to
3ffaece
Compare
3ffaece to
03d153d
Compare
03d153d to
1783866
Compare
The USD cable importer built rod articulations via add_rod / add_rod_graph but never resolved the per-articulation self-collision flag, so authoring newton:selfCollisionEnabled on a cable had no effect while the general rigid importer honored it. This left non-adjacent segments of the same cable colliding even when self-collision was disabled. Resolve self_collision_enabled per cable articulation (newton namespace, with the physxArticulation fallback) and, when disabled, filter collisions between all of the cable's segment shape pairs, mirroring the rigid importer. Welded rod graphs disable self-collision when any member curve opts out, and warn on mixed authoring.
Resolve welded rod-graph self-collision from the values member curves actually author instead of the resolver's injected default. Any authored newton:selfCollisionEnabled=False disables the whole graph, and the mixed authoring warning fires only when authored values genuinely disagree, so welding no longer lets an unauthored sibling's default override an authored value. This matches the single-curve and rigid-articulation paths. Skip the self-collision filter when the cable has collision disabled, so a non-colliding cable no longer emits filter pairs for shapes the broad phase never tests. Resolve and warn only for a colliding graph too, so a non-colliding welded graph with disagreeing authored values no longer emits a spurious mixed-authoring warning. Cover the enable_self_collisions argument, the physxArticulation fallback, the non-colliding-cable skip, and the authored-beats-default paths. Document cable self-collision resolution and the welded-graph rule, and note the enable_self_collisions argument in the changelog entry.
1783866 to
cadc5ee
Compare
| # docs/concepts/usd_parsing.rst. get_value_with_resolver returns resolver=None for an | ||
| # unauthored curve (it stays neutral); the default= below does not feed the result, it | ||
| # only suppresses the unresolved-value diagnostic, so do not drop it as dead code. | ||
| if collision_enabled: |
There was a problem hiding this comment.
🔵 Could you collect all active resolver attributes for each accepted cable prim before this collision check? get_value_with_resolver() only records the resolver that supplies the winning value, and this whole block is skipped for a non-colliding welded graph. That means result["schema_attrs"] can omit authored attributes from the other active resolver, or omit the cable prim entirely. Would something like this work here, with the same collection added in the standalone cable path?
| if collision_enabled: | |
| for key in comp_paths: | |
| if ctx.collect_schema_attrs: | |
| ctx.resolver.collect_prim_attrs(curve_recs[key].prim) | |
| if collision_enabled: |
A regression test with both Newton and PhysX resolvers, plus a non-colliding welded graph, would help pin this down.
Description
Newton's USD cable importer builds rod articulations via
add_rod/add_rod_graph, but it never resolved the per-articulation self-collision flag. As a result, authoringnewton:selfCollisionEnabled(or thephysxArticulation:enabledSelfCollisionsfallback) on a cable had no effect, even though the general rigid importer inparse_usdalready honors it. Non-adjacent segments of the same cable kept colliding even when self-collision was disabled.This PR resolves
self_collision_enabledper cable articulation and, when it is disabled, filters collisions between all of the cable's segment shape pairs, mirroring the rigid importer's behavior. Adjacent segments are already filtered by the CABLE joints'collision_filter_parent, so this only adds the non-adjacent pairs, and cables imported without collision add no pairs at all. Theenable_self_collisionsargument ofadd_usd()/parse_usd()supplies the default when a cable authors nothing, while an authored attribute takes precedence. Welded rod graphs are one articulation, so they resolve self-collision from the values their member curves actually author: any member opting out disables the whole graph, and the importer warns only when authored values genuinely disagree. With the defaultenable_self_collisions=Trueand nothing authored, no filter pairs are added, so existing cable behavior is unchanged.Checklist
CHANGELOG.mdhas been updated (if user-facing change)Test plan
Regression tests were added and fail on
mainwithout the importer change:test_cable_self_collision_disabled_filters_non_adjacent_pairs(single-curve cable, covering the authored attribute, theenable_self_collisionsargument, authored-beats-default, and the non-colliding skip)test_welded_graph_self_collision_disabled_filters_non_adjacent_pairs(welded rod graph, covering disabled, all-disabled, mixed authoring warnings, and authored-beats-default)test_self_collision_disabled_does_not_filter_across_curves_in_one_prim(multi-curve prim: filters within a curve, not across sibling curves)test_cable_self_collision_physx_fallback_needs_resolver(thephysxArticulation:enabledSelfCollisionsfallback applies only whenSchemaResolverPhysxis passed)Bug fix
Steps to reproduce:
UsdGeom.BasisCurvescable withPhysicsCurvesDeformableSimAPIand collision enabled.newton:selfCollisionEnabled = Falseon the cable prim.ModelBuilder.add_usd()and inspectbuilder.shape_collision_filter_pairs.Minimal reproduction:
Summary by CodeRabbit
Bug Fixes
ModelBuilder.add_usd()-created cables now correctly applynewton:selfCollisionEnabledand the importenable_self_collisionsdefault, filtering only non-adjacent self-collisions when disabled.Tests
Documentation