From the documentation:
Parameters:
wx - The x world coordinate
wy - The y world coordinate
mx - Will be set to the associated map x coordinate
my - Will be set to the associated map y coordinate
Essentially, the world coordinates are in meters and the map coordinates are in pixels. This function doesn't transform between frames in the tf tree; it converts physical coordinates (e.g., [meters] in the map
frame) into image coordinates in the current costmap
image, using an origin shift and scaling by the costmap
resolution. Here's the function implementation for clarity:
00548 bool Costmap2D::worldToMap(double wx, double wy, unsigned int& mx, unsigned int& my) const {
00549 if(wx < origin_x_ || wy < origin_y_)
00550 return false;
00551
00552 mx = (int) ((wx - origin_x_) / resolution_);
00553 my = (int) ((wy - origin_y_) / resolution_);
00554
00555 if(mx < size_x_ && my < size_y_)
00556 return true;
00557
00558 return false;
00559 }