Merge two or more occupancy maps
9 views (last 30 days)
Show older comments
Hi,
I am trying to build an occupancy map of an environment using MATLAB's Navigation and ROS toolbox along with Gazebo. I have three TurtleBot3 ground robots in three different rooms of the Gazebo environment and I am navigationg them to get the lidar scan data. Now, I would like to build a single map of the environment.
What would be an ideal way to merge all the three occupancy maps into a single map/figure?
1 Comment
Bram Surewaard
on 30 Apr 2021
Hey,
For a project I would like to achieve the same as you mentioned.
Did you manage to figure out how to do this?
Thanks!
Answers (2)
Remo Pillat
on 10 May 2021
Hi Akshay & Bram,
If you know the exact poses of the 3 different TurtleBots, you can call the insertRay function on a single occupancyMap (call function for each lidar reading and input pose of respective robot).
A simple example of this "mapping with known poses" problem is shown in this example (this is for a single lidar).
How are you currently building the map? I might be able to give additional suggestions based on the functionality you are currently using.
Thanks, Remo
0 Comments
Sooraj Sunil
on 17 Oct 2021
Edited: Sooraj Sunil
on 18 Oct 2021
Hi Akshay & Bram,
If the initial alignment between the robots are known then the merging is very simple:
- You can use insertRay as Remo suggested
- Or alternatively you can get the probability matrix of the individual maps using occupancyMatrix Matlab function then, you can go from probability to the log-odd space and then simply add the probabilities to merge them. Finally to reconstruct the occupancy map based on the new probabilities ( convert log-odd to probability) and with the known resolution use occupancyMap function.
However, if don't know the inital alignment you should employ a merging technique to compute the alignment. I wouldn't recommend multirobot_map_merge but if you want a quick solution you can have a look at it. It can be easily implemented in Matlab using this Matlab example.
1 Comment
Cameron Stabile
on 29 Oct 2021
Edited: Cameron Stabile
on 29 Oct 2021
Hi Akshay, Bram
If each of your robots is building up their own map in isolation and you want to use the maps to update the combined map (rather than inserting rays from different sensors), here are some additional alternatives:
1) Update subregions of a world-map using the block-syntax of updateOccupancy. With this, you can probabilistically integrate readings from each of your local maps into the corresponding region of your world map:
worldMap = occupancyMap(repmat(0.75,50,60));
localMap_1 = occupancyMap(rand(20)/2);
localMap_2 = occupancyMap(eye(20)/2+.25);
origin_1 = [0 0];
origin_2 = [0 30];
localMap_1.GridLocationInWorld = origin_1;
localMap_2.GridLocationInWorld = origin_2;
worldMap.updateOccupancy(origin_1, getOccupancy(localMap_1));
worldMap.updateOccupancy(origin_2, getOccupancy(localMap_2));
show(worldMap);
2) Another alternative is the syncWith method, which will overwrite the values of the first map with values of the second map in any overlapping region:
localMap_1.GridLocationInWorld(1) = 20
localMap_2.GridLocationInWorld(1) = 20;
worldMap.syncWith(localMap_1);
worldMap.syncWith(localMap_2);
show(worldMap);
Note that syncWith method is similar to directly getting/setting values:
localMap_1.GridLocationInWorld(1) = 40
localMap_2.GridLocationInWorld(1) = 40;
worldMap.setOccupancy(localMap_1.GridLocationInWorld,getOccupancy(localMap_1));
worldMap.setOccupancy(localMap_2.GridLocationInWorld,getOccupancy(localMap_2));
show(worldMap);
but it also handle maps with mismatched resolutions and/or translation offsets between map grids.
Hope this helps,
Cameron
See Also
Categories
Find more on Mapping in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!