google-deepmind / google-deepmind/dm_control

PyMJCF nested include tags relative to base model

Đang mở
#418 0 bình luận 2 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Python
Star
4.7k
Fork
764
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

PyMJCF does not support nested include tags the same way as the MuJoCo compiler. No matter how deep the include tag is, MuJoCo expects all included models and their assets to be given as paths to the corresponding file **relative to the input file parent directory**. However, the current implementation of PyMJCF checks paths relative to the current file's parent directory, which MuJoCo does not support.

In the attached [scenes.zip](https://github.com/deepmind/dm_control/files/12268186/scenes.zip) file are 3 scenes.

- my_scene1/scene.xml includes a file in an inner directory that includes another file in yet another inner directory. The internal include tag uses a path relative to the top-level model directory (my_scene1/). This is supported by MuJoCo but PyMJCF fails to parse the scene:
```python
>>> mjcf.Physics.from_xml_path('my_scene1/scene.xml') # parse using mujoco directly

>>> mjcf.Physics.from_mjcf_model(mjcf.from_path('my_scene1/scene.xml')) # parse with PyMJCF then convert to physics
FileNotFoundError: [Errno 2] No such file or directory: 'my_scene1/inner/inner/inner-inner/include.xml'
```
- my_scene2/scene.xml is the same as my_scene1/scene.xml but the inner include path is given relative to the current model directory (my_scene2/inner/). PyMJCF supports this but it does not compile natively using MuJoCo.
```python
>>> mjcf.Physics.from_xml_path('my_scene2/scene.xml') # parse using mujoco directly
ValueError: XML Error: Could not open file 'my_scene2/inner-inner/include.xml'
Element 'include', line 0

>>> mjcf.Physics.from_mjcf_model(mjcf.from_path('my_scene2/scene.xml')) # parse with PyMJCF then convert to physics

```
- my_scene3/scene.xml specifies mesh and texture files in an included file to show that MuJoCo expects these files to be specified relative to the top-level model directory as well.
```python
>>> mjcf.Physics.from_xml_path('my_scene3/scene.xml') # parse using mujoco directly

>>> mjcf.Physics.from_mjcf_model(mjcf.from_path('my_scene2/scene.xml')) # parse with PyMJCF then convert to physics
FileNotFoundError: Line 4: error while parsing element : during initialization of attribute 'file' of element : [Errno 2] No such file or directory: 'my_scene3/inner/meshes/banana.stl'
```

In conclusion, models with nested include tags or external assets in included files are parsed differently with MuJoCo than with PyMJCF.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

Start by reproducing the discrepancy with mjcf.Physics.from_xml_path and mjcf.Physics.from_mjcf_model using the three scenes in scenes.zip. Trace PyMJCF's include and asset path handling; done means nested includes and external assets resolve relative to the top-level model directory, matching MuJoCo.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
python
Lĩnh vực
backend
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
35/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.