Skip to content

Commit a1593d5

Browse files
committed
Add MuJoCo gravity compensation schema classes
Add MujocoRigidBodyPropertiesCfg with gravity_compensation_scale (body-level, written to mjc:gravcomp) and MujocoJointDrivePropertiesCfg with gravity_compensation (joint-level, written to mjc:actuatorgravcomp) for the Newton/MuJoCo simulation backend. Both classes use _usd_namespace and _usd_attr_name_map metadata so the modify functions handle them generically with no backend-specific branching. Also extends modify_rigid_body_properties to support _usd_attr_name_map, matching the joint drive path, for backends with non-camelCase attribute names.
1 parent 0484e95 commit a1593d5

6 files changed

Lines changed: 88 additions & 5 deletions

File tree

source/isaaclab/config/extension.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22

33
# Note: Semantic Versioning is used: https://semver.org/
4-
version = "4.6.2"
4+
version = "4.6.3"
55

66
# Description
77
title = "Isaac Lab framework for Robot Learning"

source/isaaclab/docs/CHANGELOG.rst

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,27 @@
11
Changelog
22
---------
33

4+
4.6.3 (2026-04-15)
5+
~~~~~~~~~~~~~~~~~~~
6+
7+
Added
8+
^^^^^
9+
10+
* Added :class:`~isaaclab.sim.schemas.MujocoRigidBodyPropertiesCfg` with
11+
``gravity_compensation_scale`` for body-level gravity compensation in the
12+
Newton (MuJoCo) backend.
13+
* Added :class:`~isaaclab.sim.schemas.MujocoJointDrivePropertiesCfg` with
14+
``gravity_compensation`` for joint-level gravity compensation in the
15+
Newton (MuJoCo) backend.
16+
17+
Changed
18+
^^^^^^^
19+
20+
* Extended :meth:`~isaaclab.sim.schemas.modify_rigid_body_properties` to support
21+
``_usd_attr_name_map`` metadata, matching the joint drive path. This enables
22+
solver backends with non-camelCase attribute names (e.g. MuJoCo ``mjc:gravcomp``).
23+
24+
425
4.6.2 (2026-04-15)
526
~~~~~~~~~~~~~~~~~~~
627

source/isaaclab/isaaclab/sim/__init__.pyi

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ __all__ = [
4747
"JointDrivePropertiesCfg",
4848
"MassPropertiesCfg",
4949
"MeshCollisionPropertiesCfg",
50+
"MujocoJointDrivePropertiesCfg",
51+
"MujocoRigidBodyPropertiesCfg",
5052
"PhysxJointDrivePropertiesCfg",
5153
"PhysxRigidBodyPropertiesCfg",
5254
"RigidBodyBaseCfg",
@@ -215,6 +217,8 @@ from .schemas import (
215217
JointDrivePropertiesCfg,
216218
MassPropertiesCfg,
217219
MeshCollisionPropertiesCfg,
220+
MujocoJointDrivePropertiesCfg,
221+
MujocoRigidBodyPropertiesCfg,
218222
PhysxJointDrivePropertiesCfg,
219223
PhysxRigidBodyPropertiesCfg,
220224
RigidBodyBaseCfg,

source/isaaclab/isaaclab/sim/schemas/__init__.pyi

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ __all__ = [
3535
"JointDrivePropertiesCfg",
3636
"MassPropertiesCfg",
3737
"MeshCollisionPropertiesCfg",
38+
"MujocoJointDrivePropertiesCfg",
39+
"MujocoRigidBodyPropertiesCfg",
3840
"PhysxJointDrivePropertiesCfg",
3941
"PhysxRigidBodyPropertiesCfg",
4042
"RigidBodyBaseCfg",
@@ -79,6 +81,8 @@ from .schemas_cfg import (
7981
JointDrivePropertiesCfg,
8082
MassPropertiesCfg,
8183
MeshCollisionPropertiesCfg,
84+
MujocoJointDrivePropertiesCfg,
85+
MujocoRigidBodyPropertiesCfg,
8286
PhysxJointDrivePropertiesCfg,
8387
PhysxRigidBodyPropertiesCfg,
8488
RigidBodyBaseCfg,

source/isaaclab/isaaclab/sim/schemas/schemas.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,7 @@ def modify_rigid_body_properties(
320320
# read solver-specific metadata from the cfg instance
321321
namespace = getattr(cfg, "_usd_namespace", None)
322322
applied_schema = getattr(cfg, "_usd_applied_schema", None)
323+
attr_name_map = getattr(cfg, "_usd_attr_name_map", {})
323324

324325
# convert to dict, filtering out class metadata (underscore-prefixed keys)
325326
cfg_dict = {k: v for k, v in cfg.to_dict().items() if not k.startswith("_")}
@@ -329,7 +330,7 @@ def modify_rigid_body_properties(
329330
value = cfg_dict.pop(attr_name, None)
330331
safe_set_attribute_on_usd_schema(usd_rigid_body_api, attr_name, value, camel_case=True)
331332

332-
# set solver-specific properties using class metadata (namespace + applied schema)
333+
# set solver-specific properties using class metadata (namespace + applied schema + attr name map)
333334
if cfg_dict:
334335
if namespace is None:
335336
raise ValueError(
@@ -341,9 +342,8 @@ def modify_rigid_body_properties(
341342
if applied_schema not in rigid_body_prim.GetAppliedSchemas():
342343
rigid_body_prim.AddAppliedSchema(applied_schema)
343344
for attr_name, value in cfg_dict.items():
344-
safe_set_attribute_on_usd_prim(
345-
rigid_body_prim, f"{namespace}:{to_camel_case(attr_name, 'cC')}", value, camel_case=False
346-
)
345+
usd_attr_name = attr_name_map.get(attr_name, to_camel_case(attr_name, "cC"))
346+
safe_set_attribute_on_usd_prim(rigid_body_prim, f"{namespace}:{usd_attr_name}", value, camel_case=False)
347347
# success
348348
return True
349349

source/isaaclab/isaaclab/sim/schemas/schemas_cfg.py

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,34 @@ class PhysxRigidBodyPropertiesCfg(RigidBodyBaseCfg):
144144
"""The mass-normalized kinetic energy threshold below which an actor may participate in stabilization."""
145145

146146

147+
@configclass
148+
class MujocoRigidBodyPropertiesCfg(RigidBodyBaseCfg):
149+
"""MuJoCo-specific rigid body properties.
150+
151+
Extends :class:`RigidBodyBaseCfg` with properties that are only supported by the
152+
Newton (MuJoCo) simulation backend.
153+
154+
See :meth:`modify_rigid_body_properties` for more information.
155+
156+
.. note::
157+
If the values are None, they are not modified. This is useful when you want to set only a subset of
158+
the properties and leave the rest as-is.
159+
"""
160+
161+
# -- Class metadata (not dataclass fields) --
162+
# Prim attribute namespace for solver-specific fields.
163+
_usd_namespace = "mjc"
164+
# Mapping from cfg field names to USD attribute names.
165+
_usd_attr_name_map = {"gravity_compensation_scale": "gravcomp"}
166+
167+
gravity_compensation_scale: float | None = None
168+
"""Scale factor for gravity compensation for the body [dimensionless]. Defaults to None
169+
(attribute not written to USD).
170+
171+
In MuJoCo, ``0.0`` means no compensation and ``1.0`` means full compensation.
172+
"""
173+
174+
147175
@configclass
148176
class RigidBodyPropertiesCfg(PhysxRigidBodyPropertiesCfg):
149177
"""Deprecated: use :class:`PhysxRigidBodyPropertiesCfg` or :class:`RigidBodyBaseCfg`.
@@ -321,6 +349,32 @@ class PhysxJointDrivePropertiesCfg(JointDriveBaseCfg):
321349
"""
322350

323351

352+
@configclass
353+
class MujocoJointDrivePropertiesCfg(JointDriveBaseCfg):
354+
"""MuJoCo-specific joint drive properties.
355+
356+
Extends :class:`JointDriveBaseCfg` with properties that are only supported by the
357+
Newton (MuJoCo) simulation backend.
358+
359+
See :meth:`modify_joint_drive_properties` for more information.
360+
361+
.. note::
362+
If the values are None, they are not modified. This is useful when you want to set only a subset of
363+
the properties and leave the rest as-is.
364+
"""
365+
366+
# -- Class metadata (not dataclass fields) --
367+
# Prim attribute namespace for solver-specific fields.
368+
_usd_namespace = "mjc"
369+
# Mapping from cfg field names to USD attribute names.
370+
_usd_attr_name_map = {"gravity_compensation": "actuatorgravcomp"}
371+
372+
gravity_compensation: bool | None = None
373+
"""Whether to enable gravity compensation on the joint. Defaults to None
374+
(attribute not written to USD).
375+
"""
376+
377+
324378
@configclass
325379
class JointDrivePropertiesCfg(PhysxJointDrivePropertiesCfg):
326380
"""Deprecated: use :class:`PhysxJointDrivePropertiesCfg` or :class:`JointDriveBaseCfg`.

0 commit comments

Comments
 (0)