robotology / idyntree

Multibody Dynamics Library designed for Free Floating Robots
BSD 3-Clause "New" or "Revised" License
166 stars 66 forks source link

iDynTree Irrlicht visualizer does not load TALOS model properly #926

Open GiulioRomualdi opened 2 years ago

GiulioRomualdi commented 2 years ago

I try to visualize the model with the following command

idyntree-model-view -m $CONDA_PREFIX/share/example-robot-data/robots/talos_data/robots/talos_reduced.urdf

I got

image

On the other hand, if I load the model using iDynTree-Meshcat visualizer (after applying #925) the model is loaded correctly

image


To replicate the error you can use the following conda environment (conda list):

``` conda list # packages in environment at /home/gromualdi/mambaforge/envs/idyntree-env: # # Name Version Build Channel _libgcc_mutex 0.1 conda_forge conda-forge _openmp_mutex 4.5 1_llvm conda-forge ampl-mp 3.1.0 h2cc385e_1005 conda-forge argon2-cffi 21.1.0 py39h3811e60_0 conda-forge assimp 5.0.1 hedfc422_6 conda-forge async_generator 1.10 py_0 conda-forge attrs 21.2.0 pyhd8ed1ab_0 conda-forge backcall 0.2.0 pyh9f0ad1d_0 conda-forge backports 1.0 py_2 conda-forge backports.functools_lru_cache 1.6.4 pyhd8ed1ab_0 conda-forge bleach 4.1.0 pyhd8ed1ab_0 conda-forge boost 1.74.0 py39h5472131_3 conda-forge boost-cpp 1.74.0 h359cf19_5 conda-forge bzip2 1.0.8 h7f98852_4 conda-forge ca-certificates 2021.10.8 ha878542_0 conda-forge cffi 1.14.6 py39h4bc2ebd_1 conda-forge console_bridge 1.0.1 h4bd325d_0 conda-forge debugpy 1.4.1 py39he80948d_0 conda-forge decorator 5.1.0 pyhd8ed1ab_0 conda-forge defusedxml 0.7.1 pyhd8ed1ab_0 conda-forge eigen 3.4.0 h4bd325d_0 conda-forge eigenpy 2.6.9 py39h5aed9d1_0 conda-forge entrypoints 0.3 py39hde42818_1002 conda-forge example-robot-data 3.11.0 py39h1a9c180_0 conda-forge freetype 2.10.4 h0708190_1 conda-forge hpp-fcl 1.7.8 py39hbcdfc36_0 conda-forge icu 69.1 h9c3ff4c_0 conda-forge idyntree 4.2.0 py39hf4c3102_0 conda-forge importlib-metadata 4.8.1 py39hf3d152e_0 conda-forge ipopt 3.14.4 h7ede334_0 conda-forge ipykernel 6.4.2 py39hef51801_0 conda-forge ipython 7.29.0 py39hef51801_0 conda-forge ipython_genutils 0.2.0 py_1 conda-forge ipywidgets 7.6.5 pyhd8ed1ab_0 conda-forge irrlicht 1.8.4 hdaeae82_1 conda-forge jbig 2.1 h7f98852_2003 conda-forge jedi 0.18.0 py39hf3d152e_2 conda-forge jinja2 3.0.2 pyhd8ed1ab_0 conda-forge jpeg 9d h36c2ea0_0 conda-forge jsonschema 4.1.2 pyhd8ed1ab_0 conda-forge jupyter_client 7.0.6 pyhd8ed1ab_0 conda-forge jupyter_core 4.9.1 py39hf3d152e_0 conda-forge jupyterlab_pygments 0.1.2 pyh9f0ad1d_0 conda-forge jupyterlab_widgets 1.0.2 pyhd8ed1ab_0 conda-forge lcms2 2.12 hddcbb42_0 conda-forge ld_impl_linux-64 2.36.1 hea4e1c9_2 conda-forge lerc 3.0 h9c3ff4c_0 conda-forge libblas 3.9.0 12_linux64_openblas conda-forge libcblas 3.9.0 12_linux64_openblas conda-forge libdeflate 1.8 h7f98852_0 conda-forge libffi 3.4.2 h9c3ff4c_4 conda-forge libgcc-ng 11.2.0 h1d223b6_11 conda-forge libgfortran-ng 11.2.0 h69a702a_11 conda-forge libgfortran5 11.2.0 h5c6108e_11 conda-forge libgomp 11.2.0 h1d223b6_11 conda-forge libiconv 1.16 h516909a_0 conda-forge liblapack 3.9.0 12_linux64_openblas conda-forge libopenblas 0.3.18 pthreads_h8fe5266_0 conda-forge libosqp 0.6.2 h9c3ff4c_3 conda-forge libpng 1.6.37 h21135ba_2 conda-forge libsodium 1.0.18 h36c2ea0_1 conda-forge libstdcxx-ng 11.2.0 he4da1e4_11 conda-forge libtiff 4.3.0 h6f004c6_2 conda-forge libwebp-base 1.2.1 h7f98852_0 conda-forge libxcb 1.13 h7f98852_1003 conda-forge libxml2 2.9.12 h885dcf4_1 conda-forge libzlib 1.2.11 h36c2ea0_1013 conda-forge llvm-openmp 12.0.1 h4bd325d_1 conda-forge lz4-c 1.9.3 h9c3ff4c_1 conda-forge markupsafe 2.0.1 py39h3811e60_0 conda-forge matplotlib-inline 0.1.3 pyhd8ed1ab_0 conda-forge meshcat-python 0.3.1 pyhd8ed1ab_0 conda-forge metis 5.1.0 h58526e2_1006 conda-forge mistune 0.8.4 py39h3811e60_1004 conda-forge mumps-include 5.2.1 ha770c72_10 conda-forge mumps-seq 5.2.1 h47a8eb5_10 conda-forge nbclient 0.5.4 pyhd8ed1ab_0 conda-forge nbconvert 6.2.0 py39hf3d152e_0 conda-forge nbformat 5.1.3 pyhd8ed1ab_0 conda-forge ncurses 6.2 h58526e2_4 conda-forge nest-asyncio 1.5.1 pyhd8ed1ab_0 conda-forge notebook 6.4.5 pyha770c72_0 conda-forge numpy 1.21.3 py39hdbf815f_0 conda-forge octomap 1.9.7 h4bd325d_0 conda-forge olefile 0.46 pyh9f0ad1d_1 conda-forge openjpeg 2.4.0 hb52868f_1 conda-forge openssl 3.0.0 h7f98852_1 conda-forge osqp-eigen 0.6.4 h9c3ff4c_1 conda-forge packaging 21.2 pyhd8ed1ab_1 conda-forge pandoc 2.15 h7f98852_0 conda-forge pandocfilters 1.5.0 pyhd8ed1ab_0 conda-forge parso 0.8.2 pyhd8ed1ab_0 conda-forge pexpect 4.8.0 pyh9f0ad1d_2 conda-forge pickleshare 0.7.5 py39hde42818_1002 conda-forge pillow 8.3.2 py39ha612740_0 conda-forge pinocchio 2.6.3 py39hbcdfc36_2 conda-forge pip 21.3.1 pyhd8ed1ab_0 conda-forge prometheus_client 0.12.0 pyhd8ed1ab_0 conda-forge prompt-toolkit 3.0.21 pyha770c72_0 conda-forge pthread-stubs 0.4 h36c2ea0_1001 conda-forge ptyprocess 0.7.0 pyhd3deb0d_0 conda-forge pycparser 2.20 pyh9f0ad1d_2 conda-forge pygments 2.10.0 pyhd8ed1ab_0 conda-forge pyngrok 5.1.0 pyhd8ed1ab_0 conda-forge pyparsing 2.4.7 pyhd8ed1ab_1 conda-forge pyrsistent 0.17.3 py39h3811e60_2 conda-forge python 3.9.7 hf930737_3_cpython conda-forge python-dateutil 2.8.2 pyhd8ed1ab_0 conda-forge python_abi 3.9 2_cp39 conda-forge pyyaml 6.0 py39h3811e60_0 conda-forge pyzmq 22.3.0 py39h37b5a0c_0 conda-forge qhull 2020.2 h4bd325d_2 conda-forge readline 8.1 h46c0cb4_0 conda-forge scotch 6.0.9 h3858553_1 conda-forge send2trash 1.8.0 pyhd8ed1ab_0 conda-forge setuptools 58.3.0 py39hf3d152e_0 conda-forge six 1.16.0 pyh6c4a22f_0 conda-forge sqlite 3.36.0 h9cd32fc_2 conda-forge terminado 0.12.1 py39hf3d152e_0 conda-forge testpath 0.5.0 pyhd8ed1ab_0 conda-forge tinyxml 2.6.2 h4bd325d_2 conda-forge tk 8.6.11 h27826a3_1 conda-forge tornado 6.1 py39h3811e60_1 conda-forge traitlets 5.1.1 pyhd8ed1ab_0 conda-forge tzdata 2021e he74cb21_0 conda-forge u-msgpack-python 2.7.1 pyh9f0ad1d_0 conda-forge urdfdom 2.3.5 h4bd325d_0 conda-forge urdfdom_headers 1.0.5 h4bd325d_2 conda-forge wcwidth 0.2.5 pyh9f0ad1d_2 conda-forge webencodings 0.5.1 py_1 conda-forge wheel 0.37.0 pyhd8ed1ab_1 conda-forge widgetsnbextension 3.5.2 py39hf3d152e_0 conda-forge xorg-kbproto 1.0.7 h7f98852_1002 conda-forge xorg-libx11 1.7.2 h7f98852_0 conda-forge xorg-libxau 1.0.9 h7f98852_0 conda-forge xorg-libxdmcp 1.1.3 h7f98852_0 conda-forge xorg-libxext 1.3.4 h7f98852_1 conda-forge xorg-xextproto 7.3.0 h7f98852_1002 conda-forge xorg-xproto 7.0.31 h7f98852_1007 conda-forge xz 5.2.5 h516909a_1 conda-forge yaml 0.2.5 h516909a_0 conda-forge zeromq 4.3.4 h9c3ff4c_1 conda-forge zipp 3.6.0 pyhd8ed1ab_0 conda-forge zlib 1.2.11 h36c2ea0_1013 conda-forge zstd 1.5.0 ha95c52a_0 conda-forge ```

Please expand the ROS_PACKAGE_PATH environment variable with

export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH:+${ROS_PACKAGE_PATH}:}${CONDA_PREFIX}/share

Then apply the PR #925

You can finally run the following python script to visualize the model with meshcat

from idyntree.visualize import MeshcatVisualizer
import numpy as np
import os

def get_model_path(robot_name='talos_reduced'):
    conda_prefix = os.environ["CONDA_PREFIX"]
    robots_folder = os.path.join("share","example-robot-data","robots","talos_data","robots")

    return os.path.join(conda_prefix, robots_folder, robot_name +".urdf")

def get_joint_list():

    joint_list = ["torso_1_joint", "torso_2_joint",
                  "leg_left_1_joint", "leg_left_2_joint", "leg_left_3_joint", "leg_left_4_joint", "leg_left_5_joint", "leg_left_6_joint",
                  "leg_right_1_joint", "leg_right_2_joint", "leg_right_3_joint", "leg_right_4_joint", "leg_right_5_joint", "leg_right_6_joint",
                  "arm_left_1_joint", "arm_left_2_joint", "arm_left_3_joint", "arm_left_4_joint", "arm_left_5_joint", "arm_left_6_joint", "arm_left_7_joint",
                  "arm_right_1_joint", "arm_right_2_joint", "arm_right_3_joint", "arm_right_4_joint", "arm_right_5_joint", "arm_right_6_joint", "arm_right_7_joint"]

    return joint_list

if __name__ == "__main__":
   model_path = get_model_path()
   joint_list = get_joint_list()
   viz = MeshcatVisualizer()
   viz.set_model_from_file(model_path, joint_list)
   viz.load_model(color=[1, 1, 1, 0.8])
traversaro commented 2 years ago

My guess is that the irrlicht visualizer is not taking properly taking into account the iDynTree::SolidShape::getLink_H_geometry data of visualization shapes.

traversaro commented 2 years ago

My guess is that the irrlicht visualizer is not taking properly taking into account the iDynTree::SolidShape::getLink_H_geometry data of visualization shapes.

However, I quickly checked in https://github.com/Gepetto/example-robot-data/blob/v3.11.0/robots/talos_data/robots/talos_reduced.urdf and it seems that all the visual geometry elements have the form:

    <visual>
      <origin rpy="0 0 0" xyz="0 0 0"/>

So this may not be the case.