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

Add helper functions to locate yarp configuration files #80

Closed
Tracked by #103
xela-95 opened this issue Feb 10, 2024 · 7 comments · Fixed by #116
Closed
Tracked by #103

Add helper functions to locate yarp configuration files #80

xela-95 opened this issue Feb 10, 2024 · 7 comments · Fixed by #116
Assignees

Comments

@xela-95
Copy link
Member

xela-95 commented Feb 10, 2024

The yarpConfigurationFile way to specify a configuration file for yarp plugins must support the specification of paths using the model:// syntax.

#77 (comment)

How gazebo vs. gazebo classic search for models and other sdf elements: https://gazebosim.org/api/sim/8/migrationsdf.html

@xela-95
Copy link
Member Author

xela-95 commented Mar 11, 2024

@xela-95
Copy link
Member Author

xela-95 commented Mar 12, 2024

By using the findURI function provided by Gazebo, if the string is actually an absolute or relative path without the use of URI (defined as
scheme[//authority]path[?query][#fragment]
), the function gives the following output:

[Err] [SystemPaths.cc:364] The passed value [/home/acroci/repos/gz-sim-yarp-plugins/tests/commons/conf/laser.ini] is not a valid URI, trying as a file

and then it correctly defaults to searching the file.

@traversaro should I match the string against a regex to determine what function to call (findFile or findURI)?

@xela-95
Copy link
Member Author

xela-95 commented Mar 12, 2024

Note for future users (and myself): while writing the unit test to check the loading of the configuration of gz-sim-yarp-plugins, I noted that the <plugin> tag must be inserted into the <model> element. When I tried to put this directly inside the <sensor> element of the SDF I got errors since the scoped name was empty. To my experience this is true for all plugins we have, not only for what in Gazebo classic were model plugins.

I found on http://robotology.github.io/gazebo-yarp-plugins/master/embed_plugins.html documentation that:

For model plugins such as the gazebo_yarp_controlboard, a plugin can be loaded by adding a SDF tag as a child of the SDF tag that describes the model.

but it does not says anything about sensor plugins.

@traversaro does this align with your knowledge?

@traversaro
Copy link
Member

@traversaro should I match the string against a regex to determine what function to call (findFile or findURI)?

Good point. I guess that was the behaviour also in the old Gazebo. Passing the absolute path in general is undesirable, as it creates non-portable models. However, if something is supported, it should not print an error. I guess we can either discriminate absolute files by check if they are absolute path with std::filesystem , or check if a value is a URI by checking if it starts with an URI. However, this is not trivial as on Windows absolute paths may start with C:\ or D:\, so for now we can also leave this aside if we do not know how to do it properly, and just stay with the error in case of absolute path.

@traversaro
Copy link
Member

Note for future users (and myself): while writing the unit test to check the loading of the configuration of gz-sim-yarp-plugins, I noted that the <plugin> tag must be inserted into the <model> element. When I tried to put this directly inside the <sensor> element of the SDF I got errors since the scoped name was empty. To my experience this is true for all plugins we have, not only for what in Gazebo classic were model plugins.

I found on http://robotology.github.io/gazebo-yarp-plugins/master/embed_plugins.html documentation that:

For model plugins such as the gazebo_yarp_controlboard, a plugin can be loaded by adding a SDF tag as a child of the SDF tag that describes the model.
but it does not says anything about sensor plugins.

@traversaro does this align with your knowledge?

Yes, that was indeed a limitation we realized while first working on the plugins in this repo, and we decided to proceed like that as we were not be able to get it to work by putting the plugins as children of the sensor tag. We may eventually want to fix this, but for now we can just document this as a change between gazebo-yarp-plugins and gz-sim-yarp-plugins (for example if we prepare a migration document).

@xela-95
Copy link
Member Author

xela-95 commented Mar 13, 2024

@traversaro should I match the string against a regex to determine what function to call (findFile or findURI)?

Good point. I guess that was the behaviour also in the old Gazebo. Passing the absolute path in general is undesirable, as it creates non-portable models. However, if something is supported, it should not print an error. I guess we can either discriminate absolute files by check if they are absolute path with std::filesystem , or check if a value is a URI by checking if it starts with an URI. However, this is not trivial as on Windows absolute paths may start with C:\ or D:\, so for now we can also leave this aside if we do not know how to do it properly, and just stay with the error in case of absolute path.

I think I can discriminate the paths using the is_absolute and is_relative methods, that should work on both Windows and Linux https://en.cppreference.com/w/cpp/filesystem/path/is_absrel

@xela-95
Copy link
Member Author

xela-95 commented Mar 13, 2024

Ok with db30ff2 we can manage three ways to specify configuration files:

  • URIs
  • Absolute paths (discouraged but working)
  • Relative paths

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

Successfully merging a pull request may close this issue.

2 participants