Skip to content

Commit

Permalink
Merge branch 'borongyuan-likelihood_experiment'
Browse files Browse the repository at this point in the history
  • Loading branch information
matlabbe committed May 20, 2024
2 parents 256dcbd + 995f65b commit 0d4e473
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 54 deletions.
1 change: 1 addition & 0 deletions corelib/include/rtabmap/core/Parameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ class RTABMAP_CORE_EXPORT Parameters
RTABMAP_PARAM(Rtabmap, LoopThr, float, 0.11, "Loop closing threshold.");
RTABMAP_PARAM(Rtabmap, LoopRatio, float, 0, "The loop closure hypothesis must be over LoopRatio x lastHypothesisValue.");
RTABMAP_PARAM(Rtabmap, LoopGPS, bool, true, uFormat("Use GPS to filter likelihood (if GPS is recorded). Only locations inside the local radius \"%s\" of the current GPS location are considered for loop closure detection.", kRGBDLocalRadius().c_str()));
RTABMAP_PARAM(Rtabmap, VirtualPlaceLikelihoodRatio, int, 0, "Likelihood ratio for virtual place (for no loop closure hypothesis): 0=Mean / StdDev, 1=StdDev / (Max-Mean)");

// Memory
RTABMAP_PARAM(Mem, RehearsalSimilarity, float, 0.6, "Rehearsal similarity.");
Expand Down
1 change: 1 addition & 0 deletions corelib/include/rtabmap/core/Rtabmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ class RTABMAP_CORE_EXPORT Rtabmap
unsigned int _maxMemoryAllowed; // signatures count in WM
float _loopThr;
float _loopRatio;
int _virtualPlaceLikelihoodRatio;
float _maxLoopClosureDistance;
bool _verifyLoopClosureHypothesis;
unsigned int _maxRetrieved;
Expand Down
33 changes: 18 additions & 15 deletions corelib/src/Rtabmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ Rtabmap::Rtabmap() :
_maxMemoryAllowed(Parameters::defaultRtabmapMemoryThr()), // 0=inf
_loopThr(Parameters::defaultRtabmapLoopThr()),
_loopRatio(Parameters::defaultRtabmapLoopRatio()),
_virtualPlaceLikelihoodRatio(Parameters::defaultRtabmapVirtualPlaceLikelihoodRatio()),
_maxLoopClosureDistance(Parameters::defaultRGBDMaxLoopClosureDistance()),
_verifyLoopClosureHypothesis(Parameters::defaultVhEpEnabled()),
_maxRetrieved(Parameters::defaultRtabmapMaxRetrieved()),
Expand Down Expand Up @@ -567,6 +568,8 @@ void Rtabmap::parseParameters(const ParametersMap & parameters)
Parameters::parse(parameters, Parameters::kRtabmapMemoryThr(), _maxMemoryAllowed);
Parameters::parse(parameters, Parameters::kRtabmapLoopThr(), _loopThr);
Parameters::parse(parameters, Parameters::kRtabmapLoopRatio(), _loopRatio);
Parameters::parse(parameters, Parameters::kRtabmapVirtualPlaceLikelihoodRatio(), _virtualPlaceLikelihoodRatio);

Parameters::parse(parameters, Parameters::kRGBDMaxLoopClosureDistance(), _maxLoopClosureDistance);
Parameters::parse(parameters, Parameters::kVhEpEnabled(), _verifyLoopClosureHypothesis);
Parameters::parse(parameters, Parameters::kRtabmapMaxRetrieved(), _maxRetrieved);
Expand Down Expand Up @@ -5281,34 +5284,34 @@ void Rtabmap::adjustLikelihood(std::map<int, float> & likelihood) const
for(std::map<int, float>::iterator iter=++likelihood.begin(); iter!= likelihood.end(); ++iter)
{
float value = iter->second;
if(value > mean+stdDev && mean)
iter->second = 1.0f;
if(value > mean+stdDev)
{
iter->second = (value-(stdDev-epsilon))/mean;
if(value > max)
if(_virtualPlaceLikelihoodRatio==0 && mean)
{
max = value;
maxId = iter->first;
iter->second = (value-(stdDev-epsilon))/mean;
}
}
else if(value == 1.0f && stdDev == 0)
{
iter->second = 1.0f;
if(value > max)
else if(_virtualPlaceLikelihoodRatio!=0 && stdDev)
{
max = value;
maxId = iter->first;
iter->second = (value-mean)/stdDev;
}
}
else

if(value > max)
{
iter->second = 1.0f;
max = value;
maxId = iter->first;
}
}

if(stdDev > epsilon && max)
if(_virtualPlaceLikelihoodRatio==0 && stdDev > epsilon && max)
{
likelihood.begin()->second = mean/stdDev + 1.0f;
}
else if(_virtualPlaceLikelihoodRatio!=0 && max > mean)
{
likelihood.begin()->second = stdDev/(max-mean) + 1.0f;
}
else
{
likelihood.begin()->second = 2.0f; //2 * std dev
Expand Down
1 change: 1 addition & 0 deletions guilib/src/PreferencesDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1006,6 +1006,7 @@ PreferencesDialog::PreferencesDialog(QWidget * parent) :
// Create hypotheses
_ui->general_doubleSpinBox_hardThr->setObjectName(Parameters::kRtabmapLoopThr().c_str());
_ui->general_doubleSpinBox_loopRatio->setObjectName(Parameters::kRtabmapLoopRatio().c_str());
_ui->comboBox_virtualPlaceLikelihoodRatio->setObjectName(Parameters::kRtabmapVirtualPlaceLikelihoodRatio().c_str());
_ui->comboBox_globalDescriptorExtractor->setObjectName(Parameters::kMemGlobalDescriptorStrategy().c_str());
connect(_ui->comboBox_globalDescriptorExtractor, SIGNAL(currentIndexChanged(int)), this, SLOT(updateGlobalDescriptorVisibility()));

Expand Down
108 changes: 69 additions & 39 deletions guilib/src/ui/preferencesDialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
<enum>QFrame::Raised</enum>
</property>
<property name="currentIndex">
<number>5</number>
<number>11</number>
</property>
<widget class="QWidget" name="page_22">
<layout class="QVBoxLayout" name="verticalLayout_29" stretch="0,0">
Expand Down Expand Up @@ -11789,30 +11789,34 @@ see Sqlite3 doc 'PRAGMA synchronous'.</string>
</item>
<item>
<layout class="QGridLayout" name="gridLayout_22" columnstretch="0,1">
<item row="0" column="0">
<widget class="QCheckBox" name="checkBox_bayes_fullPredictionUpdate">
<item row="3" column="0">
<widget class="QCheckBox" name="checkBox_rtabmap_loopGPS">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QDoubleSpinBox" name="general_doubleSpinBox_vp">
<property name="maximum">
<double>1.000000000000000</double>
</property>
<property name="singleStep">
<double>0.010000000000000</double>
</property>
<property name="value">
<double>0.900000000000000</double>
<item row="5" column="0">
<widget class="QComboBox" name="comboBox_globalDescriptorExtractor">
<property name="sizeAdjustPolicy">
<enum>QComboBox::AdjustToContents</enum>
</property>
<item>
<property name="text">
<string>Disabled</string>
</property>
</item>
<item>
<property name="text">
<string>PyDescriptor</string>
</property>
</item>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="label_113">
<item row="0" column="1">
<widget class="QLabel" name="label_142">
<property name="text">
<string>The VP here is the probability to be in a new place since no loop closure was found on the last iteration.</string>
<string>Regenerate all the prediction matrix on each iteration (otherwise only removed/added ids are updated).</string>
</property>
<property name="wordWrap">
<bool>true</bool>
Expand All @@ -11822,10 +11826,10 @@ see Sqlite3 doc 'PRAGMA synchronous'.</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="label_142">
<item row="3" column="1">
<widget class="QLabel" name="label_502">
<property name="text">
<string>Regenerate all the prediction matrix on each iteration (otherwise only removed/added ids are updated).</string>
<string>Use GPS to filter likelihood (if GPS is recorded). Only locations inside the Local Radius (see RGBD-SLAM panel) of the current GPS location are considered for loop closure detection.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
Expand All @@ -11835,16 +11839,10 @@ see Sqlite3 doc 'PRAGMA synchronous'.</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="label_82">
<item row="0" column="0">
<widget class="QCheckBox" name="checkBox_bayes_fullPredictionUpdate">
<property name="text">
<string>Use the tf-idf method to compute the likelihood. Otherwise, images are compared with each other.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
<string/>
</property>
</widget>
</item>
Expand All @@ -11858,10 +11856,23 @@ see Sqlite3 doc 'PRAGMA synchronous'.</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLabel" name="label_502">
<item row="1" column="0">
<widget class="QDoubleSpinBox" name="general_doubleSpinBox_vp">
<property name="maximum">
<double>1.000000000000000</double>
</property>
<property name="singleStep">
<double>0.010000000000000</double>
</property>
<property name="value">
<double>0.900000000000000</double>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="label_113">
<property name="text">
<string>Use GPS to filter likelihood (if GPS is recorded). Only locations inside the Local Radius (see RGBD-SLAM panel) of the current GPS location are considered for loop closure detection.</string>
<string>The VP here is the probability to be in a new place since no loop closure was found on the last iteration.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
Expand All @@ -11871,14 +11882,20 @@ see Sqlite3 doc 'PRAGMA synchronous'.</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="checkBox_rtabmap_loopGPS">
<item row="2" column="1">
<widget class="QLabel" name="label_82">
<property name="text">
<string/>
<string>Use the tf-idf method to compute the likelihood. Otherwise, images are compared with each other.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item row="4" column="1">
<item row="5" column="1">
<widget class="QLabel" name="label_6031">
<property name="text">
<string>Global descriptor extractor.</string>
Expand All @@ -11891,19 +11908,32 @@ see Sqlite3 doc 'PRAGMA synchronous'.</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLabel" name="label_755">
<property name="text">
<string>Likelihood ratio for VP.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QComboBox" name="comboBox_globalDescriptorExtractor">
<widget class="QComboBox" name="comboBox_virtualPlaceLikelihoodRatio">
<property name="sizeAdjustPolicy">
<enum>QComboBox::AdjustToContents</enum>
<enum>QComboBox::AdjustToContentsOnFirstShow</enum>
</property>
<item>
<property name="text">
<string>Disabled</string>
<string>Mean / StdDev</string>
</property>
</item>
<item>
<property name="text">
<string>PyDescriptor</string>
<string>StdDev / (Max-Mean)</string>
</property>
</item>
</widget>
Expand Down

0 comments on commit 0d4e473

Please sign in to comment.