gazebosim / gazebosim/sdformat
Error loading meshes from a relative folder for urdf models
- Dominant language
- C++
- Stars
- 216
- Forks
- 125
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 14
Description
**Original report ([archived issue](https://osrf-migration.github.io/sdformat-gh-pages/#!/osrf/sdformat/issues/227)) by Diego Ferigo (Bitbucket: [dgferigo](https://bitbucket.org/%7B994b27a5-7d6d-42b2-8aa7-2ea82fbe7bf6%7D/)).**
----------------------------------------
# Description
If an urdf file has meshes defined with relative path wrt the model file \(support introduced in [sdformat#558](https://osrf-migration.github.io/sdformat-gh-pages/#!/osrf/sdformat/pull-requests/558/accept-relative-path-in)\), the meshes are not found.
The setup is the following:
* A world file with a ground plane and an `` of the model file \(the model’s parent folder is part of `SDF_PATH`\). The world file is in an external folder far away from the model / mesh files.
* A urdf model that uses relative path to the mesh files \(mesh files are inside a `meshes` subfolder of the model’s directory\).
* A `model.config` file in the same folder of the urdf model that loads the urdf with: `icub.urdf`.
Opening the world with `ign gazebo /path/to/include_model.world` fails producing errors about meshes not found:
```
[Err] [SystemPaths.cc:428] Could not resolve file [urdf file/meshes/simmechanics/sim_sea_2-5_root_link_prt-binary.stl]
[Err] [MeshManager.cc:172] Unable to find file[urdf file/meshes/simmechanics/sim_sea_2-5_root_link_prt-binary.stl]
[...]
[GUI] [Err] [SystemPaths.cc:428] Could not resolve file [urdf file/meshes/simmechanics/sim_sea_2-5_root_link_prt-binary.stl]
[GUI] [Err] [MeshManager.cc:172] Unable to find file[urdf file/meshes/simmechanics/sim_sea_2-5_root_link_prt-binary.stl]
[GUI] [Err] [MeshDescriptor.cc:56] Mesh manager can't find mesh named [urdf file/meshes/simmechanics/sim_sea_2-5_root_link_prt-binary.stl]
[GUI] [Err] [OgreMeshFactory.cc:422] Cannot load null mesh
[GUI] [Err] [SceneManager.cc:290] Failed to load geometry for visual: base_link_fixed_joint_lump__root_link_visual
[...]
```
However, if I convert the urdf to sdf with `ign sdf -p model.urdf > model.sdf`, and modify the `model.config` to load the sdf, the meshes are found correctly.
# Versions
I’m on ubuntu 18.04 with sdformat and ign-gazebo compiled from sources.
* sdformat: `sdf9@`[8ba6c75](https://osrf-migration.github.io/sdformat-gh-pages/#!/osrf/sdformat/commits/8ba6c751ad4d9326fd8b3f14c8dc51d7c67a0ed3) (ec4769ca8047b1484baa79ce5d3fcaaa96267ab1)
* ign-gazebo: `ign-gazebo3@`[d42d5ba](https://bitbucket.org/ignitionrobotics/ign-gazebo/commits/d42d5badf2d41371d8567292e8e08b58f4f83d42)
# Additional Information
The meshes folder is not on purpose inside `IGN_FILE_PATH`. If I add the folder to the env variable, meshes are found also in the urdf case \(but the main point is that is should work also without this env var\).
It seems to me that the relative path support for meshes works only if the model is already a sdf model. If, instead, the model is an urdf that needs to be converted, the link to the meshes cannot be resolved. I suspect that, since the conversion happens inside sdformat code, the folder where the original urdf code is located is somehow ignored and it is not included in the search path for meshes.
cc @chapulina
Contributor guide
Research direction
Reproduce the setup with the external world, model.config, URDF, and meshes subfolder, then inspect SystemPaths.cc and MeshManager.cc while comparing direct URDF loading with the converted SDF case. Check how the original URDF directory is handled during conversion; done means relative meshes resolve without adding the meshes folder to IGN_FILE_PATH.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- robotics
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100