# 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.

edit retag close merge delete

can you already visualise the map on Rviz?

( 2019-06-03 00:16:26 -0500 )edit

Could I use occupancy?

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).

Also I am not sure how to calculate the quaternion/orientation from one position to another.

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)?

( 2019-06-03 15:40:42 -0500 )edit

@curi_ROS yes I can visualise the map on rviz basically I have localize it with amcl using laser and map_server

( 2019-06-03 16:31:02 -0500 )edit

@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)

( 2019-06-03 16:34:28 -0500 )edit

@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. So data[idx] corresponds to the point (idx / width, idx % width).

( 2019-06-10 10:53:37 -0500 )edit

Then you need to scale and find the origin. At that point, it's not too hard to iterate and check for occupancy.

( 2019-06-10 10:54:15 -0500 )edit

@allenh1 so for each data[indx] that is not -1 or 100, x = indx/ width and y = indx%width?

( 2019-06-10 11:42:33 -0500 )edit

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.

( 2019-06-10 12:24:04 -0500 )edit