fixed deleted nodes in localization to be not saved in database

This commit is contained in:
matlabbe
2015-07-15 17:43:08 -04:00
parent 2d7be6be48
commit 82ef6231c4

View File

@@ -336,7 +336,7 @@ bool Memory::init(const std::string & dbUrl, bool dbOverwritten, const Parameter
Memory::~Memory() Memory::~Memory()
{ {
if(_postInitClosingEvents) UEventsManager::post(new RtabmapEventInit(RtabmapEventInit::kClosing)); if(_postInitClosingEvents) UEventsManager::post(new RtabmapEventInit(RtabmapEventInit::kClosing));
UDEBUG("");
if(!_memoryChanged && !_linksChanged) if(!_memoryChanged && !_linksChanged)
{ {
if(_postInitClosingEvents) UEventsManager::post(new RtabmapEventInit(uFormat("No changes added to database."))); if(_postInitClosingEvents) UEventsManager::post(new RtabmapEventInit(uFormat("No changes added to database.")));
@@ -1776,7 +1776,8 @@ void Memory::moveToTrash(Signature * s, bool keepLinkedToGraph, std::list<int> *
if( (_notLinkedNodesKeptInDb || keepLinkedToGraph) && if( (_notLinkedNodesKeptInDb || keepLinkedToGraph) &&
_dbDriver && _dbDriver &&
s->id()>0) s->id()>0 &&
(_incrementalMemory || s->isSaved()))
{ {
_dbDriver->asyncSave(s); _dbDriver->asyncSave(s);
} }
@@ -2816,26 +2817,29 @@ bool Memory::addLink(const Link & link)
toS->addLink(Link(link.to(), link.from(), link.type(), link.transform().inverse(), link.infMatrix())); toS->addLink(Link(link.to(), link.from(), link.type(), link.transform().inverse(), link.infMatrix()));
fromS->addLink(link); fromS->addLink(link);
if(link.type()!=Link::kVirtualClosure) if(_incrementalMemory)
{ {
_linksChanged = true; if(link.type()!=Link::kVirtualClosure)
}
if(_incrementalMemory && link.type() == Link::kGlobalClosure)
{
_lastGlobalLoopClosureId = fromS->id()>toS->id()?fromS->id():toS->id();
// update weights only if the memory is incremental
UASSERT(fromS->getWeight() >= 0 && toS->getWeight() >=0);
if(fromS->id() > toS->id())
{ {
fromS->setWeight(fromS->getWeight() + toS->getWeight()); _linksChanged = true;
toS->setWeight(0);
} }
else
if(link.type() == Link::kGlobalClosure)
{ {
toS->setWeight(toS->getWeight() + fromS->getWeight()); _lastGlobalLoopClosureId = fromS->id()>toS->id()?fromS->id():toS->id();
fromS->setWeight(0);
// update weights only if the memory is incremental
UASSERT(fromS->getWeight() >= 0 && toS->getWeight() >=0);
if(fromS->id() > toS->id())
{
fromS->setWeight(fromS->getWeight() + toS->getWeight());
toS->setWeight(0);
}
else
{
toS->setWeight(toS->getWeight() + fromS->getWeight());
fromS->setWeight(0);
}
} }
} }
return true; return true;