Skip to content

Commit 5baabff

Browse files
Keep schema fallbacks source-owned
Let source-neutral adapters supply registered schema metadata at resolution time while keeping the PXR registry authoritative for USD imports. Remove the copied fallback catalog so unregistered schemas retain only their compatibility behavior.
1 parent 7cbc52a commit 5baabff

9 files changed

Lines changed: 420 additions & 458 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@
2424
- Add opt-in filtering of static-static, static-kinematic, and kinematic-kinematic contacts during broad-phase collision detection. Set `CollisionPipeline(include_static_kinematic_pairs=False)` to enable filtering; the default preserves existing contact generation. `Model.shape_contact_pairs` remains an unfiltered superset for direct consumers such as `SolverKamino` and hydroelastic SDF setup.
2525
- Add opt-in `body_frame_origin="com"` to `ModelBuilder.add_rod()` and `ModelBuilder.add_rod_graph()` for COM-centered cable capsule body frames.
2626
- Add `sign_method` argument to `Mesh.build_sdf` and `SDF.create_from_mesh` support for a `"normal"` (angle-weighted pseudo-normal) sign strategy, for selecting the inside/outside sign of the baked SDF (`"auto"`, `"parity"`, `"winding"`, or `"normal"`).
27-
- Add opt-in source-neutral USD schema resolution through `newton.usd.create_schema_resolution()` and `ModelBuilder.add_usd(schema_resolution=...)`, allowing populated scene sources to reuse Newton's schema precedence, conversions, and built-in fallbacks.
28-
- Add source-neutral USD schema resolution through `newton.usd.SchemaResolution` and `ModelBuilder.add_usd(schema_resolution=...)`, allowing populated scene sources to reuse Newton's schema precedence, conversions, and built-in fallbacks.
27+
- Add source-neutral USD schema resolution through `newton.usd.SchemaResolution` and `ModelBuilder.add_usd(schema_resolution=...)`, allowing populated scene adapters to reuse Newton's precedence and conversions with adapter-supplied registered schema fallbacks.
2928
- Add `forward_depth_image` output support to `SensorTiledCamera.update()` and `SensorTiledCamera.utils.create_forward_depth_image_output()` for native forward-depth rendering without post-processing `depth_image`.
3029
- Add optional `shear_stiffness`/`shear_damping` and `twist_stiffness`/`twist_damping` controls to `ModelBuilder.add_joint_cable()`, `ModelBuilder.add_rod()`, and `ModelBuilder.add_rod_graph()`; omitted shear defaults to stretch and omitted twist defaults to bend for compatibility.
3130
- Add `newton.utils.CableStiffness` and extend `newton.utils.create_cable_stiffness_from_elastic_moduli()` with `poissons_ratio`/`shear_modulus` inputs that include torsional `GJ/L` stiffness.

docs/design/schema-resolution.md

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,20 @@ the current `ModelBuilder.add_usd()` construction path and behavior. One typed
1919
existing `schema_resolvers=` argument constructs that object internally.
2020
Applied schema identity is part of the input: an applied schema owns the
2121
properties it defines, including its USD fallbacks. Resolver definitions
22-
identify ownership and conversion. A private catalog supplies built-in Newton,
23-
PhysX, and MuJoCo fallbacks when their schema plugins are unavailable. Batched
24-
resolution, Warp functions, and direct ModelBuilder buffer population are
25-
deliberately deferred.
22+
identify ownership and conversion. The source adapter supplies registered
23+
schema fallbacks: the PXR adapter reads them from `Usd.SchemaRegistry`, while a
24+
PXR-free adapter provides the equivalent versioned schema metadata explicitly.
25+
Batched resolution, Warp functions, and direct ModelBuilder buffer population
26+
are deliberately deferred.
2627

2728
## Goals
2829

2930
- Keep core Newton as the single owner of schema precedence and conversion.
3031
- Preserve the behavior of `add_usd()` and `schema_resolvers=` by default.
3132
- Resolve values and applied schemas supplied without a `Usd.Prim`.
3233
- Read fallbacks from registered USD schemas on the PXR path.
33-
- Share built-in fallbacks with schema-neutral sources.
34-
- Let callers override or extend the fallback catalog for other schema versions.
34+
- Accept registered schema fallbacks from schema-neutral source adapters.
35+
- Keep schema metadata versioning in the adapter that owns the scene source.
3536
- Keep the external mechanism small and hide candidates, provenance, and storage.
3637
- Make the scalar contract suitable for later columnar and Warp execution.
3738
- Let non-PXR scene consumers reuse the resolver without changing their
@@ -86,13 +87,14 @@ fallback(schema_name, attribute_name) -> raw USD value or missing
8687

8788
The PXR adapter reads authored values and applied/type metadata, then asks
8889
`Usd.SchemaRegistry` for the composed prim definition and its attribute
89-
fallbacks. A non-PXR source provides already-composed values and recorded
90-
schema identity; the resolver uses Newton's private fallback catalog. Resolver
91-
priority, transformations, and selected-source provenance are shared. Once the
92-
composed policy is active, an applied schema that owns a requested property but
93-
has no fallback in either the registry or catalog fails instead of silently
94-
using a builder default. During the audit period, that future error does not
95-
break the legacy result.
90+
fallbacks. A non-PXR source provides already-composed values, recorded schema
91+
identity, and the fallbacks for schemas it treats as registered. Resolver
92+
priority, transformations, and selected-source provenance are shared.
93+
94+
Schemas without authoritative metadata remain a second-class compatibility
95+
path. Their authored values still participate in resolver priority, while
96+
importer defaults precede resolver compatibility defaults. They do not claim
97+
registered-schema fallback ownership.
9698

9799
Canonical USDPhysics descriptors remain importer inputs. Resolvers only supply
98100
extension-schema properties such as armature, friction, contact parameters,
@@ -131,17 +133,17 @@ The same object resolves mapping inputs directly:
131133
```python
132134
resolution = newton.usd.SchemaResolution(
133135
resolvers,
134-
# Only needed for custom schemas or version-specific overrides.
135-
schema_fallbacks={
136-
"ExampleJointAPI": {"example:armature": 0.0},
137-
},
138136
)
139137
requirements = resolution.requirements(PrimType.JOINT)
140138
schemas = resolution.schemas(PrimType.JOINT)
141139
properties = resolution.resolve(
142140
PrimType.JOINT,
143141
values,
144142
schemas=applied_schemas,
143+
# Registered schema metadata supplied by this source adapter.
144+
schema_fallbacks={
145+
"ExampleJointAPI": {"example:armature": 0.0},
146+
},
145147
defaults={"armature": builder.default_joint_cfg.armature},
146148
)
147149
```
@@ -165,9 +167,10 @@ path, not the future hot path.
165167
`SchemaResolution` through the PXR adapter. It constructs a default Newton
166168
resolution when neither argument is supplied and wraps `schema_resolvers=` when
167169
that shorthand is used. The adapter caches composed schema fallbacks by prim
168-
type and schema. An explicitly supplied fallback table is used only when the
169-
registered schema cannot provide the property. Attribute collection for the
170-
returned `schema_attrs` dictionary remains separate and unchanged.
170+
type and schema. `Usd.SchemaRegistry` remains authoritative on this path;
171+
`schema_fallbacks` is input for source-neutral `resolve()` calls. Attribute
172+
collection for the returned `schema_attrs` dictionary remains separate and
173+
unchanged.
171174

172175
The first implementation does not move every higher-level rule out of
173176
`import_usd.py`. Source-specific branches such as MuJoCo raw-limit provenance,
@@ -178,8 +181,8 @@ small behavior-preserving changes after the common scalar engine is established.
178181

179182
A schema-aware scene source supplies attribute values plus typed and applied
180183
schema identities to the same `SchemaResolution` inside its existing body,
181-
shape, and joint loops. It uses Newton's built-in fallback catalog, so it owns
182-
no schema-default table. Topology discovery, ordering, and
184+
shape, and joint loops. It also supplies the registered fallbacks for the
185+
schema versions its transport exposes. Topology discovery, ordering, and
183186
`ModelBuilder.add_*()` calls remain source concerns. Equivalent local
184187
precedence and conversion code can be removed as each entity family moves to
185188
the shared engine.
@@ -217,8 +220,9 @@ host to report after execution. Diagnostic representation is not public.
217220
authored nonzero, resolver ordering, transformations, and missing values.
218221
- The same values and schema identity resolve equally through PXR and mapping
219222
sources.
220-
- Every built-in owned mapping has an entry in the private fallback catalog.
221-
- Registered Newton schema fallbacks match the catalog exactly.
223+
- Adapter-supplied fallbacks establish registered ownership without importing
224+
PXR.
225+
- Registered Newton schema fallbacks are read directly from the PXR registry.
222226
- Legacy PXR-only callbacks continue to work and fail explicitly through the
223227
source-neutral facade.
224228
- Later cross-source tests compare final builder/model fields against

newton/_src/sim/builder.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3395,6 +3395,7 @@ def add_usd(
33953395
parse_mujoco_options: bool = True,
33963396
mesh_maxhullvert: int | None = None,
33973397
schema_resolvers: list[SchemaResolver] | None = None,
3398+
schema_resolution: SchemaResolution | None = None,
33983399
use_applied_schema_fallbacks: bool = False,
33993400
force_position_velocity_actuation: bool = False,
34003401
convert_mjc_equality_constraints: bool = True,
@@ -3520,8 +3521,12 @@ def add_usd(
35203521

35213522
.. experimental::
35223523

3523-
The ``schema_resolvers`` and ``use_applied_schema_fallbacks``
3524-
arguments may change without prior notice.
3524+
The ``schema_resolvers``, ``schema_resolution``, and
3525+
``use_applied_schema_fallbacks`` arguments may change without
3526+
prior notice.
3527+
schema_resolution: Reusable source-neutral schema resolution. It is
3528+
mutually exclusive with ``schema_resolvers`` and owns the applied
3529+
schema fallback policy when provided.
35253530
use_applied_schema_fallbacks: True uses an applied schema's registered
35263531
USD fallback before importer defaults and lower-priority resolvers,
35273532
opting into the future behavior without migration warnings. The
@@ -3648,6 +3653,7 @@ def add_usd(
36483653
parse_mujoco_options=parse_mujoco_options,
36493654
mesh_maxhullvert=mesh_maxhullvert,
36503655
schema_resolvers=schema_resolvers,
3656+
schema_resolution=schema_resolution,
36513657
use_applied_schema_fallbacks=use_applied_schema_fallbacks,
36523658
force_position_velocity_actuation=force_position_velocity_actuation,
36533659
convert_mjc_equality_constraints=convert_mjc_equality_constraints,

newton/_src/usd/_schema_fallbacks.py

Lines changed: 0 additions & 158 deletions
This file was deleted.

0 commit comments

Comments
 (0)