Home | Tutorials | Wiki | Issues
Ask Your Question

Relative Paths in own sdf element

asked 2015-11-25 08:45:12 -0500

Illuminatur gravatar image


i am writing a plugin, which needs to load a csv file from a relative path with an own sdf-xml element <pathtofile>file::myfile</pathtofile>. Is there any gazebo-header, where methods are provided to resolve a file://myfile to the gazebo resource path?

Bbest regards!

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2015-11-25 09:39:30 -0500

nkoenig gravatar image

You can try using SDF's findFile function.

edit flag offensive delete link more

answered 2015-11-26 02:39:17 -0500

Illuminatur gravatar image

updated 2015-11-26 02:39:57 -0500


thank you very much, your suggestion works. You can include an element in the SDF, like


then in the plugin load the path (relative to the Gazebo Resource Path)

const char* gazeboResourcePaths = getenv("GAZEBO_RESOURCE_PATH");
std::string gazeboResourcePathString(gazeboResourcePaths);
sdf::addURIPath("elem://", gazeboResourcePathString);
const std::string absolute_path = sdf::findFile(_sdf->Get<std::string>("elementToInclude"), true, false);

The absolute path then is given in the string absolute_path.

Best regards!

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower


Asked: 2015-11-25 08:45:12 -0500

Seen: 747 times

Last updated: Nov 26 '15