@@ -1288,9 +1288,9 @@ void Memory::addSignatureToWmFromLTM(Signature * signature)
12881288 }
12891289}
12901290
1291- int Memory::reduceNode (int id, float maxDistance, bool keepLinkedInDb)
1291+ int Memory::reduceNode (int id, float maxDistance, bool keepLinkedInDb, float neighborMergedRatio )
12921292{
1293- std::map<int , float > reducedTo = reduceNodeImpl (id, maxDistance, keepLinkedInDb);
1293+ std::map<int , float > reducedTo = reduceNodeImpl (id, maxDistance, keepLinkedInDb, neighborMergedRatio );
12941294 return reducedTo.empty ()?0 :reducedTo.rbegin ()->first ;
12951295}
12961296
@@ -1305,7 +1305,7 @@ bool canBeReduced(const Link & link, float maxDistance)
13051305 (maxDistance==0 || link.transform ().getNorm () < maxDistance);
13061306}
13071307
1308- std::map<int , float > Memory::reduceNodeImpl (int id, float maxDistance, bool keepLinkedInDb)
1308+ std::map<int , float > Memory::reduceNodeImpl (int id, float maxDistance, bool keepLinkedInDb, float neighborMergedRatio )
13091309{
13101310 UDEBUG (" Reducing %d (max distance=%f, keep linked in db=%s)" , id, maxDistance, keepLinkedInDb?" true" :" false" );
13111311 std::map<int , float > reducedTo;
@@ -1353,15 +1353,15 @@ std::map<int, float> Memory::reduceNodeImpl(int id, float maxDistance, bool keep
13531353 {
13541354 if (iter->second .type () == Link::kNeighborMerged )
13551355 {
1356+ s->removeLink (sTo ->id ());
13561357 if (maxDistance == 0 .0f )
13571358 {
13581359 // online graph reduction, always skip these links
13591360 continue ;
13601361 }
1361- s->removeLink (sTo ->id ());
13621362 std::list<std::pair<int , Transform> > path = graph::computePath (s->id (), sTo ->id (), this , false );
13631363 float pathLength = graph::computePathLength (uListToVector (path));
1364- if (!path.empty () && iter->second .transform ().getNorm () / pathLength > 0.2 )
1364+ if (!path.empty () && pathLength> 0 . 0f && iter->second .transform ().getNorm () / pathLength > neighborMergedRatio )
13651365 {
13661366 // skip, reachable by another path of similar size
13671367 continue ;
@@ -1429,18 +1429,6 @@ std::map<int, float> Memory::reduceNodeImpl(int id, float maxDistance, bool keep
14291429 }
14301430 }
14311431
1432- // remove neighbor links
1433- /* std::multimap<int, Link> linksCopy = links;
1434- for(std::multimap<int, Link>::iterator iter=linksCopy.begin(); iter!=linksCopy.end(); ++iter)
1435- {
1436- if(iter->second.type() == Link::kNeighborMerged)
1437- {
1438- // Removing only merged neighbor links, we keep original neighbor
1439- // links to be able to reprocess databases with correct odometry covariance.
1440- s->removeLink(iter->first);
1441- }
1442- }*/
1443-
14441432 this ->moveToTrash (s, keepLinkedInDb);
14451433 s = 0 ;
14461434 _linksChanged = true ;
@@ -1451,7 +1439,7 @@ std::map<int, float> Memory::reduceNodeImpl(int id, float maxDistance, bool keep
14511439 // Nodes can be already reduced by other nodes, check if they are still there
14521440 if (getSignature (pair.first ) != 0 )
14531441 {
1454- reducedTo = reduceNodeImpl (pair.first , pair.second , keepLinkedInDb);
1442+ reducedTo = reduceNodeImpl (pair.first , pair.second , keepLinkedInDb, neighborMergedRatio );
14551443 }
14561444 }
14571445 }
0 commit comments