google-deepmind / mujoco

Multi-Joint dynamics with Contact. A general purpose physics simulator.
https://mujoco.org
Apache License 2.0
8.26k stars 827 forks source link

meshdir does not work for flexcomp while including #1834

Open xkiixkii opened 4 months ago

xkiixkii commented 4 months ago

Hi,

I was trying to include an object into a scene, and I found the compiler cannot find the mesh correctly when I was trying to load the scene that includes the object with its absolute path, however, when I tried to load the scene with its relative path or load the object file which include the scene, it worked pretty fine. I have also tried use the absolute meshdir path it still does not work.

Here is the test directory structure I have

.
├── meshes
│   └── insole.msh
├── model_include_scene.xml
├── model.xml
├── scene_include_model.xml
├── scene.xml
└── test.py

Here are the xml files I used for test

model.xml ```XML ```
scene.xml ```XML ```
model_include_scene.xml ```XML ```
scene_include_model.xml ```XML ```

Here is the test code

from os import path
import mujoco

dir_absolute = path.dirname(__file__)
relative_scene_include_model = "scene_include_model.xml"
relative_model_include_scene = "model_include_scene.xml"
absolute_scene_include_model = path.join(dir_absolute, relative_scene_include_model)
absolute_model_include_scene = path.join(dir_absolute, relative_model_include_scene)

if __name__ == "__main__":
    try:
        model = mujoco.MjModel.from_xml_path(absolute_scene_include_model)
    except Exception as e:
        print("*" * 50)
        print("scene include model absolute failed")
        print("*" * 50)
        print(e)

    try:
        model = mujoco.MjModel.from_xml_path(relative_scene_include_model)
    except Exception as e:
        print("*" * 50)
        print("scene include model relative failed")
        print("*" * 50)
        print(e)

    try:
        model = mujoco.MjModel.from_xml_path(absolute_model_include_scene)
    except Exception as e:
        print("*" * 50)
        print("model include scene absolute failed")
        print("*" * 50)
        print(e)

    try:
        model = mujoco.MjModel.from_xml_path(relative_model_include_scene)
    except Exception as e:
        print("*" * 50)
        print("model include scene relative failed")
        print("*" * 50)
        print(e)

Issues Encountered:

**************************************************
scene include model absolute failed
**************************************************
XML Error: Error: resource not found via provider or OS filesystem: '/home/kaixing/assets/insole.msh'
Element 'flexcomp', line 0

MuJoCo Version: 3.1.6 OS: Ubuntu 22.04.4 x86_64 Using mujoco python binding

Josh00-Lu commented 1 month ago

Same Problem!