Skip to content

Commit 33d5d35

Browse files
Restrict mjc resolver fix to physics import paths
1 parent 68f4e40 commit 33d5d35

6 files changed

Lines changed: 51 additions & 61 deletions

File tree

source/isaaclab/changelog.d/antoiner-mjc-frictionloss.skip

Lines changed: 0 additions & 1 deletion
This file was deleted.

source/isaaclab/isaaclab/assets/articulation/ordering_resolvers.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -432,11 +432,7 @@ def _get_names_from_newton_usd_builder(
432432

433433
try:
434434
from newton import JointType, ModelBuilder, solvers # noqa: PLC0415
435-
from newton._src.usd.schemas import ( # noqa: PLC0415
436-
SchemaResolverMjc,
437-
SchemaResolverNewton,
438-
SchemaResolverPhysx,
439-
)
435+
from newton._src.usd.schemas import SchemaResolverNewton, SchemaResolverPhysx # noqa: PLC0415
440436
from newton.selection import ArticulationView # noqa: PLC0415
441437

442438
from pxr import UsdGeom, UsdPhysics # noqa: PLC0415
@@ -482,7 +478,7 @@ def has_articulation_root_api(prim) -> bool:
482478
root_path=source_asset_path,
483479
load_visual_shapes=False,
484480
skip_mesh_approximation=True,
485-
schema_resolvers=[SchemaResolverNewton(), SchemaResolverPhysx(), SchemaResolverMjc()],
481+
schema_resolvers=[SchemaResolverNewton(), SchemaResolverPhysx()],
486482
joint_ordering=joint_ordering,
487483
bodies_follow_joint_ordering=bodies_follow_joint_ordering,
488484
)

source/isaaclab/test/assets/test_articulation_ordering.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -768,7 +768,6 @@ def __init__(self, model, pattern, **kwargs):
768768
schemas_mod = types.ModuleType("newton._src.usd.schemas")
769769
schemas_mod.SchemaResolverNewton = lambda: "newton_schema"
770770
schemas_mod.SchemaResolverPhysx = lambda: "physx_schema"
771-
schemas_mod.SchemaResolverMjc = lambda: "mjc_schema"
772771
stage_mod = types.ModuleType("isaaclab.sim.utils.stage")
773772
stage_mod.get_current_stage = lambda: stage
774773
monkeypatch.setitem(sys.modules, "newton", newton_mod)

source/isaaclab_newton/isaaclab_newton/physics/visualization_builder.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
import torch
1212
from newton import ModelBuilder
13-
from newton._src.usd.schemas import SchemaResolverMjc, SchemaResolverNewton, SchemaResolverPhysx
13+
from newton._src.usd.schemas import SchemaResolverNewton, SchemaResolverPhysx
1414

1515
from pxr import Usd
1616

@@ -95,7 +95,7 @@ def build_visualization_builder_from_stage_envs(
9595
A tuple of the populated :class:`~newton.ModelBuilder` and shadow-deformable
9696
metadata ``(shadow_entities, registry_groups)``.
9797
"""
98-
schema_resolvers = [SchemaResolverNewton(), SchemaResolverPhysx(), SchemaResolverMjc()]
98+
schema_resolvers = [SchemaResolverNewton(), SchemaResolverPhysx()]
9999
builder = ModelBuilder(up_axis=up_axis)
100100
# Discover once and reuse via ``entries=`` below (ignore paths + shadow add).
101101
deformable_entries = discover_deformables_on_stage(stage)

source/isaaclab_newton/test/physics/test_newton_manager_abstraction.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1592,3 +1592,50 @@ def test_hard_reset_then_step_runs(use_cuda_graph):
15921592
# A hard device sync surfaces any deferred illegal access as an exception.
15931593
sim.step(render=False)
15941594
wp.synchronize_device("cuda:0")
1595+
1596+
1597+
# ---------------------------------------------------------------------------
1598+
# Regression: USD-authored ``mjc:*`` joint attributes must reach the Newton
1599+
# model through the manager import path (https://github.com/isaac-sim/IsaacLab/issues/6829).
1600+
# ---------------------------------------------------------------------------
1601+
1602+
1603+
def _author_revolute_with_frictionloss(stage, frictionloss: float) -> None:
1604+
"""Author a two-body articulation whose revolute joint carries ``mjc:frictionloss``."""
1605+
from pxr import Sdf, UsdGeom, UsdPhysics
1606+
1607+
world = UsdGeom.Xform.Define(stage, "/World/robot")
1608+
UsdPhysics.ArticulationRootAPI.Apply(world.GetPrim())
1609+
for name in ("parent", "child"):
1610+
body = UsdGeom.Cube.Define(stage, f"/World/robot/{name}")
1611+
UsdPhysics.RigidBodyAPI.Apply(body.GetPrim())
1612+
UsdPhysics.MassAPI.Apply(body.GetPrim()).CreateMassAttr(1.0)
1613+
fixed = UsdPhysics.FixedJoint.Define(stage, "/World/robot/fix")
1614+
fixed.CreateBody1Rel().SetTargets(["/World/robot/parent"])
1615+
joint = UsdPhysics.RevoluteJoint.Define(stage, "/World/robot/rev")
1616+
joint.CreateBody0Rel().SetTargets(["/World/robot/parent"])
1617+
joint.CreateBody1Rel().SetTargets(["/World/robot/child"])
1618+
joint.CreateAxisAttr("Z")
1619+
joint.GetPrim().CreateAttribute("mjc:frictionloss", Sdf.ValueTypeNames.Float, custom=True).Set(frictionloss)
1620+
1621+
1622+
def test_usd_mjc_frictionloss_reaches_newton_model():
1623+
"""A USD joint authored with ``mjc:frictionloss`` yields a matching ``joint_friction``."""
1624+
import isaaclab.sim as sim_utils
1625+
1626+
sim_cfg = SimulationCfg(
1627+
dt=0.005,
1628+
device="cuda:0",
1629+
physics=NewtonCfg(solver_cfg=MJWarpSolverCfg(), num_substeps=1, use_cuda_graph=False),
1630+
)
1631+
with build_simulation_context(sim_cfg=sim_cfg):
1632+
stage = sim_utils.get_current_stage()
1633+
_author_revolute_with_frictionloss(stage, frictionloss=0.11)
1634+
1635+
NewtonManager.instantiate_builder_from_stage()
1636+
model = NewtonManager._builder.finalize()
1637+
1638+
friction = model.joint_friction.numpy()
1639+
assert friction.max() == pytest.approx(0.11), (
1640+
f"mjc:frictionloss was dropped by the USD import (joint_friction={friction})"
1641+
)

source/isaaclab_newton/test/sim/test_mjc_usd_import.py

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

0 commit comments

Comments
 (0)