Gazebo | Ignition | Community
Ask Your Question
0

Relative Paths in own sdf element

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

Illuminatur gravatar image

Hi,

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
0

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

nkoenig gravatar image

You can try using SDF's findFile function.

edit flag offensive delete link more
0

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

Illuminatur gravatar image

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

Hi,

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

<elementToInclude>elem://relative_path_to_file</elementToInclude>

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

Question Tools

1 follower

Stats

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

Seen: 1,265 times

Last updated: Nov 26 '15