1 #ifndef COSTMAP_TOOLS_H_ 2 #define COSTMAP_TOOLS_H_ 4 #include <geometry_msgs/PolygonStamped.h> 5 #include <geometry_msgs/PointStamped.h> 7 #include <boost/foreach.hpp> 20 std::vector<unsigned int> out;
24 if (idx > size_x_ * size_y_ -1){
25 ROS_WARN(
"Evaluating nhood for offmap point");
29 if(idx % size_x_ > 0){
30 out.push_back(idx - 1);
32 if(idx % size_x_ < size_x_ - 1){
33 out.push_back(idx + 1);
36 out.push_back(idx - size_x_);
38 if(idx < size_x_*(size_y_-1)){
39 out.push_back(idx + size_x_);
53 std::vector<unsigned int> out =
nhood4(idx, costmap);
57 if (idx > size_x_ * size_y_ -1){
61 if(idx % size_x_ > 0 && idx >= size_x_){
62 out.push_back(idx - 1 - size_x_);
64 if(idx % size_x_ > 0 && idx < size_x_*(size_y_-1)){
65 out.push_back(idx - 1 + size_x_);
67 if(idx % size_x_ < size_x_ - 1 && idx >= size_x_){
68 out.push_back(idx + 1 - size_x_);
70 if(idx % size_x_ < size_x_ - 1 && idx < size_x_*(size_y_-1)){
71 out.push_back(idx + 1 + size_x_);
88 const unsigned char* map = costmap.
getCharMap();
91 if(start >= size_x * size_y){
96 std::queue<unsigned int> bfs;
97 std::vector<bool> visited_flag(size_x * size_y,
false);
101 visited_flag[start] =
true;
105 unsigned int idx = bfs.front();
115 BOOST_FOREACH(
unsigned nbr,
nhood8(idx, costmap)){
116 if(!visited_flag[nbr]){
118 visited_flag[nbr] =
true;
std::vector< unsigned int > nhood4(unsigned int idx, const costmap_2d::Costmap2D &costmap)
Determine 4-connected neighbourhood of an input cell, checking for map edges.
bool nearestCell(unsigned int &result, unsigned int start, unsigned char val, const costmap_2d::Costmap2D &costmap)
Find nearest cell of a specified value.
unsigned char * getCharMap() const
std::vector< unsigned int > nhood8(unsigned int idx, const costmap_2d::Costmap2D &costmap)
Determine 8-connected neighbourhood of an input cell, checking for map edges.
unsigned int getSizeInCellsY() const
unsigned int getSizeInCellsX() const