Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
182dcb9
Add rigid-body physics-material schema fragments
vidurv-nvidia Jun 28, 2026
17d7c0a
Fix pre-commit lint in material fragment test
vidurv-nvidia Jun 28, 2026
b8ba64e
Clarify physics-material dispatcher stage and regex semantics
vidurv-nvidia Jun 28, 2026
bbf9c71
Validate physics-material fragment lists in dispatcher
vidurv-nvidia Jun 28, 2026
bd0f063
Merge develop to pick up docker install fixes (#6262)
vidurv-nvidia Jun 29, 2026
a8bc6aa
Complete rigid-body material fragment family
vidurv-nvidia Jul 1, 2026
2d70ad4
Fix rigid-material guard bugs from prior review fix
vidurv-nvidia Jul 2, 2026
bb3226f
Add density to the legacy rigid material base cfg
vidurv-nvidia Jul 3, 2026
85592af
Add Newton contact attrs to the legacy material cfg
vidurv-nvidia Jul 3, 2026
435240e
Route generated-terrain material through the dispatcher
vidurv-nvidia Jul 3, 2026
e0e647d
Route the default physics material through the dispatcher
vidurv-nvidia Jul 3, 2026
31abf2c
Spawn compliant-contact material via the dispatcher
vidurv-nvidia Jul 3, 2026
c84801e
Narrow shape spawner material slot to rigid materials
vidurv-nvidia Jul 3, 2026
ffa19f3
Reject non-current stage on legacy material path
vidurv-nvidia Jul 3, 2026
1983a59
Add structural parity and slot-typing tests
vidurv-nvidia Jul 3, 2026
9553f38
Update material changelog for slot and parity fixes
vidurv-nvidia Jul 3, 2026
21b2a5e
Note PhysX default-material change in changelog
vidurv-nvidia Jul 3, 2026
3c86ca6
Document default material type change as breaking
vidurv-nvidia Jul 3, 2026
e1bb60b
Tighten material fragment integration boundaries
ooctipus Jul 4, 2026
419d1c0
Remove rigid policy from material dispatcher
ooctipus Jul 4, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions docs/source/api/lab/isaaclab.sim.spawners.rst
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,9 @@ Materials
MdlFileCfg
GlassMdlCfg
PhysicsMaterialCfg
RigidBodyMaterialBaseCfg
RigidBodyMaterialFragment
UsdPhysicsRigidBodyMaterialCfg
RigidBodyMaterialCfg
DeformableBodyMaterialBaseCfg
SurfaceDeformableBodyMaterialBaseCfg
Expand Down Expand Up @@ -303,8 +306,27 @@ Physical Materials
:members:
:exclude-members: __init__, func

.. autofunction:: spawn_physics_material

.. autofunction:: spawn_rigid_body_material

.. autoclass:: RigidBodyMaterialBaseCfg
:members:
:show-inheritance:
:exclude-members: __init__, func

.. autofunction:: spawn_rigid_body_material_from_fragments

.. autoclass:: RigidBodyMaterialFragment
:members:
:show-inheritance:
:exclude-members: __init__, func

.. autoclass:: UsdPhysicsRigidBodyMaterialCfg
:members:
:show-inheritance:
:exclude-members: __init__, func

.. autoclass:: RigidBodyMaterialCfg
:members:
:exclude-members: __init__, func
Expand Down
9 changes: 9 additions & 0 deletions docs/source/api/lab_newton/isaaclab_newton.sim.spawners.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,19 @@ isaaclab_newton.sim.spawners

.. autosummary::

NewtonMaterialCfg
NewtonDeformableBodyMaterialCfg
NewtonDeformableMaterialCfg
NewtonSurfaceDeformableBodyMaterialCfg

Rigid Materials
---------------

.. autoclass:: NewtonMaterialCfg
:members:
:show-inheritance:
:exclude-members: __init__, func

Deformable Materials
--------------------

Expand Down
15 changes: 15 additions & 0 deletions docs/source/api/lab_physx/isaaclab_physx.sim.spawners.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,27 @@ isaaclab_physx.sim.spawners

.. autosummary::

PhysxRigidBodyMaterialCfg
PhysxMaterialCfg
PhysxDeformableBodyMaterialCfg
PhysxSurfaceDeformableBodyMaterialCfg
PhysXDeformableMaterialCfg
DeformableBodyMaterialCfg
SurfaceDeformableBodyMaterialCfg

Rigid Materials
---------------

.. autoclass:: PhysxRigidBodyMaterialCfg
:members:
:show-inheritance:
:exclude-members: __init__, func

.. autoclass:: PhysxMaterialCfg
:members:
:show-inheritance:
:exclude-members: __init__, func

Deformable Materials
--------------------

Expand Down
45 changes: 45 additions & 0 deletions source/isaaclab/changelog.d/vidurv-schema-frag-materials.minor.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
Added
^^^^^

* Added the rigid-body physics-material "fragment" classes
:class:`~isaaclab.sim.spawners.materials.RigidBodyMaterialFragment` (marker base) and
:class:`~isaaclab.sim.spawners.materials.UsdPhysicsRigidBodyMaterialCfg` (solver-common
``physics:*`` friction/restitution/density), plus the family writer
:func:`~isaaclab.sim.spawners.materials.spawn_rigid_body_material_from_fragments` and the slot
dispatcher :func:`~isaaclab.sim.spawners.materials.spawn_physics_material`. Relevant
``physics_material`` slots now accept a single fragment or list alongside their legacy cfg form.
Legacy material cfgs are current-stage-only: the dispatcher raises ``ValueError`` for an explicit
non-current stage, while fragment-based materials support explicit-stage authoring.

* Added :attr:`~isaaclab.sim.spawners.materials.UsdPhysicsRigidBodyMaterialCfg.density` (writes
``physics:density``), completing the fragment's coverage of ``UsdPhysics.MaterialAPI``.
* Added :attr:`~isaaclab.sim.spawners.materials.RigidBodyMaterialBaseCfg.density`, so the legacy
rigid material base authors every attribute the fragment authors.

Changed
^^^^^^^

* Narrowed :attr:`~isaaclab.sim.spawners.ShapeCfg.physics_material` from the broad
:class:`~isaaclab.sim.spawners.materials.PhysicsMaterialCfg` to the rigid material base, a single
rigid-material fragment, or a list of fragments.
* Extended the already rigid-only :attr:`~isaaclab.sim.spawners.GroundPlaneCfg.physics_material`
and :attr:`~isaaclab.terrains.TerrainImporterCfg.physics_material` slots from the legacy
:class:`~isaaclab_physx.sim.spawners.materials.RigidBodyMaterialCfg` type to
:class:`~isaaclab.sim.spawners.materials.RigidBodyMaterialBaseCfg`, a single
:class:`~isaaclab.sim.spawners.materials.RigidBodyMaterialFragment`, or a list of fragments.
Deformable materials remain accepted where deformables can spawn
(:class:`~isaaclab.sim.spawners.FileCfg` and :class:`~isaaclab.sim.spawners.MeshCfg`).
* Changed the generated-terrain material path to use
:func:`~isaaclab.sim.spawners.materials.spawn_physics_material`, enabling fragment lists there.

Fixed
^^^^^

* Fixed mesh spawners rejecting valid rigid physics materials: the rigid-material check compared
against the deprecated leaf class, so canonical
:class:`~isaaclab_physx.sim.spawners.materials.PhysxRigidBodyMaterialCfg` and
:class:`~isaaclab_newton.sim.schemas.NewtonMaterialPropertiesCfg` instances raised
``ValueError`` on rigid meshes. The check now accepts any
:class:`~isaaclab.sim.spawners.materials.RigidBodyMaterialBaseCfg`.
* Fixed malformed fragment inputs reaching an opaque legacy ``func`` call. Direct and dispatched
fragment calls now reject empty, mixed, and non-fragment inputs before creating a material prim.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

from isaaclab.sim import converters, schemas
from isaaclab.sim.spawners.materials import SurfaceDeformableBodyMaterialBaseCfg
from isaaclab.sim.spawners.materials.physics_materials import spawn_physics_material
from isaaclab.sim.utils import (
add_labels,
bind_physics_material,
Expand Down Expand Up @@ -211,7 +212,7 @@ def spawn_ground_plane(

# Create physics material
if cfg.physics_material is not None:
cfg.physics_material.func(f"{prim_path}/physicsMaterial", cfg.physics_material)
spawn_physics_material(f"{prim_path}/physicsMaterial", cfg.physics_material, stage=stage)
# Apply physics material to ground plane
collision_prim = get_first_matching_child_prim(
prim_path,
Expand Down Expand Up @@ -478,8 +479,8 @@ def _spawn_from_usd_file(
material_path = f"{prim_path}/{cfg.physics_material_path}"
else:
material_path = cfg.physics_material_path
# create material
cfg.physics_material.func(material_path, cfg.physics_material)
# create material (accepts a legacy material cfg or rigid-body fragment(s))
spawn_physics_material(material_path, cfg.physics_material, stage=stage)
# apply material
bind_physics_material(prim_path, material_path, stage=stage)

Expand Down
25 changes: 22 additions & 3 deletions source/isaaclab/isaaclab/sim/spawners/from_files/from_files_cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,18 @@ class FileCfg(RigidObjectSpawnerCfg, DeformableObjectSpawnerCfg):
This parameter is ignored if `physics_material` is not None.
"""

physics_material: materials.PhysicsMaterialCfg | None = None
physics_material: (
materials.PhysicsMaterialCfg
| materials.RigidBodyMaterialFragment
| list[materials.RigidBodyMaterialFragment]
| None
) = None
"""Physics material properties.

Accepts either a legacy material cfg, a single
:class:`~isaaclab.sim.spawners.materials.RigidBodyMaterialFragment`, or a list of such
single-namespace fragments.

Note:
If None, then no custom physics material will be added.
"""
Expand Down Expand Up @@ -259,5 +268,15 @@ class GroundPlaneCfg(SpawnerCfg):
size: tuple[float, float] = (100.0, 100.0)
"""The size of the ground plane. Defaults to 100 m x 100 m."""

physics_material: materials.RigidBodyMaterialCfg = materials.RigidBodyMaterialCfg()
"""Physics material properties. Defaults to the default rigid body material."""
physics_material: (
materials.RigidBodyMaterialBaseCfg
| materials.RigidBodyMaterialFragment
| list[materials.RigidBodyMaterialFragment]
) = materials.RigidBodyMaterialCfg()
"""Physics material properties. Defaults to the default rigid body material.

The ground plane only spawns a collision plane, so this only accepts rigid-body materials: a
legacy :class:`~isaaclab.sim.spawners.materials.RigidBodyMaterialBaseCfg`, a single
:class:`~isaaclab.sim.spawners.materials.RigidBodyMaterialFragment`, or a list of such
single-namespace fragments.
"""
13 changes: 12 additions & 1 deletion source/isaaclab/isaaclab/sim/spawners/materials/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@

__all__ = [
"spawn_rigid_body_material",
"spawn_rigid_body_material_from_fragments",
"spawn_physics_material",
"spawn_deformable_body_material",
"PhysicsMaterialCfg",
"RigidBodyMaterialBaseCfg",
"RigidBodyMaterialFragment",
"UsdPhysicsRigidBodyMaterialCfg",
"DeformableBodyMaterialBaseCfg",
"DeformableBodyMaterialCfg",
"SurfaceDeformableBodyMaterialBaseCfg",
Expand All @@ -20,10 +24,17 @@ __all__ = [
"VisualMaterialCfg",
]

from .physics_materials import spawn_rigid_body_material, spawn_deformable_body_material
from .physics_materials import (
spawn_deformable_body_material,
spawn_physics_material,
spawn_rigid_body_material,
spawn_rigid_body_material_from_fragments,
)
from .physics_materials_cfg import (
PhysicsMaterialCfg,
RigidBodyMaterialBaseCfg,
RigidBodyMaterialFragment,
UsdPhysicsRigidBodyMaterialCfg,
DeformableBodyMaterialBaseCfg,
DeformableBodyMaterialCfg,
SurfaceDeformableBodyMaterialBaseCfg,
Expand Down
136 changes: 132 additions & 4 deletions source/isaaclab/isaaclab/sim/spawners/materials/physics_materials.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,138 @@
from isaaclab.sim.schemas.schemas import _apply_namespaced_schemas
from isaaclab.sim.utils import clone
from isaaclab.sim.utils.stage import get_current_stage
from isaaclab.utils.string import string_to_callable

from . import physics_materials_cfg


def spawn_rigid_body_material_from_fragments(
prim_path: str,
fragments: physics_materials_cfg.RigidBodyMaterialFragment
| list[physics_materials_cfg.RigidBodyMaterialFragment]
| tuple[physics_materials_cfg.RigidBodyMaterialFragment, ...],
stage: Usd.Stage | None = None,
) -> Usd.Prim:
"""Spawn a rigid-body physics material from one or more single-namespace fragments.

Creates (or reuses) the ``UsdShade.Material`` prim at ``prim_path``, applies the standard
``UsdPhysics.MaterialAPI`` anchor, then dispatches each fragment via its
:attr:`~isaaclab.sim.schemas.SchemaFragment.func` to author its namespace onto the material prim.
Backend fragments carry backend-specific namespaces (e.g. PhysX ``physxMaterial:*``) without core
importing a backend.

.. note::
Unlike the ``@clone``-decorated :func:`spawn_rigid_body_material`, this writer expects a
concrete ``prim_path`` and does not resolve regex prim-path patterns. Physics materials are
spawned at a single derived path by :func:`spawn_physics_material` and the spawner internals,
so regex resolution does not apply here.

Args:
prim_path: The prim path to spawn the material at.
fragments: A single :class:`~isaaclab.sim.spawners.materials.RigidBodyMaterialFragment`,
or a list/tuple of them.
stage: The stage to spawn on. Defaults to None, in which case the current stage is used.

Returns:
The spawned rigid body material prim.

Raises:
ValueError: When ``fragments`` is empty.
ValueError: When a prim already exists at the path and is not a material.
TypeError: When an item is not a rigid-body material fragment.
"""
if not isinstance(fragments, (list, tuple)):
fragments = [fragments]
else:
fragments = list(fragments)
if not fragments:
raise ValueError(f"Cannot spawn a physics material at '{prim_path}' from an empty fragment collection.")
invalid_types = [
type(fragment).__name__
for fragment in fragments
if not isinstance(fragment, physics_materials_cfg.RigidBodyMaterialFragment)
]
if invalid_types:
raise TypeError(
"A physics-material fragment collection must contain only RigidBodyMaterialFragment instances; got"
f" {invalid_types}."
)
if stage is None:
stage = get_current_stage()

# create the material prim if none exists yet
if not stage.GetPrimAtPath(prim_path).IsValid():
UsdShade.Material.Define(stage, prim_path)
prim = stage.GetPrimAtPath(prim_path)
if not prim.IsA(UsdShade.Material):
raise ValueError(f"A prim already exists at path: '{prim_path}' but is not a material.")

# apply the standard UsdPhysics MaterialAPI anchor (the defining schema for a physics material)
if not UsdPhysics.MaterialAPI(prim):
UsdPhysics.MaterialAPI.Apply(prim)

# dispatch each fragment's applier (writes its single namespace onto the material prim)
for cfg in fragments:
func = cfg.func if callable(cfg.func) else string_to_callable(cfg.func)
func(cfg, prim_path, stage)
return prim
Comment on lines +20 to +89

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Missing @clone decorator

spawn_rigid_body_material and spawn_deformable_body_material are both decorated with @clone, which resolves regex prim-path patterns (e.g. /World/Robot_.*/body) to concrete paths before spawning. spawn_rigid_body_material_from_fragments skips the decorator, so callers who pass a regex path directly will silently get a single prim at the literal pattern string rather than one prim per match. The docstring does not note this limitation, which diverges from the documented behaviour of the rest of the spawner family.



def spawn_physics_material(
prim_path: str,
material: physics_materials_cfg.PhysicsMaterialCfg
| physics_materials_cfg.RigidBodyMaterialFragment
| list[physics_materials_cfg.RigidBodyMaterialFragment]
| tuple[physics_materials_cfg.RigidBodyMaterialFragment, ...],
stage: Usd.Stage | None = None,
) -> Usd.Prim:
Comment on lines +92 to +99

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 The material parameter has no type annotation. Every other public function in this file is fully annotated, and this function sits at the dispatch boundary between the fragment and legacy interfaces. Adding the union type makes the contract explicit for type checkers and readers.

Suggested change
def spawn_physics_material(
prim_path: str,
material,
stage: Usd.Stage | None = None,
) -> Usd.Prim:
def spawn_physics_material(
prim_path: str,
material: physics_materials_cfg.PhysicsMaterialCfg
| physics_materials_cfg.RigidBodyMaterialFragment
| list[physics_materials_cfg.RigidBodyMaterialFragment],
stage: Usd.Stage | None = None,
) -> Usd.Prim:

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

"""Spawn a physics material from a spawner ``physics_material`` slot value.

Dispatches the two accepted slot forms: a single rigid-body fragment or list/tuple is spawned via
:func:`spawn_rigid_body_material_from_fragments`; otherwise the value is a legacy material cfg and is
spawned via its own :attr:`func`. Lets spawners accept both the fragment and the legacy interface
from one call site.

Args:
prim_path: The prim path to spawn the material at.
material: A :class:`~isaaclab.sim.spawners.materials.RigidBodyMaterialFragment` (or list/tuple
of them), or a legacy material cfg carrying a :attr:`func`.
stage: The stage to spawn on. Defaults to None, in which case the current stage is used. A
legacy material cfg only supports the current stage (or None); passing a different
stage raises.
Returns:
The spawned material prim.

Raises:
ValueError: When ``material`` is an empty fragment collection.
ValueError: When ``material`` is a legacy material cfg and ``stage`` is neither ``None``
nor the current stage.
TypeError: When ``material`` is a fragment collection containing anything other than
:class:`~isaaclab.sim.spawners.materials.RigidBodyMaterialFragment` instances.
TypeError: When ``material`` is neither a physics-material cfg nor a rigid-body fragment.
"""
# The family writer owns fragment validation so direct and dispatched calls have one contract.
if isinstance(material, (list, tuple, physics_materials_cfg.RigidBodyMaterialFragment)):
return spawn_rigid_body_material_from_fragments(prim_path, material, stage)
if not isinstance(material, physics_materials_cfg.PhysicsMaterialCfg):
raise TypeError(
"A physics material must be a PhysicsMaterialCfg or rigid-body material fragment; got"
f" '{type(material).__name__}'."
)
# legacy single-cfg path (rigid or deformable material cfg with its own spawner ``func``).
# Legacy material funcs take only ``(prim_path, cfg)`` and resolve the stage internally via
# ``get_current_stage()`` (their path matching is also current-stage-bound), so an explicit
# different stage cannot be honored on this path -- reject it loudly rather than authoring on
# the wrong stage. The fragment path above supports explicit stages.
if stage is not None and stage != get_current_stage():
raise ValueError(
f"Legacy material cfg '{type(material).__name__}' can only be spawned on the current"
" stage. Pass the current stage (or None), or use the fragment-based API for"
" explicit-stage authoring."
)
return material.func(prim_path, material)


@clone
def spawn_rigid_body_material(prim_path: str, cfg: physics_materials_cfg.RigidBodyMaterialBaseCfg) -> Usd.Prim:
"""Create material with rigid-body physics properties.
Expand All @@ -26,10 +154,10 @@ def spawn_rigid_body_material(prim_path: str, cfg: physics_materials_cfg.RigidBo
PxMaterial <https://nvidia-omniverse.github.io/PhysX/physx/5.4.1/_api_build/classPxBaseMaterial.html>`_.

The writer is metadata-driven: it always applies the standard ``UsdPhysics.MaterialAPI`` and
writes the friction/restitution fields, then reads ``_usd_applied_schema``, ``_usd_namespace``,
and ``_usd_attr_name_map`` from the cfg to author solver-specific attributes. The applied
schema (e.g. ``PhysxMaterialAPI``) is added only when at least one solver-specific field has a
non-``None`` value at the instance level.
writes the friction/restitution/density fields, then reads ``_usd_applied_schema``,
``_usd_namespace``, and ``_usd_attr_name_map`` from the cfg to author solver-specific attributes.
The applied schema (e.g. ``PhysxMaterialAPI``) is added only when at least one solver-specific
field has a non-``None`` value at the instance level.

.. note::
This function is decorated with :func:`clone` that resolves prim path into list of paths
Expand Down
Loading
Loading