From 11a8057246f1bd52db5488e7725505c01ebfa477 Mon Sep 17 00:00:00 2001 From: matlabbe Date: Wed, 4 Sep 2024 11:39:38 -0700 Subject: [PATCH] LocalGrid: fixed overestimated local grid size when Grid/RangeMax is used --- corelib/src/util3d_mapping.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/corelib/src/util3d_mapping.cpp b/corelib/src/util3d_mapping.cpp index f46dd6b87d..21c787f9f6 100644 --- a/corelib/src/util3d_mapping.cpp +++ b/corelib/src/util3d_mapping.cpp @@ -642,10 +642,10 @@ cv::Mat create2DMap(const std::map & poses, // Added margin to make sure that all points are inside the map (when rounded to integer) float margin = cellSize*10.0f; - xMin = (unknownSpaceFilled && scanMaxRange > 0 && -scanMaxRange < min.x?-scanMaxRange:min.x) - margin; - yMin = (unknownSpaceFilled && scanMaxRange > 0 && -scanMaxRange < min.y?-scanMaxRange:min.y) - margin; - float xMax = (unknownSpaceFilled && scanMaxRange > 0 && scanMaxRange > max.x?scanMaxRange:max.x) + margin; - float yMax = (unknownSpaceFilled && scanMaxRange > 0 && scanMaxRange > max.y?scanMaxRange:max.y) + margin; + xMin = (scanMaxRange > 0 ? -scanMaxRange : min.x) - margin; + yMin = (scanMaxRange > 0 ? -scanMaxRange : min.y) - margin; + float xMax = (scanMaxRange > 0 ? scanMaxRange : max.x) + margin; + float yMax = (scanMaxRange > 0 ? scanMaxRange : max.y) + margin; UDEBUG("map min=(%fm, %fm) max=(%fm,%fm) (margin=%fm, cellSize=%fm, scan range=%f, min=[%fm,%fm] max=[%fm,%fm])", xMin, yMin, xMax, yMax, margin, cellSize, scanMaxRange, min.x, min.y, max.x, max.y);