USD decoder ignores the NewtonSceneAPI fallback for newton:timeStepsPerSecond

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

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

まだ誰も着手していません。

評価

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

調査の方向性

plugin/usd_decoder/usd_decoder.ccの498~504行付近にある、デコーダーがnewton:timeStepsPerSecondを読み取るチェックから始めてください。属性がauthoredされておらず、NewtonSceneAPIがフォールバック値を提供する場合に、解決済みのUSD属性値がどのように取得されるかを確認してください。この場合にデコーダーが毎秒1000ステップを使用し、タイムステップが0.001 sになることを完了条件とします。authoredの場合とauthoredされていない場合の両方を確認してください。

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

説明

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
主要言語
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 を短くまとめたダイジェスト。