USD decoder applies newton:inertia without clearing physics:diagonalInertia and physics:principalAxes
Maintainer thường phản hồi trong vòng 6 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 78/100
Hướng nghiên cứu
Đọc plugin/usd_decoder/usd_decoder.cc, đặc biệt là ParseUsdPhysicsMassAPIForBody quanh dòng 922–953, và phần xác thực khối lượng trong src/user/user_objects.cc quanh dòng 3373–3398. Tái hiện sự cố bằng các USD stage được cung cấp và so sánh mô men quán tính đã giải mã với giá trị tham chiếu MJCF. Hoàn tất khi newton:inertia được khai báo ghi đè các thuộc tính dự phòng và mô men quán tính đã giải mã khớp với MJCF nguồn.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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?
NewtonMassAPI's newton:inertia is a full inertia tensor in the body's local frame that, per the schema, overrides physics:diagonalInertia and physics:principalAxes when authored. Writers can author both so that readers without the Newton schemas still get the principal-axis form, and mujoco-usd-converter does this for every MJCF body with fullinertia.
The decoder does not apply the override. It copies physics:principalAxes to iquat and physics:diagonalInertia to inertia, then copies newton:inertia to fullinertia and leaves the other two set. Compilation fails:
Error: fullinertia and diagonal inertia cannot both be specified
This blocks every converted MJCF that uses fullinertia. In MuJoCo Menagerie that is 10 of 54 scenes, including franka_emika_panda, unitree_a1, agility_cassie, and robotstudio_so101.
Removing only physics:diagonalInertia is not a workaround. The model then compiles, but the compiler rotates fullinertia by iquat, which still holds physics:principalAxes, so a tensor that is already in the body frame is rotated a second time and the inertia is wrong.
I expected the decoder, when newton:inertia is authored, to set fullinertia and reset inertia to zero and iquat to identity, so the tensor is used as authored in the body frame and the result matches the source MJCF.
The relevant code at 4.0.1:
usd_decoder.ccParseUsdPhysicsMassAPIForBodysets all three.user_objects.ccrejectsfullinertiawith diagonal inertia and rotatesfullinertiabyiquat.
Steps for reproduction
pip install mujoco-usd==4.0.1- Run the code below. It builds a body with mass 1 and the tensor
0.3 0.25 0.2 0.01 0 0three ways and compares each decoded inertia with the same body in MJCF. - Authoring all three attributes fails.
newton:inertiaalone matches the MJCF exactly.physics:principalAxeswithnewton:inertiacompiles with the wrong inertia.
diagonalInertia + principalAxes + newton:inertia: Error: fullinertia and diagonal inertia cannot both be specified
newton:inertia only: compiles, max |inertia - MJCF| = 0
principalAxes + newton:inertia: compiles, max |inertia - MJCF| = 0.00857
Minimal model for reproduction
The stages are built in memory by the code below. The equivalent MJCF:
minimal XML
<mujoco>
<worldbody>
<body name="b">
<freejoint/>
<inertial pos="0 0 0" mass="1" fullinertia="0.3 0.25 0.2 0.01 0 0"/>
<geom type="sphere" size="0.1"/>
</body>
</worldbody>
</mujoco>
Code required for reproduction
import mujoco
import numpy as np
from pxr import Gf, Sdf, Usd, UsdGeom, UsdPhysics, Vt
FULL = [0.3, 0.25, 0.2, 0.01, 0.0, 0.0]
MJCF = f"""<mujoco><worldbody><body name="b"><freejoint/>
<inertial pos="0 0 0" mass="1" fullinertia="{' '.join(map(str, FULL))}"/>
<geom type="sphere" size="0.1"/></body></worldbody></mujoco>"""
def body_frame_tensor(inertia, iquat):
mat = np.zeros(9)
mujoco.mju_quat2Mat(mat, np.asarray(iquat, dtype=float))
rot = mat.reshape(3, 3)
return rot @ np.diag(inertia) @ rot.T
def make_stage(diag=None, axes=None, newton=None) -> Usd.Stage:
stage = Usd.Stage.CreateInMemory()
UsdGeom.SetStageMetersPerUnit(stage, 1.0)
UsdGeom.SetStageUpAxis(stage, UsdGeom.Tokens.z)
body = UsdGeom.Xform.Define(stage, "/World/b").GetPrim()
UsdPhysics.RigidBodyAPI.Apply(body)
mass_api = UsdPhysics.MassAPI.Apply(body)
mass_api.CreateMassAttr().Set(1.0)
mass_api.CreateCenterOfMassAttr().Set(Gf.Vec3f(0, 0, 0))
if diag is not None:
mass_api.CreateDiagonalInertiaAttr().Set(Gf.Vec3f(*diag))
if axes is not None:
mass_api.CreatePrincipalAxesAttr().Set(Gf.Quatf(*axes))
if newton is not None:
body.ApplyAPI("NewtonMassAPI")
body.GetAttribute("newton:inertia").Set(Vt.DoubleArray(newton))
sphere = UsdGeom.Sphere.Define(stage, "/World/b/geom")
sphere.CreateRadiusAttr().Set(0.1)
UsdPhysics.CollisionAPI.Apply(sphere.GetPrim())
return stage
ref = mujoco.MjModel.from_xml_string(MJCF)
ref_tensor = body_frame_tensor(ref.body_inertia[1], ref.body_iquat[1])
# Principal-axis decomposition of FULL, authored as the PhysicsMassAPI fallback for newton:inertia.
eigval, eigvec, quat = np.zeros(3), np.zeros(9), np.zeros(4)
tensor = np.array([[FULL[0], FULL[3], FULL[4]], [FULL[3], FULL[1], FULL[5]], [FULL[4], FULL[5], FULL[2]]])
mujoco.mju_eig3(eigval, eigvec, quat, tensor.flatten())
cases = {
"diagonalInertia + principalAxes + newton:inertia": dict(diag=eigval, axes=quat, newton=FULL),
"newton:inertia only": dict(newton=FULL),
"principalAxes + newton:inertia": dict(axes=quat, newton=FULL),
}
for name, kwargs in cases.items():
stage = make_stage(**kwargs)
try:
model = mujoco.MjSpec.from_file(stage.GetRootLayer().identifier).compile()
error = np.abs(body_frame_tensor(model.body_inertia[1], model.body_iquat[1]) - ref_tensor).max()
print(f"{name}: compiles, max |inertia - MJCF| = {error:.3g}")
except ValueError as e:
print(f"{name}: {str(e).splitlines()[0]}")
Confirmations
- I searched the latest documentation thoroughly before posting.
- I searched previous Issues and Discussions, I am certain this has not been raised before.
- Ngôn ngữ chính
- C++
- Star
- 18.3k
- Fork
- 2.2k
- Merge trung bình
- 9 ngày 11 giờ
- Pull request đã merge (30 ngày)
- 5
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của google-deepmind/mujoco
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
google-deepmind/mujoco#3929 ·
Maintainer thường phản hồi trong vòng 6 ngày
-
`import mujoco.mjx` fails with TypeError when warp-lang is too oldCó thể đã có người làm @moah0911 đã nhận 22 ngày trước. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
google-deepmind/mujoco#3738 ·
Maintainer thường phản hồi trong vòng 6 ngày
-
Unity 6.6 supportCó thể làm lại được @Balint-H đã nhận 53 ngày trước và không có pull request nào đang mở. Đang mởenhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
google-deepmind/mujoco#3615 · 1 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 6 ngày
-
Filament: `filament.ao.bilateral_threshold` and six other model options are ignored since 4.0.1, which changed the default ambient occlusionCó thể đã có người làm @jeongseok-meta đã nhận hôm nay. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 56/100
google-deepmind/mujoco#3933 ·
Maintainer thường phản hồi trong vòng 6 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 56/100
google-deepmind/mujoco#3931 ·
Maintainer thường phản hồi trong vòng 6 ngày
Tất cả issue của google-deepmind/mujoco
Issue tương tự
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 91/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 69/100
maplibre/maplibre-native#5072 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[UBSan] spawn_simulator passes null child_options.args to uv_spawn (execvp nonnull violation)Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 79/100
tenstorrent/tt-umd#4017 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
difficulty:easy func:gui prio:low type:bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
NatronGitHub/Natron#1538 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
hyprwm/hyprsunset#103 · 1 bình luận ·