mirror of
https://github.com/introlab/rtabmap.git
synced 2026-09-01 17:10:26 +08:00
rtabmap: Added parameter to disable logs of the statistics
rtabmap: Added parameter to avoid saving to database nodes/words of rehearsed nodes git-svn-id: http://rtabmap.googlecode.com/svn/trunk/rtabmap@834 f169173b-cf89-36c8-b27e-44dbe73f0c83
This commit is contained in:
@@ -44,6 +44,7 @@ Memory::Memory(const ParametersMap & parameters) :
|
||||
_similarityThreshold(Parameters::defaultMemRehearsalSimilarity()),
|
||||
_rehearsalOnlyWithLast(Parameters::defaultMemRehearsalOnlyWithLast()),
|
||||
_rawDataKept(Parameters::defaultMemImageKept()),
|
||||
_keepRehearsedNodesInDb(Parameters::defaultMemRehearsedNodesKept()),
|
||||
_incrementalMemory(Parameters::defaultMemIncrementalMemory()),
|
||||
_maxStMemSize(Parameters::defaultMemSTMSize()),
|
||||
_recentWmRatio(Parameters::defaultMemRecentWmRatio()),
|
||||
@@ -251,6 +252,10 @@ void Memory::parseParameters(const ParametersMap & parameters)
|
||||
{
|
||||
_rawDataKept = uStr2Bool((*iter).second.c_str());
|
||||
}
|
||||
if((iter=parameters.find(Parameters::kMemRehearsedNodesKept())) != parameters.end())
|
||||
{
|
||||
_keepRehearsedNodesInDb = uStr2Bool((*iter).second.c_str());
|
||||
}
|
||||
if((iter=parameters.find(Parameters::kMemIncrementalMemory())) != parameters.end())
|
||||
{
|
||||
_incrementalMemory = uStr2Bool((*iter).second.c_str());
|
||||
@@ -1341,7 +1346,7 @@ void Memory::moveToTrash(Signature * s, bool saveToDatabase)
|
||||
UINFO("id=%d", s?s->id():0);
|
||||
if(s)
|
||||
{
|
||||
this->disableWordsRef(s->id());
|
||||
this->disableWordsRef(s->id(), saveToDatabase);
|
||||
|
||||
_workingMem.erase(s->id());
|
||||
_stMem.erase(s->id());
|
||||
@@ -1590,8 +1595,10 @@ bool Memory::addLoopClosureLink(int oldId, int newId)
|
||||
this->copyData(newS, oldS);
|
||||
}
|
||||
|
||||
bool saveToDb = !onRehearsal || _keepRehearsedNodesInDb;
|
||||
|
||||
// remove location
|
||||
moveToTrash(_idUpdatedToNewOneRehearsal?oldS:newS);
|
||||
moveToTrash(_idUpdatedToNewOneRehearsal?oldS:newS, saveToDb);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -2327,7 +2334,7 @@ Signature * Memory::createSignature(const Image & image, bool keepRawData)
|
||||
return ks;
|
||||
}
|
||||
|
||||
void Memory::disableWordsRef(int signatureId)
|
||||
void Memory::disableWordsRef(int signatureId, bool saveToDatabase)
|
||||
{
|
||||
ULOGGER_DEBUG("id=%d", signatureId);
|
||||
|
||||
@@ -2341,6 +2348,18 @@ void Memory::disableWordsRef(int signatureId)
|
||||
for(std::list<int>::const_iterator i=keys.begin(); i!=keys.end(); ++i)
|
||||
{
|
||||
_vwd->removeAllWordRef(*i, signatureId);
|
||||
if(!saveToDatabase)
|
||||
{
|
||||
// assume just removed word doesn't have any other references
|
||||
VisualWord * w = _vwd->getUnusedWord(*i);
|
||||
if(w)
|
||||
{
|
||||
std::vector<VisualWord*> wordToDelete;
|
||||
wordToDelete.push_back(w);
|
||||
_vwd->removeWords(wordToDelete);
|
||||
delete w;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
count -= _vwd->getTotalActiveReferences();
|
||||
|
||||
@@ -71,6 +71,7 @@ Rtabmap::Rtabmap() :
|
||||
_maxRetrieved(Parameters::defaultRtabmapMaxRetrieved()),
|
||||
_likelihoodNullValuesIgnored(Parameters::defaultRtabmapLikelihoodNullValuesIgnored()),
|
||||
_statisticLogsBufferedInRAM(Parameters::defaultRtabmapStatisticLogsBufferedInRAM()),
|
||||
_statisticLogged(Parameters::defaultRtabmapStatisticLogged()),
|
||||
_lcHypothesisId(0),
|
||||
_lcHypothesisValue(0),
|
||||
_retrievedId(0),
|
||||
@@ -109,74 +110,81 @@ void Rtabmap::setupLogFiles(bool overwrite)
|
||||
_foutInt = 0;
|
||||
}
|
||||
|
||||
std::string attributes = "a+"; // append to log files
|
||||
if(overwrite)
|
||||
if(_statisticLogged)
|
||||
{
|
||||
// If a file with the same name already exists
|
||||
// its content is erased and the file is treated
|
||||
// as a new empty file.
|
||||
attributes = "w";
|
||||
std::string attributes = "a+"; // append to log files
|
||||
if(overwrite)
|
||||
{
|
||||
// If a file with the same name already exists
|
||||
// its content is erased and the file is treated
|
||||
// as a new empty file.
|
||||
attributes = "w";
|
||||
}
|
||||
|
||||
bool addLogFHeader = overwrite || !UFile::exists(_wDir+LOG_F);
|
||||
bool addLogIHeader = overwrite || !UFile::exists(_wDir+LOG_I);
|
||||
|
||||
#ifdef _MSC_VER
|
||||
fopen_s(&_foutFloat, (_wDir+LOG_F).toStdString().c_str(), attributes.c_str());
|
||||
fopen_s(&_foutInt, (_wDir+LOG_I).toStdString().c_str(), attributes.c_str());
|
||||
#else
|
||||
_foutFloat = fopen((_wDir+LOG_F).c_str(), attributes.c_str());
|
||||
_foutInt = fopen((_wDir+LOG_I).c_str(), attributes.c_str());
|
||||
#endif
|
||||
// add header (column identification)
|
||||
if(addLogFHeader && _foutFloat)
|
||||
{
|
||||
fprintf(_foutFloat, "Column headers:\n");
|
||||
fprintf(_foutFloat, " 1-Total iteration time (s)\n");
|
||||
fprintf(_foutFloat, " 2-Memory update time (s)\n");
|
||||
fprintf(_foutFloat, " 3-Retrieval time (s)\n");
|
||||
fprintf(_foutFloat, " 4-Likelihood time (s)\n");
|
||||
fprintf(_foutFloat, " 5-Posterior time (s)\n");
|
||||
fprintf(_foutFloat, " 6-Hypothesis selection time (s)\n");
|
||||
fprintf(_foutFloat, " 7-Transfer time (s)\n");
|
||||
fprintf(_foutFloat, " 8-Statistics creation time (s)\n");
|
||||
fprintf(_foutFloat, " 9-Loop closure hypothesis value\n");
|
||||
fprintf(_foutFloat, " 10-NAN\n");
|
||||
fprintf(_foutFloat, " 11-Maximum likelihood\n");
|
||||
fprintf(_foutFloat, " 12-Sum likelihood\n");
|
||||
fprintf(_foutFloat, " 13-Mean likelihood\n");
|
||||
fprintf(_foutFloat, " 14-Std dev likelihood\n");
|
||||
fprintf(_foutFloat, " 15-Virtual place hypothesis\n");
|
||||
fprintf(_foutFloat, " 16-Join trash time (s)\n");
|
||||
fprintf(_foutFloat, " 17-Weight Update (rehearsal) similarity\n");
|
||||
fprintf(_foutFloat, " 18-Empty trash time (s)\n");
|
||||
fprintf(_foutFloat, " 19-Retrieval database access time (s)\n");
|
||||
fprintf(_foutFloat, " 20-Add loop closure link time (s)\n");
|
||||
}
|
||||
if(addLogIHeader && _foutInt)
|
||||
{
|
||||
fprintf(_foutInt, "Column headers:\n");
|
||||
fprintf(_foutInt, " 1-Loop closure ID\n");
|
||||
fprintf(_foutInt, " 2-Highest loop closure hypothesis\n");
|
||||
fprintf(_foutInt, " 3-Locations transferred\n");
|
||||
fprintf(_foutInt, " 4-NAN\n");
|
||||
fprintf(_foutInt, " 5-Words extracted from the last image\n");
|
||||
fprintf(_foutInt, " 6-Vocabulary size\n");
|
||||
fprintf(_foutInt, " 7-Working memory size\n");
|
||||
fprintf(_foutInt, " 8-Is loop closure hypothesis rejected?\n");
|
||||
fprintf(_foutInt, " 9-NAN\n");
|
||||
fprintf(_foutInt, " 10-NAN\n");
|
||||
fprintf(_foutInt, " 11-Locations retrieved\n");
|
||||
fprintf(_foutInt, " 12-Retrieval location ID\n");
|
||||
fprintf(_foutInt, " 13-Unique words extraced from last image\n");
|
||||
fprintf(_foutInt, " 14-Retrieval ID\n");
|
||||
fprintf(_foutInt, " 15-Non-null likelihood values\n");
|
||||
fprintf(_foutInt, " 16-Weight Update ID\n");
|
||||
fprintf(_foutInt, " 17-Is last location merged through Weight Update?\n");
|
||||
}
|
||||
|
||||
ULOGGER_DEBUG("Log file (int)=%s", (_wDir+LOG_I).c_str());
|
||||
ULOGGER_DEBUG("Log file (float)=%s", (_wDir+LOG_F).c_str());
|
||||
}
|
||||
|
||||
bool addLogFHeader = overwrite || !UFile::exists(_wDir+LOG_F);
|
||||
bool addLogIHeader = overwrite || !UFile::exists(_wDir+LOG_I);
|
||||
|
||||
#ifdef _MSC_VER
|
||||
fopen_s(&_foutFloat, (_wDir+LOG_F).toStdString().c_str(), attributes.c_str());
|
||||
fopen_s(&_foutInt, (_wDir+LOG_I).toStdString().c_str(), attributes.c_str());
|
||||
#else
|
||||
_foutFloat = fopen((_wDir+LOG_F).c_str(), attributes.c_str());
|
||||
_foutInt = fopen((_wDir+LOG_I).c_str(), attributes.c_str());
|
||||
#endif
|
||||
// add header (column identification)
|
||||
if(addLogFHeader && _foutFloat)
|
||||
else
|
||||
{
|
||||
fprintf(_foutFloat, "Column headers:\n");
|
||||
fprintf(_foutFloat, " 1-Total iteration time (s)\n");
|
||||
fprintf(_foutFloat, " 2-Memory update time (s)\n");
|
||||
fprintf(_foutFloat, " 3-Retrieval time (s)\n");
|
||||
fprintf(_foutFloat, " 4-Likelihood time (s)\n");
|
||||
fprintf(_foutFloat, " 5-Posterior time (s)\n");
|
||||
fprintf(_foutFloat, " 6-Hypothesis selection time (s)\n");
|
||||
fprintf(_foutFloat, " 7-Transfer time (s)\n");
|
||||
fprintf(_foutFloat, " 8-Statistics creation time (s)\n");
|
||||
fprintf(_foutFloat, " 9-Loop closure hypothesis value\n");
|
||||
fprintf(_foutFloat, " 10-NAN\n");
|
||||
fprintf(_foutFloat, " 11-Maximum likelihood\n");
|
||||
fprintf(_foutFloat, " 12-Sum likelihood\n");
|
||||
fprintf(_foutFloat, " 13-Mean likelihood\n");
|
||||
fprintf(_foutFloat, " 14-Std dev likelihood\n");
|
||||
fprintf(_foutFloat, " 15-Virtual place hypothesis\n");
|
||||
fprintf(_foutFloat, " 16-Join trash time (s)\n");
|
||||
fprintf(_foutFloat, " 17-Weight Update (rehearsal) similarity\n");
|
||||
fprintf(_foutFloat, " 18-Empty trash time (s)\n");
|
||||
fprintf(_foutFloat, " 19-Retrieval database access time (s)\n");
|
||||
fprintf(_foutFloat, " 20-Add loop closure link time (s)\n");
|
||||
UDEBUG("Log disabled!");
|
||||
}
|
||||
if(addLogIHeader && _foutInt)
|
||||
{
|
||||
fprintf(_foutInt, "Column headers:\n");
|
||||
fprintf(_foutInt, " 1-Loop closure ID\n");
|
||||
fprintf(_foutInt, " 2-Highest loop closure hypothesis\n");
|
||||
fprintf(_foutInt, " 3-Locations transferred\n");
|
||||
fprintf(_foutInt, " 4-NAN\n");
|
||||
fprintf(_foutInt, " 5-Words extracted from the last image\n");
|
||||
fprintf(_foutInt, " 6-Vocabulary size\n");
|
||||
fprintf(_foutInt, " 7-Working memory size\n");
|
||||
fprintf(_foutInt, " 8-Is loop closure hypothesis rejected?\n");
|
||||
fprintf(_foutInt, " 9-NAN\n");
|
||||
fprintf(_foutInt, " 10-NAN\n");
|
||||
fprintf(_foutInt, " 11-Locations retrieved\n");
|
||||
fprintf(_foutInt, " 12-Retrieval location ID\n");
|
||||
fprintf(_foutInt, " 13-Unique words extraced from last image\n");
|
||||
fprintf(_foutInt, " 14-Retrieval ID\n");
|
||||
fprintf(_foutInt, " 15-Non-null likelihood values\n");
|
||||
fprintf(_foutInt, " 16-Weight Update ID\n");
|
||||
fprintf(_foutInt, " 17-Is last location merged through Weight Update?\n");
|
||||
}
|
||||
|
||||
ULOGGER_DEBUG("Log file (int)=%s", (_wDir+LOG_I).c_str());
|
||||
ULOGGER_DEBUG("Log file (float)=%s", (_wDir+LOG_F).c_str());
|
||||
}
|
||||
|
||||
void Rtabmap::flushStatisticLogs()
|
||||
@@ -211,6 +219,10 @@ void Rtabmap::init(const ParametersMap & parameters, bool deleteMemory)
|
||||
{
|
||||
this->setWorkingDirectory(iter->second.c_str());
|
||||
}
|
||||
if((iter=parameters.find(Parameters::kRtabmapStatisticLogged())) != parameters.end())
|
||||
{
|
||||
_statisticLogged = uStr2Bool(iter->second.c_str());
|
||||
}
|
||||
this->resetMemory(true);
|
||||
}
|
||||
|
||||
@@ -320,6 +332,10 @@ void Rtabmap::parseParameters(const ParametersMap & parameters)
|
||||
{
|
||||
_statisticLogsBufferedInRAM = uStr2Bool(iter->second.c_str());
|
||||
}
|
||||
if((iter=parameters.find(Parameters::kRtabmapStatisticLogged())) != parameters.end())
|
||||
{
|
||||
_statisticLogged = uStr2Bool(iter->second.c_str());
|
||||
}
|
||||
|
||||
// By default, we create our strategies if they are not already created.
|
||||
// If they already exists, we check the parameters if a change is requested
|
||||
|
||||
@@ -1012,7 +1012,7 @@ const VisualWord * VWDictionary::getWord(int id) const
|
||||
return uValue(_visualWords, id, (VisualWord *)0);
|
||||
}
|
||||
|
||||
const VisualWord * VWDictionary::getUnusedWord(int id) const
|
||||
VisualWord * VWDictionary::getUnusedWord(int id) const
|
||||
{
|
||||
return uValue(_unusedWords, id, (VisualWord *)0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user