MjSpec.to_xml() drops userfacetexcoord, so inline textured meshes do not reload
I maintainer di solito rispondono entro 6 giorni
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 56/100
Direzione di ricerca
Start with src/xml/xml_native_writer.cc around the mesh serialization code, then check src/xml/generated/mjcf_read_table.inc and src/user/user_mesh.cc as the issue identifies. Reproduce with the Python MjSpec example in the report and verify how inline face UV indices are represented during XML writing and loading. Done means the generated XML reloads with the same per-corner UV mapping; the issue also flags userfacenormal as a possible related gap.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
My setup
MuJoCo 4.0.1 from PyPI (mujoco-core 4.0.1, plus mujoco-usd 4.0.1 for the USD case), Python 3.12, Linux x86_64. The same code is on main.
What's happening? What did you expect?
MjSpec.to_xml() writes MJCF that does not compile for meshes with inline vertex data and userfacetexcoord. MJCF <mesh> has vertex, normal, texcoord, and face attributes but nothing for face texcoord indices, so the writer emits texcoord and drops userfacetexcoord. On reload the texcoord count no longer matches the vertex count:
Error: texcoord must be 2*nv if face texcoord indices are not provided in an OBJ file
When the texcoord count happens to equal the vertex count, the reload compiles instead, with UVs assigned to the wrong corners.
Meshes loaded from an OBJ file are not affected because the XML references the file. Inline meshes with per-corner UVs are common in specs built by importers. The USD decoder fills userfacetexcoord from faceVarying primvars:st, so every textured USD mesh hits this. 9 of the 40 MuJoCo Menagerie models I converted to USD and decoded fail to reload after to_xml(), including unitree_go2, boston_dynamics_spot, and aloha.
I expected to_xml() to write MJCF that reloads to the same mesh, for example through a facetexcoord attribute on <mesh> or by splitting vertices so each has one texcoord. userfacenormal looks like it has the same gap, but I have not tested it.
The relevant code at 4.0.1:
xml_native_writer.ccwritestexcoordwithoutuserfacetexcoord.mjcf_read_table.inchas no face texcoord attribute for<mesh>.user_mesh.ccraises the error.
Steps for reproduction
pip install mujoco==4.0.1- Run the code below. It builds a tetrahedron with 4 vertices and a separate UV for each of its 12 face corners, compiles it, writes it with
to_xml(), and reloads the XML. - The original spec compiles, and the reloaded XML fails.
original spec compiles
<mesh name="tet" vertex="0 0 0 1 0 0 0 1 0 0 0 1" texcoord="0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1" face="0 2 1 0 1 3 0 3 2 1 2 3"/>
reloaded XML fails: Error: texcoord must be 2*nv if face texcoord indices are not provided in an OBJ file | Element name 'tet', id 0, line 5
Minimal model for reproduction
The spec is built in code because MJCF cannot express it.
Code required for reproduction
import mujoco
# Tetrahedron with 4 vertices and a separate UV per face corner (12 UVs).
spec = mujoco.MjSpec()
mesh = spec.add_mesh(name="tet")
mesh.uservert = [0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1]
mesh.userface = [0, 2, 1, 0, 1, 3, 0, 3, 2, 1, 2, 3]
mesh.usertexcoord = [0, 0, 1, 0, 0, 1] * 4
mesh.userfacetexcoord = list(range(12))
spec.worldbody.add_geom(type=mujoco.mjtGeom.mjGEOM_MESH, meshname="tet")
spec.compile()
print("original spec compiles")
xml = spec.to_xml()
print(next(line.strip() for line in xml.splitlines() if "<mesh" in line))
try:
mujoco.MjSpec.from_string(xml).compile()
print("reloaded XML compiles")
except ValueError as e:
print("reloaded XML fails:", str(e).replace("\n", " | "))
Confirmations
- I searched the latest documentation thoroughly before posting.
- I searched previous Issues and Discussions, I am certain this has not been raised before.
- Lingua principale
- C++
- Stelle
- 18.3k
- Fork
- 2.2k
- Merge medio
- 9g 11h
- PR unite (30g)
- 5
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di google-deepmind/mujoco
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
google-deepmind/mujoco#3932 ·
I maintainer di solito rispondono entro 6 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
google-deepmind/mujoco#3929 ·
I maintainer di solito rispondono entro 6 giorni
-
`import mujoco.mjx` fails with TypeError when warp-lang is too oldForse già presa @moah0911 l’ha presa 22 giorni fa. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
google-deepmind/mujoco#3738 ·
I maintainer di solito rispondono entro 6 giorni
-
Unity 6.6 supportForse di nuovo libera @Balint-H l’ha presa 53 giorni fa e non c’è nessuna pull request aperta. Apertaenhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
google-deepmind/mujoco#3615 · 1 commento · 1 assegnatario ·
I maintainer di solito rispondono entro 6 giorni
-
Filament: `filament.ao.bilateral_threshold` and six other model options are ignored since 4.0.1, which changed the default ambient occlusionForse già presa @jeongseok-meta l’ha presa oggi. Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 56/100
google-deepmind/mujoco#3933 ·
I maintainer di solito rispondono entro 6 giorni
Tutte le issue di google-deepmind/mujoco
Issue simili
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 91/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 69/100
maplibre/maplibre-native#5072 ·
I maintainer di solito rispondono entro 1 giorno
-
[UBSan] spawn_simulator passes null child_options.args to uv_spawn (execvp nonnull violation)Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 79/100
tenstorrent/tt-umd#4017 ·
I maintainer di solito rispondono entro 3 giorni
-
difficulty:easy func:gui prio:low type:bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
NatronGitHub/Natron#1538 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
hyprwm/hyprsunset#103 · 1 commento ·