rosjava / android_core

Android libraries for rosjava
144 stars 166 forks source link

Possible bug / unexpected behaviour inside OccupancyGrid #297

Closed stringnotfound1 closed 5 years ago

stringnotfound1 commented 5 years ago

I'm currently working with the visualization part of android_core and wondering about the following part inside OccupancyGridLayer:

if (x < numTilesWide - 1) { tiles.get(tileIndex).setStride(TextureBitmap.STRIDE); } else { tiles.get(tileIndex).setStride(width % TextureBitmap.STRIDE); }

I'm receiving a map with a 2048x2048 resolution and therefore 4 tiles are created. The tiles on top (x = 1) get a stride (aka width) of 0 assigned which makes the content invisible since the TextureBitMap assigns the fillcolor. Setting the stride of the tiles to TextureBitMap.STRIDE instead seems to solve the problem.

I don't know if the current implementation is solving a problem that I'm not aware of which is why I created this issue.

jubeira commented 5 years ago

Hi @stringnotfound1, You might be right about this. If you send a PR with a fix, please include a couple of screenshots showing the before and after so that it's a bit easier to review. Thanks in advance!

stringnotfound1 commented 5 years ago

It might take a while until I manage to create the PR so here's a preview. All I did was replacing:

if (x < numTilesWide - 1) {
    tiles.get(tileIndex).setStride(TextureBitmap.STRIDE);
} else {
    tiles.get(tileIndex).setStride(width % TextureBitmap.STRIDE);
}

with

tiles.get(tileIndex).setStride(TextureBitmap.STRIDE);

inside OccupancyGridLayer.

Before (I changed the COLOR_TRANSPARENT to 0x55FF0000 for better visibility of the 'error'):

occupancy_error_0x55FF0000

After

proper_occupancy_map

jubeira commented 5 years ago

Closed via #298; thanks again @stringnotfound1!