Ask Your Question
1

how can I build probability maps with gmapping

asked 2012-06-03 22:15:41 -0500

igoliao gravatar image

updated 2012-06-03 22:19:59 -0500

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 flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
4

answered 2012-06-04 00:55:07 -0500

updated 2012-06-04 01:02:46 -0500

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.

See also this question/answer about visualization in rviz.

edit flag offensive delete link more

Comments

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?

Thanks in advance

A_Hari gravatar image A_Hari  ( 2019-05-10 10:00:53 -0500 )edit
1

answered 2012-06-03 23:43:06 -0500

dornhege gravatar image

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.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2012-06-03 22:15:41 -0500

Seen: 626 times

Last updated: Jun 04 '12