USD decoder ignores inertiaGroupRange unless both min and max are authored

Abierto
#3,924 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 6 días

@blessedefe4real ya está trabajando en esto.

Desde el 19/11/2026.

  • #3926 de @blessedefe4real — abierto

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
35/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Estancado
Stack tecnológico
cpp, python
Área
api, backend

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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
Lenguaje dominante
C++
Estrellas
18.3k
Forks
2.2k
Merge medio
9 d 11 h
PR fusionados (30 d)
5

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de google-deepmind/mujoco

Todos los issues de google-deepmind/mujoco

Issues similares

Más issues de C++

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.