Skip to content

Commit

Permalink
Fixed #1211
Browse files Browse the repository at this point in the history
  • Loading branch information
matlabbe committed Feb 11, 2024
1 parent cd615c6 commit a11ea29
Showing 1 changed file with 40 additions and 3 deletions.
43 changes: 40 additions & 3 deletions corelib/src/Rtabmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1868,9 +1868,46 @@ bool Rtabmap::process(
//============================================================
// Bayes filter update
//============================================================
int previousId = signature->getLinks().size() && signature->getLinks().begin()->first!=signature->id()?signature->getLinks().begin()->first:0;
bool localizationOnPreviousUpdate = false;
if(_memory->isIncremental())
{
localizationOnPreviousUpdate =
signature->getLinks().size() &&
signature->getLinks().begin()->first!=signature->id() &&
_memory->getLoopClosureLinks(signature->getLinks().begin()->first, false).size() != 0;
}
else
{
// localization mode

// Count how many localization links are in the constraints
int localizationLinks = 0;
int previousIdWithLocalizationLink = 0;
for(std::multimap<int, Link>::iterator iter=_odomCacheConstraints.begin();
iter!=_odomCacheConstraints.end(); ++iter)
{
if(previousIdWithLocalizationLink == iter->first)
{
// ignore links with node already counted
continue;
}
if(iter->second.type() == Link::kGlobalClosure ||
iter->second.type() == Link::kLocalSpaceClosure ||
iter->second.type() == Link::kLocalTimeClosure ||
iter->second.type() == Link::kUserClosure ||
iter->second.type() == Link::kNeighborMerged ||
iter->second.type() == Link::kLandmark)
{
++localizationLinks;
previousIdWithLocalizationLink = iter->first;
}
}

localizationOnPreviousUpdate = localizationLinks > 1; // need two links in case we have delayed localization
}

// Not a bad signature, not an intermediate node, not a small displacement unless the previous signature didn't have a loop closure, not too fast movement
if(!signature->isBadSignature() && signature->getWeight()>=0 && (!smallDisplacement || _memory->getLoopClosureLinks(previousId, false).size() == 0) && !tooFastMovement)
if(!signature->isBadSignature() && signature->getWeight()>=0 && (!smallDisplacement || !localizationOnPreviousUpdate) && !tooFastMovement)
{
// If the working memory is empty, don't do the detection. It happens when it
// is the first time the detector is started (there needs some images to
Expand Down Expand Up @@ -2550,7 +2587,7 @@ bool Rtabmap::process(

// don't do it if it is a small displacement unless the previous signature didn't have a loop closure
// don't do it if there is a too fast movement
if((!smallDisplacement || _memory->getLoopClosureLinks(previousId, false).size() == 0) && !tooFastMovement)
if((!smallDisplacement || !localizationOnPreviousUpdate) && !tooFastMovement)
{

//============================================================
Expand Down

0 comments on commit a11ea29

Please sign in to comment.