5 #ifndef __pinocchio_parsers_utils_hpp__ 6 #define __pinocchio_parsers_utils_hpp__ 13 #include <boost/filesystem/fstream.hpp> 14 #include <boost/foreach.hpp> 15 #include <boost/format.hpp> 17 #include "pinocchio/utils/file-explorer.hpp" 18 #include <boost/filesystem.hpp> 42 const std::string extension = filename.substr(filename.find_last_of(
".") + 1);
44 if (extension ==
"urdf")
46 else if (extension ==
"lua")
65 const std::vector<std::string> & package_dirs)
68 namespace bf = boost::filesystem;
69 std::string result_path;
71 const std::string separator(
"://");
72 const std::size_t pos_separator =
string.find(separator);
74 if (pos_separator != std::string::npos)
76 std::string scheme =
string.substr(0, pos_separator);
77 std::string path =
string.substr(pos_separator+3, std::string::npos);
79 if(scheme ==
"package")
86 for (std::size_t i = 0; i < package_dirs.size(); ++i)
88 if ( bf::exists( bf::path(package_dirs[i] +
"/" + path)))
90 result_path = std::string( package_dirs[i] +
"/" + path );
95 else if (scheme ==
"file")
101 const std::string exception_message (
"Schemes of form" + scheme +
"are not handled");
102 throw std::invalid_argument(exception_message);
107 result_path = string;
115 #endif // __pinocchio_parsers_utils_hpp__ ModelFileExtensionType checkModelFileExtension(const std::string &filename)
Extract the type of the given model file according to its extension.
Main pinocchio namespace.
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 an url-format. Currently convert from the folliw...
ModelFileExtensionType
Supported model file extensions.