Skip to content

Commit

Permalink
rtabmap: updated proximity paths check order when likehood is not ava…
Browse files Browse the repository at this point in the history
…ilable (use closest node). MainWindow: don't pause when error happens in monitoring mode / ROS. DbViewer: show local transform of scan.
  • Loading branch information
matlabbe committed Feb 12, 2022
1 parent 191e165 commit 4776de7
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 9 deletions.
30 changes: 24 additions & 6 deletions corelib/src/Rtabmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1038,23 +1038,32 @@ void Rtabmap::resetMemory()
class NearestPathKey
{
public:
NearestPathKey(float l, int i) :
NearestPathKey(float l, int i, float d) :
likelihood(l),
id(i){}
id(i),
distance(d){}
bool operator<(const NearestPathKey & k) const
{
if(likelihood < k.likelihood)
{
return true;
}
else if(likelihood == k.likelihood && id < k.id)
else if(likelihood == k.likelihood)
{
return true;
if(distance > k.distance)
{
return true;
}
else if(distance == k.distance && id < k.id)
{
return true;
}
}
return false;
}
float likelihood;
int id;
float distance;
};

//============================================================
Expand Down Expand Up @@ -1952,6 +1961,11 @@ bool Rtabmap::process(
else if(!signature->isBadSignature() && (smallDisplacement || tooFastMovement))
{
_highestHypothesis = lastHighestHypothesis;
UDEBUG("smallDisplacement=%d tooFastMovement=%d", smallDisplacement?1:0, tooFastMovement?1:0);
}
else
{
UDEBUG("Ignoring likelihood and loop closure hypotheses as current signature doesn't have enough visual features.");
}

//============================================================
Expand Down Expand Up @@ -2429,21 +2443,25 @@ bool Rtabmap::process(
UDEBUG("got %d paths", (int)nearestPathsNotSorted.size());
// sort nearest paths by highest likelihood (if two have same likelihood, sort by id)
std::map<NearestPathKey, std::map<int, Transform> > nearestPaths;
Transform currentPoseInv = _optimizedPoses.at(signature->id());
for(std::map<int, std::map<int, Transform> >::const_iterator iter=nearestPathsNotSorted.begin();iter!=nearestPathsNotSorted.end(); ++iter)
{
const std::map<int, Transform> & path = iter->second;
float highestLikelihood = 0.0f;
int highestLikelihoodId = iter->first;
float smallestDistanceSqr = -1;
for(std::map<int, Transform>::const_iterator jter=path.begin(); jter!=path.end(); ++jter)
{
float v = uValue(likelihood, jter->first, 0.0f);
if(v > highestLikelihood)
float distance = (currentPoseInv * jter->second).getNormSquared();
if(v > highestLikelihood || (v == highestLikelihood && (smallestDistanceSqr < 0 || distance < smallestDistanceSqr)))
{
highestLikelihood = v;
highestLikelihoodId = jter->first;
smallestDistanceSqr = distance;
}
}
nearestPaths.insert(std::make_pair(NearestPathKey(highestLikelihood, highestLikelihoodId), path));
nearestPaths.insert(std::make_pair(NearestPathKey(highestLikelihood, highestLikelihoodId, smallestDistanceSqr), path));
}
UDEBUG("nearestPaths=%d proximityMaxPaths=%d", (int)nearestPaths.size(), _proximityMaxPaths);

Expand Down
5 changes: 3 additions & 2 deletions guilib/src/DatabaseViewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4677,7 +4677,7 @@ void DatabaseViewer::update(int value,

if(data.laserScanRaw().size())
{
labelScan->setText(tr("Format=%1 Points=%2 [max=%3] Range=[%4->%5 m] Angle=[%6->%7 rad inc=%8] Has [Color=%9 2D=%10 Normals=%11 Intensity=%12]")
labelScan->setText(tr("Format=%1 Points=%2 [max=%3] Range=[%4->%5 m] Angle=[%6->%7 rad inc=%8] Has [Color=%9 2D=%10 Normals=%11 Intensity=%12] %13")
.arg(data.laserScanRaw().formatName().c_str())
.arg(data.laserScanRaw().size())
.arg(data.laserScanRaw().maxPoints())
Expand All @@ -4689,7 +4689,8 @@ void DatabaseViewer::update(int value,
.arg(data.laserScanRaw().hasRGB()?1:0)
.arg(data.laserScanRaw().is2d()?1:0)
.arg(data.laserScanRaw().hasNormals()?1:0)
.arg(data.laserScanRaw().hasIntensity()?1:0));
.arg(data.laserScanRaw().hasIntensity()?1:0)
.arg(data.laserScanRaw().localTransform().prettyPrint().c_str()));
}

//stereo
Expand Down
2 changes: 1 addition & 1 deletion guilib/src/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -962,7 +962,7 @@ bool MainWindow::handleEvent(UEvent* anEvent)
{
QMetaObject::invokeMethod(_ui->dockWidget_console, "show");
// The timer prevents multiple calls to pauseDetection() before the state can be changed
if(_state != kPaused && _state != kMonitoringPaused && _logEventTime->elapsed() > 1000)
if(_state != kPaused && _state != kMonitoringPaused && _state != kMonitoring && _logEventTime->elapsed() > 1000)
{
_logEventTime->start();
if(_preferencesDialog->beepOnPause())
Expand Down

0 comments on commit 4776de7

Please sign in to comment.