Go to the documentation of this file.00001
00004
00005
00006
00007
00008 #include <iostream>
00009 #include <ros/package.h>
00010 #include <string>
00011 #include "../../include/cost_map_ros/utilities.hpp"
00012
00013
00014
00015
00016
00017 namespace cost_map {
00018
00019
00020
00021
00022
00023 std::string resolveResourceName(const std::string& resource_name) {
00024
00025
00026
00027
00028 std::string delimiter = "/";
00029 int index = resource_name.find(delimiter);
00030 if ( index == std::string::npos ) {
00031 throw std::invalid_argument(std::string("'") + resource_name + std::string("' is not a valid resource name."));
00032 }
00033 std::string package = resource_name.substr(0, index);
00034 std::string name = resource_name.substr(index + delimiter.length());
00035
00036
00037
00038
00039 std::string plugin_package = "cost_map_ros";
00040 std::string attribute = "image_resource";
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050 std::vector<std::string> costmaps;
00051 ros::package::getPlugins(plugin_package, attribute, costmaps);
00052 for (const auto& filename : costmaps) {
00053 if ( (filename.find(package) != std::string::npos) && (filename.find(name) != std::string::npos) ) {
00054 return filename;
00055 }
00056 }
00057
00058 throw std::runtime_error(std::string("resource name '") + resource_name + std::string("' is not available (try 'rospack plugins --attrib=image_resource cost_map_ros')."));
00059 }
00060
00061
00062
00063
00064
00065 }