diff --git a/corelib/include/rtabmap/core/Parameters.h b/corelib/include/rtabmap/core/Parameters.h index 985d2c3a..f5d0c438 100644 --- a/corelib/include/rtabmap/core/Parameters.h +++ b/corelib/include/rtabmap/core/Parameters.h @@ -752,6 +752,7 @@ class RTABMAP_EXP Parameters RTABMAP_PARAM(GridGlobal, MinSize, float, 0.0, "Minimum map size (m)."); RTABMAP_PARAM(GridGlobal, Eroded, bool, false, "Erode obstacle cells."); RTABMAP_PARAM(GridGlobal, MaxNodes, int, 0, "Maximum nodes assembled in the map starting from the last node (0=unlimited)."); + RTABMAP_PARAM(GridGlobal, AltitudeDelta, float, 0, "Assemble only nodes that have the same altitude of +-delta meters of the current pose (0=disabled). This is used to generate 2D occupancy grid based on the current altitude (e.g., multi-floor building)."); RTABMAP_PARAM(GridGlobal, OccupancyThr, float, 0.5, "Occupancy threshold (value between 0 and 1)."); RTABMAP_PARAM(GridGlobal, ProbHit, float, 0.7, "Probability of a hit (value between 0.5 and 1)."); RTABMAP_PARAM(GridGlobal, ProbMiss, float, 0.4, "Probability of a miss (value between 0 and 0.5)."); diff --git a/guilib/src/MainWindow.cpp b/guilib/src/MainWindow.cpp index 498171c6..d7c34ba5 100644 --- a/guilib/src/MainWindow.cpp +++ b/guilib/src/MainWindow.cpp @@ -258,7 +258,7 @@ MainWindow::MainWindow(PreferencesDialog * prefDialog, QWidget * parent, bool sh setupMainLayout(_preferencesDialog->isVerticalLayoutUsed()); ParametersMap parameters = _preferencesDialog->getAllParameters(); - _occupancyGrid = new OccupancyGrid(); + _occupancyGrid = new OccupancyGrid(parameters); #ifdef RTABMAP_OCTOMAP _octomap = new OctoMap(parameters); #endif @@ -2466,19 +2466,39 @@ void MainWindow::updateMapCloud( } int maxNodes = uStr2Int(_preferencesDialog->getParameter(Parameters::kGridGlobalMaxNodes())); - if(maxNodes > 0 && poses.size()>1) + int altitudeDelta = uStr2Int(_preferencesDialog->getParameter(Parameters::kGridGlobalAltitudeDelta())); + if((maxNodes > 0 || altitudeDelta>0.0) && poses.size()>1) { - std::map nodes = graph::findNearestNodes(poses, poses.rbegin()->second, maxNodes); - std::map nearestPoses; - nearestPoses.insert(*poses.rbegin()); - for(std::map::iterator iter=nodes.begin(); iter!=nodes.end(); ++iter) + Transform currentPose = poses.rbegin()->second; + if(poses.find(0) != poses.end()) { - std::map::iterator pter = poses.find(iter->first); - if(pter != poses.end()) + currentPose = poses.at(0); + } + + std::map nearestPoses; + if(maxNodes > 0) + { + std::map nodes = graph::findNearestNodes(poses, currentPose, maxNodes); + for(std::map::iterator iter=nodes.begin(); iter!=nodes.end(); ++iter) { - nearestPoses.insert(*pter); + if(altitudeDelta<=0.0 || + fabs(poses.at(iter->first).z()-currentPose.z())first)); + } } } + else // altitudeDelta>0.0 + { + for(std::map::const_iterator iter=poses.begin(); iter!=poses.end(); ++iter) + { + if(fabs(iter->second.z()-currentPose.z())doubleSpinBox_grid_updateError->setObjectName(Parameters::kGridGlobalUpdateError().c_str()); _ui->doubleSpinBox_grid_minMapSize->setObjectName(Parameters::kGridGlobalMinSize().c_str()); _ui->spinBox_grid_maxNodes->setObjectName(Parameters::kGridGlobalMaxNodes().c_str()); + _ui->doubleSpinBox_grid_altitudeDelta->setObjectName(Parameters::kGridGlobalAltitudeDelta().c_str()); _ui->doubleSpinBox_grid_footprintRadius->setObjectName(Parameters::kGridGlobalFootprintRadius().c_str()); _ui->doubleSpinBox_grid_occThr->setObjectName(Parameters::kGridGlobalOccupancyThr().c_str()); _ui->doubleSpinBox_grid_probHit->setObjectName(Parameters::kGridGlobalProbHit().c_str()); diff --git a/guilib/src/ui/preferencesDialog.ui b/guilib/src/ui/preferencesDialog.ui index b905f2ae..c63513f4 100644 --- a/guilib/src/ui/preferencesDialog.ui +++ b/guilib/src/ui/preferencesDialog.ui @@ -63,7 +63,7 @@ 0 - -678 + 0 686 3357 @@ -95,7 +95,7 @@ QFrame::Raised - 5 + 16 @@ -12238,7 +12238,7 @@ If set to false, classic RTAB-Map loop closure detection is done using only imag - + Probability clamping threshold minimum. @@ -12274,7 +12274,7 @@ If set to false, classic RTAB-Map loop closure detection is done using only imag - + Erode obstacle cells. @@ -12287,7 +12287,7 @@ If set to false, classic RTAB-Map loop closure detection is done using only imag - + Probability of a hit. @@ -12300,7 +12300,7 @@ If set to false, classic RTAB-Map loop closure detection is done using only imag - + Footprint radius used to clear all obstacles under the graph. @@ -12313,7 +12313,7 @@ If set to false, classic RTAB-Map loop closure detection is done using only imag - + @@ -12330,7 +12330,7 @@ If set to false, classic RTAB-Map loop closure detection is done using only imag - + m @@ -12432,7 +12432,7 @@ If set to false, classic RTAB-Map loop closure detection is done using only imag - + Occupancy threshold. @@ -12445,7 +12445,7 @@ If set to false, classic RTAB-Map loop closure detection is done using only imag - + @@ -12464,7 +12464,7 @@ If set to false, classic RTAB-Map loop closure detection is done using only imag - + Probability of a miss. @@ -12477,7 +12477,7 @@ If set to false, classic RTAB-Map loop closure detection is done using only imag - + @@ -12496,7 +12496,7 @@ If set to false, classic RTAB-Map loop closure detection is done using only imag - + @@ -12515,7 +12515,7 @@ If set to false, classic RTAB-Map loop closure detection is done using only imag - + Probability clamping threshold maximum. @@ -12528,7 +12528,7 @@ If set to false, classic RTAB-Map loop closure detection is done using only imag - + @@ -12550,7 +12550,7 @@ If set to false, classic RTAB-Map loop closure detection is done using only imag - + @@ -12572,6 +12572,41 @@ If set to false, classic RTAB-Map loop closure detection is done using only imag + + + + Altitude delta. Assemble only nodes that have the same altitude of +-delta meters of the current pose (0=disabled). This is used to generate 2D occupancy grid based on the current altitude (e.g., multi-floor building). + + + true + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + m + + + 2 + + + 0.000000000000000 + + + 99.000000000000000 + + + 0.100000000000000 + + + 0.000000000000000 + + +