ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A answers.ros.org

# how can I build probability maps with gmapping

I want build probability maps, but I find that gmapping can only generate maps with 3 values (unknown, free and obstacle). How can gmapping work with probablility maps. Thank you. Further, I change source code, but it doesn't work too.

the code I changed is below: if(occ < 0) map_.map.data[MAP_IDX(map_.map.info.width, x, y)] = -1; else map_.map.data[MAP_IDX(map_.map.info.width, x, y)] = (int)round(occ*100.0);

edit retag close merge delete

Sort by ยป oldest newest most voted

It's not gmapping that is using only three discrete values, but the nav_msgs/OccupancyGrid.msg message format. Internally, gmapping uses probabilistic cell values, but in the slam_gmapping.cpp source, starting in line 631, those are converted to above linked message format like so:

for(int y=0; y < smap.getMapSizeY(); y++)
{
/// @todo Sort out the unknown vs. free vs. obstacle thresholding
GMapping::IntPoint p(x, y);
double occ=smap.cell(p);
assert(occ <= 1.0);
if(occ < 0)
map_.map.data[MAP_IDX(map_.map.info.width, x, y)] = -1;
else if(occ > occ_thresh_)
{
//map_.map.data[MAP_IDX(map_.map.info.width, x, y)] = (int)round(occ*100.0);
map_.map.data[MAP_IDX(map_.map.info.width, x, y)] = 100;
}
else
map_.map.data[MAP_IDX(map_.map.info.width, x, y)] = 0;
}


Haven't played around with the code, but the occ variable should hold the probability of occupancy.

more

Hi Stefan, I guess it is an update after a long time! When I was trying to work on your suggestion and tried assigning the occ value directly to the map data and publish it I find the same -1,0,100 as the values and cant access the probability. Do you have some more input about this?

( 2019-05-10 10:00:53 -0600 )edit

I would be very surprised if gmapping only outputs three values. You should have occupancies in the maps. Maybe you are doing something wrong in interpreting the raw data.

Also, the fact that you changed some line of code somewhere and "it doesn't work", doesn't encourage someone to properly help you.

more