How to get all position in a map (SLAM) for robot to go to?
So I am using gmapping + map_saver to save a map. Then using amcl + map_server for localization. In this tutoral: http://wiki.ros.org/navigation/Tutori... it shows how to send goals to places in the map. However. I am not sure how I will be able to get all the points position on the map to send the robot to.
Could I use occupancy?
I notice that occupancy has either 0, -1, or 100. Does that mean I can try to get the position of all the 0's? If so how? Also how will I know how big each cell is because I want the cell to be the size of my robot not a bunch of big or small cells.
can you already visualise the map on Rviz?
Probably? I would say that depends on how good your map is. But that's disregarding any sense of the robot's physical limitations (unoccupied != navigable).
I'm not sure what you mean by this. Are you referring to the rotational difference between two points, or are you referring to the transforms between the /map and /base_footprint (or whichever tf frame you are using)?
@curi_ROS yes I can visualise the map on rviz basically I have localize it with amcl using laser and map_server
@allenh1 So is it possible to write a node that gives me all of the (x,y) position in the map so I can know where all of them are and send the robot to the position I want? If so which message? Since map_server (nav_msgs/OccupancyGrid) has MapMetaData info
int8[] data
(which one gives the position (x,y) so that I can send goal)
@Usui yes -- data[] is an array of size width * height. You just need to convert an index to (x, y). Given an (x, y), you map to the index
width * y + x
. Thus the inverse operation (given an index, map to an (x, y) coordinate) can be done with division and modulo. Sodata[idx]
corresponds to the point(idx / width, idx % width)
.Then you need to scale and find the origin. At that point, it's not too hard to iterate and check for occupancy.
@allenh1 so for each data[indx] that is not -1 or 100, x = indx/ width and y = indx%width?
indx is an array element, so it cannot be -1. I can't speak for the 100 bound, since I don't know the dimensions of the map. But the x, y mappings there are correct.