USD decoder ignores inertiaGroupRange unless both min and max are authored

オープン
#3,924 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 6 日以内に返信

@blessedefe4real がすでに取り組んでいます。

2026年11月19日 から。

  • #3926 @blessedefe4real による — オープン

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
停滞
技術スタック
cpp, python
領域
api, backend

調査の方向性

The issue points to the check in plugin/usd_decoder/usd_decoder.cc around lines 866–883; start by reading how it handles authored inertiaGroupRange attributes and their schema fallbacks. Reproduce with the provided Python snippet, comparing the decoded range and body mass when only max is authored versus when both ends are authored. Done means a single authored end is decoded using the other end's resolved default, matching the expected [0, 1] range and 8 kg mass.

索引モデルが issue の本文から書いたものです。

説明

Intro

Hi!

I work on mujoco-usd-converter, which converts MJCF to OpenUSD with the MjcPhysics schemas, and I check its output with MuJoCo's USD decoder.

My setup

MuJoCo 4.0.1 with mujoco-usd 4.0.1 from PyPI (usd-core 25.11), Python 3.12, Linux x86_64. The same code is in 3.17.0 and on main.

What's happening? What did you expect?

The decoder applies mjc:compiler:inertiaGroupRange:min and mjc:compiler:inertiaGroupRange:max only when both have an authored value. If only one is authored, it warns and ignores both:

WARNING: Only one of inertiaGroupRangeMin and inertiaGroupRangeMax was authored, ignoring both.

An unauthored attribute resolves to its schema fallback, which for these attributes is MuJoCo's default (min = 0, max = 5). So a stage that authors only max = 1 describes inertiagrouprange="0 1", but it decodes as 0 5. That is the natural way to author a range that keeps one default end, such as "0 1" or "0 3", since authoring tools commonly skip values that match the schema fallback. Geoms in groups MuJoCo should exclude from inertia then contribute mass.

I expected the decoder to use the resolved value of each attribute, taking the schema fallback for whichever end is not authored. The other MjcSceneAPI compiler attributes are applied independently whenever each one is authored.

The check is in usd_decoder.cc.

Steps for reproduction
  1. pip install mujoco-usd==4.0.1
  2. Run the code below. It builds the same stage twice, with only max authored and with both ends authored. The body has a 0.2 m box in group 0 (8 kg) and a 0.3 m radius sphere collider in group 2, which is outside the range.
  3. With only max authored, the range decodes as [0, 5] and the body mass is 121.10 kg. Authoring the default min = 0 as well gives the expected [0, 1] and 8.00 kg.
WARNING: Only one of inertiaGroupRangeMin and inertiaGroupRangeMax was authored, ignoring both.
min authored=False: inertiagrouprange=[0, 5] body mass=121.10
min authored=True: inertiagrouprange=[0, 1] body mass=8.00
Minimal model for reproduction

The stage is built in memory by the code below. The equivalent MJCF, which compiles to 8 kg:

minimal XML
<mujoco>
  <compiler inertiagrouprange="0 1"/>
  <worldbody>
    <body>
      <freejoint/>
      <geom type="box" size="0.1 0.1 0.1" group="0"/>
      <geom type="sphere" size="0.3" group="2"/>
    </body>
  </worldbody>
</mujoco>
Code required for reproduction
import mujoco
from pxr import Usd, UsdGeom, UsdPhysics


def make_stage(author_min: bool) -> Usd.Stage:
    stage = Usd.Stage.CreateInMemory()
    UsdGeom.SetStageMetersPerUnit(stage, 1.0)
    UsdGeom.SetStageUpAxis(stage, UsdGeom.Tokens.z)

    scene = UsdPhysics.Scene.Define(stage, "/PhysicsScene").GetPrim()
    scene.ApplyAPI("MjcSceneAPI")
    # Equivalent to <compiler inertiagrouprange="0 1"/>. The min of 0 is the schema default.
    scene.GetAttribute("mjc:compiler:inertiaGroupRange:max").Set(1)
    if author_min:
        scene.GetAttribute("mjc:compiler:inertiaGroupRange:min").Set(0)

    body = UsdGeom.Xform.Define(stage, "/World/body").GetPrim()
    UsdPhysics.RigidBodyAPI.Apply(body)

    # 0.2 m box in group 0: 8 kg at the default density of 1000.
    box = UsdGeom.Cube.Define(stage, "/World/body/box")
    box.GetSizeAttr().Set(0.2)
    UsdPhysics.CollisionAPI.Apply(box.GetPrim())

    # 0.3 m radius sphere in group 2, outside the range, so it should not contribute mass.
    sphere = UsdGeom.Sphere.Define(stage, "/World/body/sphere")
    sphere.GetRadiusAttr().Set(0.3)
    UsdPhysics.CollisionAPI.Apply(sphere.GetPrim())
    sphere.GetPrim().ApplyAPI("MjcCollisionAPI")
    sphere.GetPrim().GetAttribute("mjc:group").Set(2)
    return stage


for author_min in (False, True):
    stage = make_stage(author_min)
    spec = mujoco.MjSpec.from_file(stage.GetRootLayer().identifier)
    model = spec.compile()
    print(
        f"min authored={author_min}: inertiagrouprange={[int(x) for x in spec.compiler.inertiagrouprange]} "
        f"body mass={model.body('/World/body').mass[0]:.2f}"
    )
Confirmations
主要言語
C++
スター
18.3k
フォーク
2.2k
平均マージ
9日 11時間
マージ済み PR(30日)
5

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

google-deepmind/mujoco のほかの issue

google-deepmind/mujoco の issue をすべて見る

似ている issue

C++ の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。