Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alternative way of specifying the model file without relying on YARP_ROBOT_NAME #147

Open
traversaro opened this issue Apr 4, 2022 · 3 comments

Comments

@traversaro
Copy link
Member

traversaro commented Apr 4, 2022

Problem

In the wholebodydynamics device we currently have a modelFile parameter for specifying the model filename, that by default is model.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):

    std::string modelFileName = "model.urdf";
    if( config.check("modelFile") && config.find("modelFile").isString() )
    {
        modelFileName = config.find("modelFile").asString();
    }
    std::string modelFileFullPath = rf.findFileByName(modelFileName);

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 the YARP_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 the gazebo_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 set YARP_ROBOT_NAME=stickBot. Even worse, in the future somebody could forget to set correctly YARP_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 style package:// or Gazebo's model:// URIs. Most of the logic for supporting those URIs is in iDynTree, so we would just need to expose it (see robotology/idyntree#942). Once that logic is exposed and used in wholebodydynamics, we could use it as:

<param name="modelFile">model://iCub/conf_stickBot/estimators/wbd_icub3_sim.xml</param>

coherently with how we specify the other configuration files in SDF, for example in the yarpRobotInterfaceConfigurationFile element, child of plugin for plugins of gazebo-yarp-plugins:

<yarpRobotInterfaceConfigurationFile>model://iCub/conf_stickBot/icub.xml</yarpRobotInterfaceConfigurationFile>
@traversaro
Copy link
Member Author

Tagging ergocub-gazebo-simulations mantainers as currently I experienced this problem mainly with that model: @GrmanRodriguez @AlexAntn @Nicogene .

@traversaro
Copy link
Member Author

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.

@traversaro
Copy link
Member Author

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.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant