0
$\begingroup$

Rosanswers logo

So the point is that during the mapping with a mobile robot I will get a set of coordinates during the process. I was wondering, how is possible to modify the values of the occupancy grid cells nearby such coordinates.

For instance, these coordinates would represent objects that I don't want them in the map but they have been detected and stored in the map during the gmapping process as obstacles. I am not sure how to approach, whether using a real-time processing or post-processing.

Is there any available tool that can achieve something similar?


Originally posted by chbloca on ROS Answers with karma: 94 on 2019-02-26

Post score: 0


Original comments

Comment by Delb on 2019-02-27:
Can you be more specific about what you exaclty want to achieve please ? How will you use your modified occupancy grid ?

I will get a set of coordinates during the process

How will you get them ?

Comment by chbloca on 2019-02-27:
An object detector implementation with a depth camera will provide the coordinates of certain objects. See for instance find_object. So when the robot detects these certain objects while gmapping, I'd like to remove them from the map (e.g. a paper bin).

Comment by Delb on 2019-02-27:
And by saying " remove them from the map" you mean clear the cell value at the pose of the object (i.e. from 100=obstacle to 0=free) to get a map with only the walls, do I understand your issue correctly ?

Comment by chbloca on 2019-02-27:
Indeed, that's what exactly what I wanted to express.

Comment by Delb on 2019-02-27:
Alsoo one last precision please : how will this new occupancy grid be used ? During the gmapping process or you just want to build a map without objects inside (meaning that you wouldn't have to "reinject" your occupancy grid in the mapping process)

Comment by chbloca on 2019-02-28:
The idea would be to "remove" from the occupancy grid little areas around the markers during gmapping process if possible, that is to build a map without objects inside.

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

What you want to achieve could be tricky. From my understanding of the pakage find_object (and correct me if I'm wrong, it's a key point), you will be able to get the position of some objects, it will be only one poisition but not the edges of this object. That means that you would know in the occupancy grid the area where you need to change the cells data, but not the exact pose of each cells.

With that in mind, you will have to find the edges of an object given its position.

First, you will need to get the occupancy grid from gmapping. To create your new map I would use two occupancy grid : one occupancy grid will be your objects free map, I'll call it cleared_map,and the other one would be used to create the previous one, I'll call it history_map.

Why two occupancy grids ?

The idea is to use the data from gmapping to create a new map. The data from the topic map is an array containing the value of each cells of your map. With gmapping the cells have three values :

  • -1 : UNKNOWN.
  • 0 : FREE.
  • 100 : OCCUPIED.

Your goal is to create a new map by replacing the values of the cells at the pose of an object from 100 to 0, that would remove the objects from the map. You need to have another occupancy grid to save the history of your objects that have been removed. This occupancy grid would have cells with intermediate values at the pose of the objects (I'll suggest 50 but anything different than 0, -1 or 100 would be fine). This occupancy grid will be constantly overwritten (meaning the value of each cells) by the occupancy grid from gmapping to always have the updated map, unless the cells have the value 50. By doing so you won't have to deal with the same object each time. Without history_map, you wouldn't know which cell needs to be overwritten or not and you would do the same calculations over and over.

Then you will have to remove the objects and you'll be able to create the cleared_map by changing every cells of histroy_map from the value 50 to 0.

Delete your objects

You now have your history_map, the goal is now to find which cells will be set at the value 50. You do have the pose of your objects. To work from a pose with an occupancy grid you first need to convert this pose to an index to get the corresponding cell.

Now here's the tricky part. You have to find all the cells corresponding to your object. You can assume that an object in map is always a group of cells at the value -1 and the edges at 100 (because gmapping can't see inside objects so the cells are always unknown). For a cylindric paper bin as you used this example the map data should be something like that :

0     0     0     0     0     0
0     0    100   100    0     0
0    100   -1    -1    100    0
0    100   -1    -1    100    0
0     0    100   100    0     0
0     0     0     0     0     0

You may assume that the position given by find_object is the center of an object so the cell would always have the value -1. You need to check all the neighbor cells of the cell you get from the object pose having the value -1 until you find a neighbor with the value 100. Once you get the list of all the cells at the object pose you can change their value to 50 :

0     0     0     0     0     0
0     0     50    50    0     0
0     50    50    50    50    0
0     50    50    50    50    0
0     0     50    50    0     0
0     0     0     0     0     0

Now you have your history_map with an object detected, you just have to copy the occupancy grid and replace the 50 by 0 to get your cleared_map.

Note : I couldn't find ros packages doing that but you can probably identify objects using openCV, that would be more precize and easier than working direclty with the occupancy grid data. Moreover, if my first assumption about the coordinates of the objects being only one pose is wrong and you do have the edges, then the last part is trivial.

Hope it helps.


Originally posted by Delb with karma: 3907 on 2019-02-28

This answer was ACCEPTED on the original site

Post score: 1


Original comments

Comment by chbloca on 2019-02-28:
I do really find your answer very helpful indeed. I thought about the idea of creating an additional occupancy grid besides the map but I didn't think about having an auxiliar map in order to avoid redundant computations. I will research about the implementation of your approach, many thanks Delb.

Comment by Delb on 2019-02-28:
Glad it helps. Can you also tell me what is the otput of find_object ? Is it just one pose for an object or all the edges of the objects ?

Comment by chbloca on 2019-02-28:
It returns the transformations of the detections, i.e., the pose. Regardless what package I use, the procedure will be the same. I can also use packages more sophisticated based on deep learning instead.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.