ANYbotics / grid_map

Universal grid map library for mobile robotic mapping
BSD 3-Clause "New" or "Revised" License
2.62k stars 799 forks source link

Index issue : Multiplying subgridmap with gridmap same size #250

Closed brunoeducsantos closed 4 years ago

brunoeducsantos commented 4 years ago

Hi, This is more a question than an issue, but here it goes. I want to multiply a grid_map to a sub-gridmap (of a larger map) with the same size. Is this possible as follows?

...
grid_map::SubmapGeometry subgeom(global_map, local_map.getPosition(), local_map.getLength(), isSuccess_);
for (grid_map::SubmapIterator iterator(global_map, subgeom.getStartIndex(), subgeom.getSize()); !iterator.isPastEnd(); ++iterator)
            {
                 grid_map::Index start_local = *iterator - subgeom.getStartIndex();
                float grid1 = global_map.at(global_layer, *iterator);
                float grid2 = local_map.at(local_layer, start_local); 
                float product = grid1*grid2;

}

For some reason, I have to subgeom.getSize()-1 to match a separate grid the same size of a subgrid of a parent map. Is that my issue? Or is a bug? Thanks, Bruno

maximilianwulf commented 4 years ago

Hey @brunoeducsantos, were you successful?

You could also try to do a matrix multiplication with eigen, as the underlying data type is eigen.