44 setMap(gridMap, unknown_as_obstacle);
67 void GridMap2D::setMap(
const nav_msgs::OccupancyGridConstPtr& grid_map,
bool unknown_as_obstacle){
75 std::vector<signed char>::const_iterator mapDataIter = grid_map->data.begin();
78 unsigned char map_occ_thres = 70;
82 for(
unsigned int j = 0; j <
m_mapInfo.height; ++j){
83 for(
unsigned int i = 0; i <
m_mapInfo.width; ++i){
84 if (*mapDataIter > map_occ_thres
85 || (unknown_as_obstacle && *mapDataIter < 0))
101 nav_msgs::OccupancyGrid msg;
105 msg.data.resize(msg.info.height*msg.info.width);
108 std::vector<signed char>::iterator mapDataIter = msg.data.begin();
110 for(
unsigned int j = 0; j <
m_mapInfo.height; ++j){
111 for(
unsigned int i = 0; i <
m_mapInfo.width; ++i){
static const uchar OCCUPIED
char value for "free": 0
nav_msgs::OccupancyGrid toOccupancyGridMsg() const
Converts back into a ROS nav_msgs::OccupancyGrid msg.
bool isOccupiedAt(double wx, double wy) const
void worldToMapNoBounds(double wx, double wy, unsigned int &mx, unsigned int &my) const
void setMap(const nav_msgs::OccupancyGridConstPtr &grid_map, bool unknown_as_obstacle=false)
Initialize map from a ROS OccupancyGrid message.
cv::Mat m_distMap
distance map (in meter)
static const uchar FREE
char value for "free": 255
void updateDistanceMap()
Recalculate the internal distance map. Required after manual changes to the grid map data...
float distanceMapAtCell(unsigned int mx, unsigned int my) const
Returns distance (in m) at map cell <mx, my> in m; -1 if out of bounds!
bool worldToMap(double wx, double wy, unsigned int &mx, unsigned int &my) const
void mapToWorld(unsigned int mx, unsigned int my, double &wx, double &wy) const
std::string m_frameId
"map" frame where ROS OccupancyGrid originated from
uchar binaryMapAt(double wx, double wy) const
Returns map value at world coordinates <wx, wy>; out of bounds will be returned as 0! ...
uchar binaryMapAtCell(unsigned int mx, unsigned int my) const
Returns map value at map cell <mx, my>; out of bounds will be returned as 0!
float distanceMapAt(double wx, double wy) const
Returns distance (in m) at world coordinates <wx,wy> in m; -1 if out of bounds!
nav_msgs::MapMetaData m_mapInfo
void inflateMap(double inflationRaduis)
Stores a nav_msgs::OccupancyGrid in a convenient opencv cv::Mat as binary map (free: 255...
const cv::Mat & binaryMap() const
bool inMapBounds(double wx, double wy) const
check if a coordinate is covered by the map extent (same as worldToMap)
cv::Mat m_binaryMap
binary occupancy map. 255: free, 0 occupied.
bool isOccupiedAtCell(unsigned int mx, unsigned int my) const