39 #include <yaml-cpp/yaml.h> 46 const std::string& planner_name,
const std::string& maps_list_filename,
47 bool check_exception_type,
bool verbose,
bool quit_early)
51 std::shared_ptr<EasyCostmap> easy_costmap = std::make_shared<EasyCostmap>();
52 planner.
initialize(nh, planner_name, tf, easy_costmap);
56 std::string prefix =
"";
57 int max_failure_cases = 10;
58 if (config[
"standard_prefix"])
60 prefix = config[
"standard_prefix"].as<std::string>();
62 if (config[
"max_failure_cases"])
64 max_failure_cases = config[
"max_failure_cases"].as<
int>();
68 struct timeval start, end;
69 double start_t, end_t, t_diff;
70 gettimeofday(&start,
nullptr);
72 bool passes_all =
true;
75 for (
const std::string base_filename : config[
"full_coverage_maps"].as<std::vector<std::string> >())
77 std::string map_filename = prefix + base_filename;
78 ROS_INFO(
"Testing full coverage map \"%s\"", map_filename.c_str());
79 easy_costmap->loadMapFromFile(map_filename);
82 check_exception_type, verbose, quit_early);
83 if (quit_early && !ret)
return ret;
88 for (
const std::string base_filename : config[
"no_coverage_maps"].as<std::vector<std::string> >())
90 std::string map_filename = prefix + base_filename;
91 ROS_INFO(
"Testing no coverage map \"%s\"", map_filename.c_str());
92 easy_costmap->loadMapFromFile(map_filename);
95 check_exception_type, verbose, quit_early);
96 if (quit_early && !invalid_test)
return invalid_test;
97 passes_all &= invalid_test;
100 gettimeofday(&end,
nullptr);
101 start_t = start.tv_sec +
static_cast<double>(start.tv_usec) / 1e6;
102 end_t = end.tv_sec +
static_cast<double>(end.tv_usec) / 1e6;
103 t_diff = end_t - start_t;
104 ROS_INFO(
"%s Full Planning Time: %.9f", planner_name.c_str(), t_diff);
std::string resolve_filename(const std::string &filename)
Replace a package:// prefix with the actual path to the given package.
virtual void initialize(const ros::NodeHandle &parent, const std::string &name, TFListenerPtr tf, Costmap::Ptr costmap)=0
bool many_map_test_suite(nav_core2::GlobalPlanner &planner, TFListenerPtr tf, const std::string &planner_name, const std::string &maps_list_filename="package://global_planner_tests/config/standard_tests.yaml", bool check_exception_type=true, bool verbose=false, bool quit_early=true)
Run a collection of global_planner_tests on the provided maps.
bool hasCompleteCoverage(nav_core2::GlobalPlanner &planner, const nav_core2::Costmap &costmap, int max_failure_cases=10, bool check_exception_type=true, bool verbose=false, bool quit_early=true)
Run a bunch of tests, assuming there is a valid path from any free cell to any other free cell...
std::shared_ptr< tf::TransformListener > TFListenerPtr
bool hasNoPaths(nav_core2::GlobalPlanner &planner, const nav_core2::Costmap &costmap, bool check_exception_type=true, bool verbose=false, bool quit_early=true)
Run a bunch of tests, assuming there are no valid paths from any free cell to any other free cell...