ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Understanding costmap_2d tutorial: Updating master_grid

asked 2014-04-30 04:51:56 -0500

Luke_ROS gravatar image

updated 2014-04-30 05:40:58 -0500

I'm trying to understand this tutorial about the new layered costmap structure in Hydro. I successfully integrated the grid_layer and it runs out of the box just fine.

I then started to work with a recorded bag-file and the used layer structure in the yaml file looks like

  plugins:  
    - {name: static_layer, type: "costmap_2d::StaticLayer"}
    - {name: obstacle_layer, type: "costmap_2d::VoxelLayer"}
    - {name: grid_layer, type: "navigation::GridLayer"}

So to my understanding the static_layer should be the "lowest" layer. Then comes the obstacle_layer handling the input data and then the new grid_layer (according to this paper). So there are two rounds: In one round all layers update the Bounds to their needs. Then in the second round each layer writes to the master costmap (master_grid), right? So now the critical part of the code I don't understand is the following:

void GridLayer::updateCosts(costmap_2d::Costmap2D& master_grid, int min_i, int min_j, int max_i,
                                          int max_j)
{
  if (!enabled_)
    return;

  for (int j = min_j; j < max_j; j++)
  {
    for (int i = min_i; i < max_i; i++)
    {
      int index = getIndex(i, j);
      if (costmap_[index] == NO_INFORMATION)
        continue;
      master_grid.setCost(i, j, costmap_[index]); 
    }
  }
}

In the master_grid I clearly see obstacles moving around since the obstacle layer updates the master_grid as wished for. But then when its the grid_layer's turn to read and write the master_grid, the whole master_grid seems to contain NO_INFORMATION values (except for that tracking dot of course). Am I missing sth? Why does the grid_layer not see the obstacles updated by the obstacle_layer to the master_grid?

Is there an option in the yaml file I need to adjust or is it sth in the code?

Thanks for your time.

edit retag flag offensive close merge delete

Comments

The master grid should change, as you expect. Can you post your costmap configuration?

David Lu gravatar image David Lu  ( 2014-05-14 10:25:26 -0500 )edit

It does change. What I wanted to do was updating the layered_costmap_ (called master costmap in the paper). The way I would do it now is updating the master_grid as mentioned above and then use the functions updateWithOverwrite or updateWithMax. But I have not found time to try that out yet.

Luke_ROS gravatar image Luke_ROS  ( 2014-05-15 02:13:51 -0500 )edit

If you'd still like help with this, please post the configuration.

David Lu gravatar image David Lu  ( 2014-05-19 18:28:05 -0500 )edit

Thanks for offering your help. I think the answer I posted below solved the problem to a degree that I could continue with the construction of my own layer. My configuration is the same as in my other post: http://answers.ros.org/question/165571/obstacle_layer-does-not-clear-area/

Luke_ROS gravatar image Luke_ROS  ( 2014-05-20 00:28:32 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2014-05-03 05:48:34 -0500

Luke_ROS gravatar image

updated 2014-05-03 05:52:37 -0500

I'm not quite sure but I think I found part of the answer. My mistake was to assume that the master_grid would refer to the master costmap as mentioned in the paper. But this does not seem to be the case. If I would like to access the master costmap I should go over the so called layered_costmap_

Even though this may be the ugliest code around this is how I am now able to read out of the master costmap:

// READ
costmap_2d::Costmap2D* layered_costmap = layered_costmap_->getCostmap();
unsigned char* master_array = layered_costmap->getCharMap();
unsigned char element_500 = master_array[500];

But I am still confused how to properly write to the master costmap (layered_costmap_)... Do I go via the master_grid? Or do I go over functions like updateWithOverwrite()? Or may it be sth into the direction of layered_costmap->setCost(x,y,value)?

edit flag offensive delete link more

Comments

I am facing the same stuff, did u got something?

matteopantano gravatar image matteopantano  ( 2017-05-05 16:13:19 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2014-04-30 04:51:56 -0500

Seen: 2,241 times

Last updated: May 03 '14