Skip to content

Commit 721130d

Browse files
fixed RViz crash if flat height layer is invalid
1 parent 03f8676 commit 721130d

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

grid_map_rviz_plugin/src/GridMapVisual.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ void GridMapVisual::computeVisualization(float alpha, bool showGridLines, bool f
8686
}
8787
const double resolution = map_.getResolution();
8888
const grid_map::Matrix& heightData = map_[flatTerrain ? layerNames[0] : heightLayer];
89-
const grid_map::Matrix& colorData = map_[flatColor ? layerNames[0] : colorLayer];
89+
const grid_map::Matrix& colorData = map_[(flatColor || noColor) ? layerNames[0] : colorLayer];
9090

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

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

119119
// Compute the color data for each cell.
120120
ColoringMethod coloringMethod;
121-
if (flatColor) {
121+
if (flatColor || noColor) {
122122
coloringMethod = ColoringMethod::FLAT;
123123
} else if(mapLayerColor) {
124124
coloringMethod = ColoringMethod::COLOR_LAYER;

0 commit comments

Comments
 (0)