google-deepmind / google-deepmind/dm_control
Exported XML loses meshdir and relative mesh paths
- Dominant language
- Python
- Stars
- 4.7k
- Forks
- 764
- PR merge metrics
- No merged PRs in 30d
Description
I'm using PyMJCF to load a robot model from an XML file and build a MuJoCo scene. When I export the composed scene back to an XML string using `scene_model.to_xml_string()`, I've run into an issue with the file paths.
### The Problem
The exported XML file is missing the directive. Meanwhile, all the mesh file paths, which were originally relative to that directory, are now missing their path prefixes.
For example, a mesh defined like `file="my_robot/meshes/part1.stl"` becomes `file="part1.stl"` in the exported file.
### Code Snippet
Here is the line of code I'm using for the export:
```Python
final_xml_string = scene_model.to_xml_string()
```
### What I've Found
I found a related issue (#454) that suggests using mjcf.export_with_assets(...) as a potential solution for managing assets.
### My Questions
1. Is there a direct method in PyMJCF to preserve the meshdir compiler attribute and the corresponding relative file paths when exporting a model to an XML string?
2. Separately, my main goal is to visualize the composed scene. I know `dm_control.viewer` can be used for simulations. Does the viewer also support loading and visualizing a custom MJCF scene like the one I'm building?
Thanks for your help!
Contributor guide
Research direction
Start with the `scene_model.to_xml_string()` call described in the issue and compare its behavior with the related `mjcf.export_with_assets(...)` path from issue #454. Check whether export can preserve `meshdir` and relative mesh paths, and separately investigate whether `dm_control.viewer` accepts the composed scene. Done requires a documented or tested answer to both questions.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100