google-deepmind / google-deepmind/mujoco
Assets missing from `MjSpec.to_zip`
- Dominant language
- C++
- Stars
- 15.2k
- Forks
- 1.8k
- Avg merge
- 10d 16h
- Merged PRs (30d)
- 25
Description
### Intro
Hi!
### My setup
Version: `mujoco==3.5.0`
API: Python
Architecture: `macos_arm64`
### What's happening? What did you expect?
The `MjSpec.to_zip` [documentation](https://mujoco.readthedocs.io/en/stable/python.html#serialization) says that:
> The `MjSpec` object can be serialized with all of its assets using the function `spec.to_zip(file)`...
I was expecting that I could serialize a model that references external assets (like meshes, textures, etc.) in the spec, e.g. loaded from XML via `` tag. However, `MjSpec.to_zip` only includes assets that are explicitly present in `spec.assets` dictionary. It does not iterate over the model elements (meshes, textures, skins, hfields) to check for file references and include those files. This makes the zip file unusable for most of my use cases.
https://github.com/google-deepmind/mujoco/blob/2efca34f584cd904557774a0825cd1c9c58bb1fb/python/mujoco/__init__.py#L93-L109
### Steps for reproduction
Load any model with "external" assets defined e.g. in the `.xml` `` tag. Dump the model with `spec.to_zip(...)` and try loading it.
### Minimal model for reproduction
_No response_
### Code required for reproduction
_No response_
### Confirmations
- [x] I searched the [latest documentation](https://mujoco.readthedocs.io/en/latest/overview.html) thoroughly before posting.
- [x] I searched previous [Issues](https://github.com/google-deepmind/mujoco/issues) and [Discussions](https://github.com/google-deepmind/mujoco/discussions), I am certain this has not been raised before.
Contributor guide
Assessment
This issue has not been assessed yet.