56 int main(
int argc,
char** argv)
63 std::string map_filename;
64 private_nh.
param(
"map_filename", map_filename, std::string(
"package://global_planner_tests/maps/smile.png"));
65 std::shared_ptr<global_planner_tests::EasyCostmap> global_costmap =
66 std::make_shared<global_planner_tests::EasyCostmap>(map_filename);
70 std::string planner_name;
71 private_nh.
param(
"global_planner", planner_name, std::string(
"dlux_global_planner::DluxGlobalPlanner"));
73 global_planner->initialize(private_nh, global_planner_loader.getName(planner_name), tf, global_costmap);
77 groupCells(*global_costmap, free_cells, occupied_cells);
80 unsigned int n = free_cells.size();
87 int passing_plans = 0, total_plans = 0;
88 std::vector<unsigned int> failures(n, 0);
90 for (
unsigned int j = 0; j < n; j++)
92 for (
unsigned int i = 0; i < n; i++)
96 int pct = (total_plans /
static_cast<float>(n * n)) * 20;
102 passing = 100.0 * passing_plans / total_plans;
104 ROS_INFO(
"%d%% complete. %d tests, %.0f%% passing", pct * 100 / 20, total_plans, passing);
108 total_plans = total_plans + 1;
110 if (
planExists(*global_planner, free_cells[i], free_cells[j]))
112 passing_plans = passing_plans + 1;
126 std::vector<char> mmap(info.
width * info.
height,
'.');
127 unsigned int highest = *std::max_element(failures.begin(), failures.end());
129 for (
unsigned int i = 0; i < n; i++)
133 int ct = failures[i];
136 mmap[ global_costmap->getIndex(x, y) ] =
' ';
140 double f =
static_cast<double>(ct) / highest;
141 int m =
static_cast<int>(f * 9);
142 mmap[ global_costmap->getIndex(x, y) ] =
'0' + m;
145 for (
int j = info.
height - 1; j >= 0; j--)
147 for (
unsigned int i = 0; i < info.
width; i++)
149 printf(
"%c", mmap[ global_costmap->getIndex(i, j) ]);
154 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)