Skip to content

usd: add sleep option, sleep flag, body sleep, and body gravcomp attributes to mjcPhysics schema (#3457) - #3462

Open
aadilrizwan wants to merge 1 commit into
google-deepmind:mainfrom
aadilrizwan:fix-3457-usd-schema
Open

usd: add sleep option, sleep flag, body sleep, and body gravcomp attributes to mjcPhysics schema (#3457)#3462
aadilrizwan wants to merge 1 commit into
google-deepmind:mainfrom
aadilrizwan:fix-3457-usd-schema

Conversation

@aadilrizwan

Copy link
Copy Markdown

Summary

This PR adds missing OpenUSD schema attributes for MJCF sleep options, sleep flags, body sleep policy, and body gravity compensation attributes to mjcPhysics and the mujoco_to_usd converter.

Resolves #3457.

Missing Attributes Added

MJCF Feature USD Attribute USD Schema API Default
<option sleep_tolerance="..."> mjc:option:sleep_tolerance MjcSceneAPI 0.001
<option><flag sleep="enable"/></option> mjc:flag:sleep MjcSceneAPI False
<body sleep="..."> mjc:sleep MjcBodyAPI (New) "auto" ("auto", "never", "allowed", "init")
<body gravcomp="..."> mjc:gravcomp MjcBodyAPI (New) 0.0

Key Changes

  1. USD Schemas:

    • Extended schema.usda & generatedSchema.usda with mjc:option:sleep_tolerance and mjc:flag:sleep on MjcSceneAPI.
    • Defined new MjcBodyAPI single-apply API schema class for rigid bodies with mjc:sleep and mjc:gravcomp.
    • Registered MjcPhysicsBodyAPI in plugInfo.json.
  2. C++ API & Tokens:

    • Added MjcPhysicsTokens (mjcOptionSleep_tolerance, mjcFlagSleep, mjcSleep, mjcGravcomp, MjcBodyAPI, allowed, init, never).
    • Implemented MjcPhysicsBodyAPI class (bodyAPI.h / bodyAPI.cpp) and updated MjcPhysicsSceneAPI.
  3. MJCF Converter (mujoco_to_usd.cc):

    • Updated WritePhysicsScene to write mjcOptionSleep_tolerance and mjcFlagSleep.
    • Updated WriteBody to apply MjcBodyAPI schema and write mjcSleep and mjcGravcomp.
  4. Documentation & Unit Tests:

    • Added MjcBodyAPI to doc/OpenUSD/mjcPhysics.rst.
    • Added fallback test assertions in mjc_physics_scene_test.cc.
    • Added unit test suite in mjc_body_api_test.cc.
    • Added round-trip conversion verification test in mjcf_file_format_test.cc.

Verification

  • Schema fallback values verified against mjModel default options.
  • API schema setters and getters tested in mjc_body_api_test.
  • MJCF-to-USD conversion verified via TestSleepAndGravcomp in mjcf_file_format_test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

mjcPhysics USD schema missing sleep and body gravcomp attributes

1 participant