|Please ask about problems and questions regarding this tutorial on answers.ros.org. Don't forget to include in your question the link to this page, the versions of your OS & ROS, and also add appropriate tags.|
Usage of asr_ros_uriDescription: This tutorial explains the available functions of the asr_ros_uri-package
Tutorial Level: BEGINNER
Simply add asr_ros_uri as a dependency and you can use the functions of this package.
Getting the absolute path of a URI
Call std::string absolute_path(std::string uriString) to get the absolute path of the given uri (either with a file or a package prefix).
std::string path = ros_uri::absolute_path("package://<package_name>/<path_in_package>");
Getting the package-URI from a file path
Call std::string package_uri(std::string pathStr, std::string packageName = std::string()) to get the package-URI for the given file. Optionally you can provide the name of the package the file is located in.
std::string uri = package_uri("/path/to/file");
Prefixing a path with the file-protocol prefix
Call std::string file_uri(fs::path path) to simply add the file-prefix to the given path.