I'm developing a navigation algorithm, for which I need to find out corners and walls present in the room. I've been playing around with turtlebot simulation. I've made a very simple rectangular room of about 3.0 x 2.4 meter square. I've saved the map I generated using gmapping.
To find the corners and walls, I'm writing my own python script, using OpenCV functions like Harris Corner detection and Contours, and Canny. I'll be feeding the map.pgm file to do the same. I'll receive the pixels with corners and wall.
Now, I need to know where these are in relation to the bot. That's where the problem is.
I am not able to understand where does the map set its origin?
And if it's the same for every map file?
Does the robot's start, end pose or trajectory during the gmapping affect the map origin?
Also, if the map isn't at the top left corner, then how can I compute the distance between that pixel and my robot? I'd thought of identifying the pixel, then knowing its location with respect to map, and map's origin with respect to base_footprint. That way I'd know the vector joining the pixel and the base_footprint, and can drive to the point if I want to. I'm using the default 0.05 resolution, therefore each pixel should be 5 cm.
According to my observations, the map origin depends on the start pose of the robot while the mapping process. But if someone experienced can answer these questions, it would be a great help.
Also, if you think this isn't a good approach, and have a better approach, please teach me, or let me know. Thanks!
As per following images, map origin isn't same, and not necessarily at the top left. Map 1:
Post score: 2
Comment by parzival on 2019-11-09:
I read about nav_msgs/OccupancyGrid and nav_msgs/MapMetaData. So the /map will have cell values (-1, 0 or 100) and that MapMetaData is a part of OccupancyGrid message, and holds info like height, width, resolution and origin. Can I use the origin data to calculate the cell value of the map origin, and therefore to calculate its distance from any pixel of interest?