mirror of
https://github.com/introlab/rtabmap.git
synced 2026-10-13 05:19:51 +08:00
Fixed nodes weight not modified in db when deleted
This commit is contained in:
@@ -280,7 +280,6 @@ private:
|
|||||||
std::list<Signature *> getRemovableSignatures(int count,
|
std::list<Signature *> getRemovableSignatures(int count,
|
||||||
const std::set<int> & ignoredIds = std::set<int>());
|
const std::set<int> & ignoredIds = std::set<int>());
|
||||||
int getNextId();
|
int getNextId();
|
||||||
void initCountId();
|
|
||||||
void rehearsal(Signature * signature, Statistics * stats = 0);
|
void rehearsal(Signature * signature, Statistics * stats = 0);
|
||||||
bool rehearsalMerge(int oldId, int newId);
|
bool rehearsalMerge(int oldId, int newId);
|
||||||
bool canBeReduced(const Link & link, float maxDistance, int direction);
|
bool canBeReduced(const Link & link, float maxDistance, int direction);
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ public:
|
|||||||
virtual ~Signature();
|
virtual ~Signature();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Must return a value between >=0 and <=1 (1 means 100% similarity).
|
* Must return a value between >=0 and <=1 (1 means 100% similarity).
|
||||||
*/
|
*/
|
||||||
float compareTo(const Signature & signature) const;
|
float compareTo(const Signature & signature) const;
|
||||||
bool isBadSignature() const;
|
bool isBadSignature() const;
|
||||||
@@ -70,10 +70,10 @@ public:
|
|||||||
int id() const {return _id;}
|
int id() const {return _id;}
|
||||||
int mapId() const {return _mapId;}
|
int mapId() const {return _mapId;}
|
||||||
|
|
||||||
void setWeight(int weight) {_modified=_weight!=weight;_weight = weight;}
|
void setWeight(int weight) {_modified=_modified || _weight!=weight;_weight = weight;}
|
||||||
int getWeight() const {return _weight;}
|
int getWeight() const {return _weight;}
|
||||||
|
|
||||||
void setLabel(const std::string & label) {_modified=_label.compare(label)!=0;_label = label;}
|
void setLabel(const std::string & label) {_modified=_modified || _label.compare(label)!=0;_label = label;}
|
||||||
const std::string & getLabel() const {return _label;}
|
const std::string & getLabel() const {return _label;}
|
||||||
|
|
||||||
double getStamp() const {return _stamp;}
|
double getStamp() const {return _stamp;}
|
||||||
|
|||||||
@@ -139,7 +139,6 @@ private:
|
|||||||
bool _incrementalFlann;
|
bool _incrementalFlann;
|
||||||
float _rebalancingFactor;
|
float _rebalancingFactor;
|
||||||
bool _byteToFloat;
|
bool _byteToFloat;
|
||||||
bool _autoUpdate;
|
|
||||||
float _nndrRatio;
|
float _nndrRatio;
|
||||||
std::string _dictionaryPath; // a pre-computed dictionary (.txt or .db)
|
std::string _dictionaryPath; // a pre-computed dictionary (.txt or .db)
|
||||||
std::string _newDictionaryPath; // a pre-computed dictionary (.txt or .db)
|
std::string _newDictionaryPath; // a pre-computed dictionary (.txt or .db)
|
||||||
@@ -151,6 +150,7 @@ private:
|
|||||||
cv::Mat _dataTree;
|
cv::Mat _dataTree;
|
||||||
bool _modified;
|
bool _modified;
|
||||||
NNStrategy _strategy;
|
NNStrategy _strategy;
|
||||||
|
bool _autoUpdate;
|
||||||
std::map<int ,int> _mapIndexId;
|
std::map<int ,int> _mapIndexId;
|
||||||
std::map<int ,int> _mapIdIndex;
|
std::map<int ,int> _mapIdIndex;
|
||||||
std::map<int, VisualWord*> _unusedWords; //<id,VisualWord*>, note that these words stay in _visualWords
|
std::map<int, VisualWord*> _unusedWords; //<id,VisualWord*>, note that these words stay in _visualWords
|
||||||
|
|||||||
@@ -443,11 +443,16 @@ void Memory::loadDataFromDb(bool postInitClosingEvents)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if(_dummyDictionary)
|
||||||
|
{
|
||||||
|
UWARN("A dummy dictionary is requested but %s is false, loading the dictionary as usual.", Parameters::kMemInitWMWithAllNodes().c_str());
|
||||||
|
}
|
||||||
UDEBUG("load words");
|
UDEBUG("load words");
|
||||||
// load the last dictionary
|
// load the last dictionary
|
||||||
_dbDriver->load(*_vwd, _vwd->isIncremental());
|
_dbDriver->load(*_vwd, _vwd->isIncremental());
|
||||||
}
|
}
|
||||||
UDEBUG("%d words loaded!", _vwd->getUnusedWordsSize());
|
UDEBUG("%d words loaded!", _vwd->getUnusedWordsSize());
|
||||||
|
UDEBUG("Dictionary memory usage: %ld Bytes", _vwd->getMemoryUsed());
|
||||||
if(_vwd->isAutoUpdateEnabled()) {
|
if(_vwd->isAutoUpdateEnabled()) {
|
||||||
_vwd->update();
|
_vwd->update();
|
||||||
}
|
}
|
||||||
@@ -3180,6 +3185,10 @@ void Memory::deleteLocation(int locationId, std::list<int> * deletedWords, bool
|
|||||||
this->moveToTrash(location, keepLinkedInDb, deletedWords);
|
this->moveToTrash(location, keepLinkedInDb, deletedWords);
|
||||||
_memoryChanged = true;
|
_memoryChanged = true;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
UWARN("Location %d has not been found in STM/WM, cannot delete it.", locationId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Memory::saveLocationData(int locationId)
|
void Memory::saveLocationData(int locationId)
|
||||||
|
|||||||
@@ -321,6 +321,8 @@ int main(int argc, char * argv[])
|
|||||||
memory.close(false);
|
memory.close(false);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
memory.emptyTrash();
|
||||||
|
memory.joinTrashThread();
|
||||||
|
|
||||||
if(isWholeGraphConnected || removeAllOrphanNodes)
|
if(isWholeGraphConnected || removeAllOrphanNodes)
|
||||||
{
|
{
|
||||||
@@ -354,6 +356,7 @@ int main(int argc, char * argv[])
|
|||||||
totalBefore, ids.size(), posesOut.size());
|
totalBefore, ids.size(), posesOut.size());
|
||||||
// Not all graph is connected anymore while it was before reduction:
|
// Not all graph is connected anymore while it was before reduction:
|
||||||
// that means we created orphan nodes, remove them
|
// that means we created orphan nodes, remove them
|
||||||
|
int transferred = 0;
|
||||||
for(std::map<int, Transform>::iterator iter=poses.lower_bound(0); iter!=poses.end(); ++iter)
|
for(std::map<int, Transform>::iterator iter=poses.lower_bound(0); iter!=poses.end(); ++iter)
|
||||||
{
|
{
|
||||||
if(posesOut.find(iter->first) == posesOut.end())
|
if(posesOut.find(iter->first) == posesOut.end())
|
||||||
@@ -366,8 +369,13 @@ int main(int argc, char * argv[])
|
|||||||
printf("Removed %d from WM/LTM.\n", iter->first);
|
printf("Removed %d from WM/LTM.\n", iter->first);
|
||||||
}
|
}
|
||||||
wm.erase(iter->first);
|
wm.erase(iter->first);
|
||||||
|
++transferred;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(transferred>0) {
|
||||||
|
memory.emptyTrash();
|
||||||
|
memory.joinTrashThread();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
printf("[Warning] After graph reduction, the global graph is not all "
|
printf("[Warning] After graph reduction, the global graph is not all "
|
||||||
@@ -454,11 +462,15 @@ int main(int argc, char * argv[])
|
|||||||
int transferred = 0;
|
int transferred = 0;
|
||||||
for(auto id:ids)
|
for(auto id:ids)
|
||||||
{
|
{
|
||||||
if(wm.find(id) == wm.end()) {
|
if(wm.find(id) == wm.end() && memory.getWorkingMem().find(id) != memory.getWorkingMem().end()) {
|
||||||
memory.deleteLocation(id, 0, /*keepLinkedInDb*/ true);
|
memory.deleteLocation(id, 0, /*keepLinkedInDb*/ true);
|
||||||
++transferred;
|
++transferred;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(transferred>0) {
|
||||||
|
memory.emptyTrash();
|
||||||
|
memory.joinTrashThread();
|
||||||
|
}
|
||||||
printf("Restoring Working Memory... done! Transferred %d nodes.\n", transferred);
|
printf("Restoring Working Memory... done! Transferred %d nodes.\n", transferred);
|
||||||
|
|
||||||
printf("Saving all changes to database...\n");
|
printf("Saving all changes to database...\n");
|
||||||
|
|||||||
Reference in New Issue
Block a user