Skip to content

Commit

Permalink
fixed RViz crash if flat height layer is invalid
Browse files Browse the repository at this point in the history
  • Loading branch information
simongiegerich committed Jan 23, 2023
1 parent 03f8676 commit 721130d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions grid_map_rviz_plugin/src/GridMapVisual.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ void GridMapVisual::computeVisualization(float alpha, bool showGridLines, bool f
}
const double resolution = map_.getResolution();
const grid_map::Matrix& heightData = map_[flatTerrain ? layerNames[0] : heightLayer];
const grid_map::Matrix& colorData = map_[flatColor ? layerNames[0] : colorLayer];
const grid_map::Matrix& colorData = map_[(flatColor || noColor) ? layerNames[0] : colorLayer];

// Reset and begin the manualObject (mesh).
// For more information: https://www.ogre3d.org/docs/api/1.7/class_ogre_1_1_manual_object.html#details
Expand All @@ -103,7 +103,7 @@ void GridMapVisual::computeVisualization(float alpha, bool showGridLines, bool f

// Compute a mask of valid cells.
auto basicLayers = map_.getBasicLayers();
if (std::find(basicLayers.begin(), basicLayers.end(), heightLayer) == basicLayers.end()) {
if (!flatTerrain && std::find(basicLayers.begin(), basicLayers.end(), heightLayer) == basicLayers.end()) {
basicLayers.emplace_back(heightLayer);
}
const MaskArray isValid = computeIsValidMask(basicLayers);
Expand All @@ -118,7 +118,7 @@ void GridMapVisual::computeVisualization(float alpha, bool showGridLines, bool f

// Compute the color data for each cell.
ColoringMethod coloringMethod;
if (flatColor) {
if (flatColor || noColor) {
coloringMethod = ColoringMethod::FLAT;
} else if(mapLayerColor) {
coloringMethod = ColoringMethod::COLOR_LAYER;
Expand Down

0 comments on commit 721130d

Please sign in to comment.