How to get all position in a map (SLAM) for robot to go to?
So I am using gmapping + mapsaver to save a map. Then using amcl + mapserver for localization. In this tutoral: http://wiki.ros.org/navigation/Tutorials/SendingSimpleGoals 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.
Asked by Usui on 2019-06-01 21:34:53 UTC
Comments
can you already visualise the map on Rviz?
Asked by curi_ROS on 2019-06-03 00:16:26 UTC
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)?
Asked by allenh1 on 2019-06-03 15:40:42 UTC
@curi_ROS yes I can visualise the map on rviz basically I have localize it with amcl using laser and map_server
Asked by Usui on 2019-06-03 16:31:02 UTC
@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)
Asked by Usui on 2019-06-03 16:34:28 UTC
@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)
.Asked by allenh1 on 2019-06-10 10:53:37 UTC
Then you need to scale and find the origin. At that point, it's not too hard to iterate and check for occupancy.
Asked by allenh1 on 2019-06-10 10:54:15 UTC
@allenh1 so for each data[indx] that is not -1 or 100, x = indx/ width and y = indx%width?
Asked by Usui on 2019-06-10 11:42:33 UTC
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.
Asked by allenh1 on 2019-06-10 12:24:04 UTC
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?
Asked by Usui on 2019-06-10 12:36:54 UTC
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
Asked by Usui on 2019-06-10 12:39:09 UTC
@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).
Asked by allenh1 on 2019-06-10 15:06:26 UTC
@allenh1 how do I make it bigger?
Asked by Usui on 2019-06-10 15:59:08 UTC
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.
Asked by VictorCP on 2019-06-11 03:44:25 UTC
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.
Asked by Usui on 2019-06-13 17:47:43 UTC
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.
Asked by VictorCP on 2019-06-14 03:08:39 UTC
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
Asked by Usui on 2019-06-14 11:52:43 UTC
@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.
Asked by allenh1 on 2019-06-14 12:18:21 UTC
As I was trying to say, you need to work with two maps. One map, the grid cell obtained from the SLAM algorithm will help the robot to be localized. The other map will be required to plan the cleaning route. This second map can be anything you need for the algorithm you prepare. It could be a graph (from a voronoi diagram of the map), it could be, as you were saying, the grid cell with the cells expanded to be as large as the robot, and many other options. Check the link of @allenh1 to get more inside about the planning problem that you are facing.
Asked by VictorCP on 2019-06-17 03:34:13 UTC
Yes but if I could divide and get all the coordinates I could just use a TSP algorithm for path planning and get order of which coordinates I need to go to first and next ..... to last.
Asked by Usui on 2019-06-19 20:09:23 UTC
@Usui did you solve it yet? I have the same issue.
Asked by Redhwan on 2020-08-31 00:21:36 UTC