55 int main(
int argc,
char** argv)
62 std::string map_filename;
63 private_nh.
param(
"map_filename", map_filename, std::string(
"package://global_planner_tests/maps/smile.png"));
64 std::shared_ptr<global_planner_tests::EasyCostmap> global_costmap =
65 std::make_shared<global_planner_tests::EasyCostmap>(map_filename);
69 std::string planner_name;
70 private_nh.
param(
"global_planner", planner_name, std::string(
"dlux_global_planner::DluxGlobalPlanner"));
72 global_planner->initialize(private_nh, global_planner_loader.getName(planner_name), tf, global_costmap);
76 groupCells(*global_costmap, free_cells, occupied_cells);
79 unsigned int n = free_cells.size();
86 int passing_plans = 0, total_plans = 0;
87 std::vector<unsigned int> failures(n, 0);
89 for (
unsigned int j = 0; j < n; j++)
91 for (
unsigned int i = 0; i < n; i++)
95 int pct = (total_plans /
static_cast<float>(n * n)) * 20;
101 passing = 100.0 * passing_plans / total_plans;
103 ROS_INFO(
"%d%% complete. %d tests, %.0f%% passing", pct * 100 / 20, total_plans, passing);
107 total_plans = total_plans + 1;
109 if (
planExists(*global_planner, free_cells[i], free_cells[j]))
111 passing_plans = passing_plans + 1;
125 std::vector<char> mmap(info.
width * info.
height,
'.');
126 unsigned int highest = *std::max_element(failures.begin(), failures.end());
128 for (
unsigned int i = 0; i < n; i++)
132 int ct = failures[i];
135 mmap[ global_costmap->getIndex(x, y) ] =
' ';
139 double f =
static_cast<double>(ct) / highest;
140 int m =
static_cast<int>(f * 9);
141 mmap[ global_costmap->getIndex(x, y) ] =
'0' + m;
144 for (
int j = info.
height - 1; j >= 0; j--)
146 for (
unsigned int i = 0; i < info.
width; i++)
148 printf(
"%c", mmap[ global_costmap->getIndex(i, j) ]);
153 ROS_INFO(
"%d/%d valid plans found.", passing_plans, total_plans);
std::vector< nav_2d_msgs::Pose2DStamped > PoseList
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
TFSIMD_FORCE_INLINE const tfScalar & y() const
bool param(const std::string ¶m_name, T ¶m_val, const T &default_val) const
TFSIMD_FORCE_INLINE const tfScalar & x() const
bool planExists(nav_core2::GlobalPlanner &planner, nav_2d_msgs::Pose2DStamped start, nav_2d_msgs::Pose2DStamped goal)
Simple check to see if a plan exists. Returns a boolean instead of returning path or throwing an exce...
int main(int argc, char **argv)
std::shared_ptr< tf::TransformListener > TFListenerPtr
void groupCells(const nav_core2::Costmap &costmap, PoseList &free_cells, PoseList &occupied_cells, bool include_edges=true)
Populate two lists of poses from a costmap. one with all the free cells, the other with all the occup...
bool worldToGridBounded(const NavGridInfo &info, double wx, double wy, unsigned int &mx, unsigned int &my)