google-deepmind / google-deepmind/mujoco
Missing `mesh_*` fields from `mjx.Model`
- Dominant language
- C++
- Stars
- 15.2k
- Forks
- 1.8k
- Avg merge
- 10d 16h
- Merged PRs (30d)
- 25
Description
### The feature, motivation and pitch
I was playing around with the `mjx.Model` meshes and noticed that there are some `mesh_*` fields missing from the definition. Specifically, these exist in the `mujoco.MjModel` but not in `mjx.Model`:
- mesh_facenum
- mesh_normaladr
- mesh_normalnum
- mesh_normal
- mesh_facenormal
- mesh_facetexcoord
- mesh_scale
- mesh_pathadr
- mesh_polynum
- mesh_polyadr
- mesh_polynormal
- mesh_polyvertadr
- mesh_polyvertnum
- mesh_polyvert
- mesh_polymapadr
- mesh_polymapnum
- mesh_polymap
I thought that maybe these are omitted for purpose, but it feels weird that, for example, `mesh_faceadr` is defined but `mesh_facenum` is not because to access the faces of a specific mesh, I think, you need both.
Should these fields be included in the `mjx.Model`?
### Alternatives
I can pass the `mujoco.MjModel` instance around together with `mjx.Model` and access the fields from that.
### Additional context
```python
import mujoco
from mujoco import mjx
MESH_FIELDS = [
"mesh_vertadr",
"mesh_vertnum",
"mesh_faceadr",
"mesh_facenum",
"mesh_bvhadr",
"mesh_bvhnum",
"mesh_normaladr",
"mesh_normalnum",
"mesh_texcoordadr",
"mesh_texcoordnum",
"mesh_graphadr",
"mesh_vert",
"mesh_normal",
"mesh_texcoord",
"mesh_face",
"mesh_facenormal",
"mesh_facetexcoord",
"mesh_graph",
"mesh_scale",
"mesh_pos",
"mesh_quat",
"mesh_pathadr",
"mesh_polynum",
"mesh_polyadr",
"mesh_polynormal",
"mesh_polyvertadr",
"mesh_polyvertnum",
"mesh_polyvert",
"mesh_polymapadr",
"mesh_polymapnum",
"mesh_polymap",
]
xml = """
"""
spec = mujoco.MjSpec.from_string(xml)
model = spec.compile()
modelx = mjx.put_model(model)
fields_present = []
fields_missing = []
for field in MESH_FIELDS:
assert hasattr(model, field), f"Field {field} is not present in `mujoco.Model`."
if hasattr(modelx, field):
fields_present.append(field)
else:
fields_missing.append(field)
print("Fields present in `mjx.Model`:")
for field in fields_present:
print(f" - {field}")
print("\nFields missing in `mjx.Model`:")
for field in fields_missing:
print(f" - {field}")
```
Contributor guide
Assessment
This issue has not been assessed yet.