ami-iit / meshcat-viz-python

Generic visualizer of robot models based on MeshCat
BSD 3-Clause "New" or "Revised" License
7 stars 2 forks source link

Remove unnecessary dependency on environment variable `IGN_GAZEBO_RESOURCE_PATH` #16

Closed flferretti closed 1 year ago

flferretti commented 1 year ago

Currently, when attempting to import a URDF model for visualization using meshcat-viz-python, there is an unexpected requirement for the IGN_GAZEBO_RESOURCE_PATH environment variable. This requirement persists even when such a dependency is not necessary for the task.

The error arises in the code block below:

https://github.com/ami-iit/meshcat-viz-python/blob/cd3fdcf2cb09792fce5f83cb2759c933c21067bb/src/meshcat_viz/model_builder.py#L82-L87

This leads to the following traceback:

Traceback (most recent call last):
  File "/home/flferretti/git/element_rl-for-codesign/src/evogym/envs/ergocub.py", line 688, in <module>
    env.render()
  File "/home/flferretti/git/element_rl-for-codesign/src/evogym/envs/ergocub.py", line 474, in render
    _ = self.world.insert_model(
  File "/home/flferretti/mambaforge/envs/test101/lib/python3.10/site-packages/meshcat_viz/world.py", line 178, in insert_model
    meshcat_model = MeshcatModelBuilder.from_rod_model(
  File "/home/flferretti/mambaforge/envs/test101/lib/python3.10/site-packages/meshcat_viz/model_builder.py", line 25, in from_rod_model
    rod_model = MeshcatModelBuilder.resolve_sdf_tree_uris(rod_model=rod_model)
  File "/home/flferretti/mambaforge/envs/test101/lib/python3.10/site-packages/meshcat_viz/model_builder.py", line 70, in resolve_sdf_tree_uris
    MeshcatModelBuilder.resolve_local_uri(
  File "/home/flferretti/mambaforge/envs/test101/lib/python3.10/site-packages/meshcat_viz/model_builder.py", line 82, in resolve_local_uri
    for path in os.environ["IGN_GAZEBO_RESOURCE_PATH"].split(":"):
  File "/home/flferretti/mambaforge/envs/test101/lib/python3.10/os.py", line 680, in __getitem__
    raise KeyError(key) from None
KeyError: 'IGN_GAZEBO_RESOURCE_PATH'

C.C. @diegoferigo @traversaro

traversaro commented 1 year ago

Probably setting this variable to an emtpy variable can be a workaround?

flferretti commented 1 year ago

Solved by #18. Closing