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.
like for every data[index] != -1, oh and 100 is occupied. What happens if the index is 0? will x be 0? also I read from map_metadata that width is 4000 would the points be really small?
Also how will I know how close the points are to each other, what if I want a certain distance between the points because I want a create a cell grid and I don't want the points to be too close to each other
@Usui yes, they will be very small. By defualt, I believe it's around 0.05 m / pixel (though it should say in your yaml file). For GMapping, -1 = unexplored, 0 = unoccupied, 100 = occupied (but this is not necessarily true for other mapping algorithms).
@allenh1 how do I make it bigger?
Why you need to know all the free points of your map? I would suggest to just check that the point where you want your robot to finish is free, and then, use a global planner, included in the navigation stack to compute the path from your position to your goal.
I want the robot to go to all point because I am using a roomba so it can clean everything using the tsp. I don't want it moving 0.01 mm for each cell because that would be inefficient.
I think you are trying to solve two problems at the same time. I don't think you need to know all the free points of your map to get your roomba passing through every spot. You need to program a lawn mower algorithm with the map you have. On the other hand, changing the resolution of your map can end up with your robot lost.
I want to turn the map into a cell grid map where each cell is as big as the robotand get all the coordinate of the center of the cell
@Usui this problem is actually quite complicated. There's a number of papers on the topic here. After a skimming, this one seems like a pretty good approach for your situation. Definitely a paper I'll read more in depth -- pretty interesting.