Open traversaro opened 2 years ago
Tagging ergocub-gazebo-simulations
mantainers as currently I experienced this problem mainly with that model: @GrmanRodriguez @AlexAntn @Nicogene .
We could even think of submitting this functionality in YARP directly, so that any code that used rf.findFileByName
could start supporting package://
/model://
URIs in input.
We could even think of submitting this functionality in YARP directly, so that any code that used
rf.findFileByName
could start supportingpackage://
/model://
URIs in input.
At the python level, I implemted this in a standalone package at https://github.com/ami-iit/resolve-robotics-uri-py , probably we can just do the same for C++ and use it where it is necessary.
Problem
In the
wholebodydynamics
device we currently have amodelFile
parameter for specifying the model filename, that by default ismodel.urdf
(https://github.com/robotology/whole-body-estimators/tree/1d310fe342922ddd1095cdbeb6dbd4555dc01ce5/devices/wholeBodyDynamics#wholebodydynamicsdevice). This string is processed by this snippet of code to obtain the actual absolute filename (from this part of the code):The
ResourceFinder::findFileByName
method then return any absolute path without changing it, but then searches for a filename without path using the YARP's way of searching for files (documented in https://www.yarp.it/latest//yarp_resource_finder_tutorials.html). In practice in most cases that file is located using the value of theYARP_ROBOT_NAME
environment variable. This practice work fine if on a given system we only need to load configuration files for one given robot.However, when we start embedding devices such as
wholebodydynamics
in simulated robots via thegazebo_yarp_robotinterface
plugin, it may happen that you load different robots in the same machine. For example, with the stickBot simulation a common failure that I encountered in the last days is that the simulation did not started correctly because I forgot to setYARP_ROBOT_NAME=stickBot
. Even worse, in the future somebody could forget to set correctlyYARP_ROBOT_NAME
, leading to silently corrupting the simulation results.Proposed Solution
A quick solution for this is to support also for
wholebodydynamics
to load files using the ROS's stylepackage://
or Gazebo'smodel://
URIs. Most of the logic for supporting those URIs is in iDynTree, so we would just need to expose it (see https://github.com/robotology/idyntree/issues/942). Once that logic is exposed and used inwholebodydynamics
, we could use it as:coherently with how we specify the other configuration files in SDF, for example in the
yarpRobotInterfaceConfigurationFile
element, child ofplugin
for plugins ofgazebo-yarp-plugins
: