USD decoder ignores the NewtonSceneAPI fallback for newton:timeStepsPerSecond

Abierto Apto para principiantes
#3,929 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 6 días

Nadie ha tomado este issue todavía.

Evaluación

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

Línea de trabajo

Empieza por la comprobación en plugin/usd_decoder/usd_decoder.cc, alrededor de las líneas 498–504, donde el decodificador lee newton:timeStepsPerSecond. Comprueba cómo se obtiene el valor resuelto del atributo USD cuando el atributo no está authored y NewtonSceneAPI proporciona su valor alternativo. El objetivo se cumple cuando el decodificador usa 1000 pasos por segundo en ese caso, lo que da un paso de tiempo de 0,001 s; verifica los casos authored y no authored.

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

Descripción

My setup

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

What's happening? What did you expect?

The decoder applies newton:timeStepsPerSecond only when it has an authored value. When it is not authored, the timestep stays at MuJoCo's default of 0.002 s.

NewtonSceneAPI defines a fallback of 1000 for newton:timeStepsPerSecond, so an applied NewtonSceneAPI with no authored value describes a 0.001 s timestep. Authoring tools commonly skip values that match the schema fallback, and mujoco-usd-converter does, so any MJCF with <option timestep="0.001"/> decodes at 0.002 s and simulates at twice the intended step. In MuJoCo Menagerie this affects google_barkour_v0, google_barkour_vb, and trossen_wxai.

I expected the decoder to use the resolved value of newton:timeStepsPerSecond whenever NewtonSceneAPI is applied, so the unauthored attribute gives 0.001 s. The other two Newton scene attributes the decoder reads have fallbacks that already agree with MuJoCo (newton:maxSolverIterations = -1 means the solver default, and newton:gravityEnabled = true), so only the timestep is affected.

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 NewtonSceneAPI and MjcSceneAPI applied to the physics scene as mujoco-usd-converter does, with and without an authored newton:timeStepsPerSecond = 1000.
  3. In both cases the attribute resolves to 1000, but the timestep is 0.002 unless the value is authored.
authored=False: newton:timeStepsPerSecond resolves to 1000, timestep=0.002
authored=True: newton:timeStepsPerSecond resolves to 1000, timestep=0.001
Minimal model for reproduction

The stage is built in memory by the code below. The equivalent MJCF:

minimal XML
<mujoco>
  <option timestep="0.001"/>
  <worldbody>
    <body>
      <freejoint/>
      <geom type="box" size="1 1 1"/>
    </body>
  </worldbody>
</mujoco>
Code required for reproduction
import mujoco
from pxr import Usd, UsdGeom, UsdPhysics


def make_stage(author: 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("NewtonSceneAPI")
    scene.ApplyAPI("MjcSceneAPI")
    # Equivalent to <option timestep="0.001"/>. 1000 Hz is the NewtonSceneAPI fallback.
    if author:
        scene.GetAttribute("newton:timeStepsPerSecond").Set(1000)

    body = UsdGeom.Cube.Define(stage, "/World/box")
    UsdPhysics.RigidBodyAPI.Apply(body.GetPrim())
    UsdPhysics.CollisionAPI.Apply(body.GetPrim())
    return stage


for author in (False, True):
    stage = make_stage(author)
    attr = stage.GetPrimAtPath("/PhysicsScene").GetAttribute("newton:timeStepsPerSecond")
    spec = mujoco.MjSpec.from_file(stage.GetRootLayer().identifier)
    model = spec.compile()
    print(f"authored={author}: newton:timeStepsPerSecond resolves to {attr.Get()}, timestep={model.opt.timestep}")
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.