5 #ifndef __pinocchio_parsers_utils_hpp__
6 #define __pinocchio_parsers_utils_hpp__
12 #include <boost/filesystem/fstream.hpp>
13 #include <boost/foreach.hpp>
14 #include <boost/format.hpp>
16 #include "pinocchio/utils/file-explorer.hpp"
17 #include <boost/filesystem.hpp>
41 const std::string extension = filename.substr(filename.find_last_of(
".") + 1);
43 if (extension ==
"urdf")
63 namespace bf = boost::filesystem;
64 std::string result_path;
66 const std::string separator(
"://");
67 const std::size_t pos_separator =
string.find(separator);
68 bf::path string_path(
string);
70 if (pos_separator != std::string::npos)
72 std::string scheme =
string.substr(0, pos_separator);
73 std::string path =
string.substr(pos_separator + 3, std::string::npos);
75 if (scheme ==
"package" || scheme ==
"model")
82 for (std::size_t i = 0; i < package_dirs.size(); ++i)
84 if (bf::exists(bf::path(package_dirs[i] +
"/" + path)))
86 result_path = std::string(package_dirs[i] +
"/" + path);
91 else if (scheme ==
"file")
97 const std::string exception_message(
"Schemes of form" + scheme +
"are not handled");
98 throw std::invalid_argument(exception_message);
101 else if (string_path.is_relative())
104 for (std::size_t i = 0; i < package_dirs.size(); ++i)
106 if (bf::exists(bf::path(package_dirs[i] +
"/" +
string)))
108 result_path = std::string(package_dirs[i] +
"/" +
string);
115 result_path = string;
Main pinocchio namespace.
ModelFileExtensionType checkModelFileExtension(const std::string &filename)
Extract the type of the given model file according to its extension.
std::string retrieveResourcePath(const std::string &string, const std::vector< std::string > &package_dirs)
Retrieve the path of the file whose path is given in URL-format. Currently convert from the following...
ModelFileExtensionType
Supported model file extensions.