Tango: fixed localization mode not working

This commit is contained in:
matlabbe
2016-11-25 15:20:42 -05:00
parent 5b183d9105
commit e65db3cba5
3 changed files with 97 additions and 85 deletions
+1 -1
View File
@@ -2,7 +2,7 @@
<!-- BEGIN_INCLUDE(manifest) --> <!-- BEGIN_INCLUDE(manifest) -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.introlab.rtabmap" package="com.introlab.rtabmap"
android:versionCode="23" android:versionCode="24"
android:versionName="@RTABMAP_VERSION@"> android:versionName="@RTABMAP_VERSION@">
<uses-permission android:name="android.permission.CAMERA" /> <uses-permission android:name="android.permission.CAMERA" />
+1
View File
@@ -206,6 +206,7 @@ private:
void preUpdate(); void preUpdate();
void addSignatureToStm(Signature * signature, const cv::Mat & covariance); void addSignatureToStm(Signature * signature, const cv::Mat & covariance);
void clear(); void clear();
void loadDataFromDb(bool postInitClosingEvents);
void moveToTrash(Signature * s, bool keepLinkedToGraph = true, std::list<int> * deletedWords = 0); void moveToTrash(Signature * s, bool keepLinkedToGraph = true, std::list<int> * deletedWords = 0);
void moveSignatureToWMFromSTM(int id, int * reducedTo = 0); void moveSignatureToWMFromSTM(int id, int * reducedTo = 0);
+36 -25
View File
@@ -119,8 +119,6 @@ bool Memory::init(const std::string & dbUrl, bool dbOverwritten, const Parameter
UDEBUG(""); UDEBUG("");
this->parseParameters(parameters); this->parseParameters(parameters);
bool loadAllNodesInWM = Parameters::defaultMemInitWMWithAllNodes();
Parameters::parse(parameters, Parameters::kMemInitWMWithAllNodes(), loadAllNodesInWM);
if(postInitClosingEvents) UEventsManager::post(new RtabmapEventInit("Clearing memory...")); if(postInitClosingEvents) UEventsManager::post(new RtabmapEventInit("Clearing memory..."));
DBDriver * tmpDriver = 0; DBDriver * tmpDriver = 0;
@@ -166,6 +164,26 @@ bool Memory::init(const std::string & dbUrl, bool dbOverwritten, const Parameter
{ {
success = true; success = true;
if(postInitClosingEvents) UEventsManager::post(new RtabmapEventInit(std::string("Connecting to database \"") + dbUrl + "\", done!")); if(postInitClosingEvents) UEventsManager::post(new RtabmapEventInit(std::string("Connecting to database \"") + dbUrl + "\", done!"));
}
else
{
if(postInitClosingEvents) UEventsManager::post(new RtabmapEventInit(RtabmapEventInit::kError, std::string("Connecting to database ") + dbUrl + ", path is invalid!"));
}
}
loadDataFromDb(postInitClosingEvents);
if(postInitClosingEvents) UEventsManager::post(new RtabmapEventInit(RtabmapEventInit::kInitialized));
return success;
}
void Memory::loadDataFromDb(bool postInitClosingEvents)
{
if(_dbDriver && _dbDriver->isConnected())
{
bool loadAllNodesInWM = Parameters::defaultMemInitWMWithAllNodes();
Parameters::parse(parameters_, Parameters::kMemInitWMWithAllNodes(), loadAllNodesInWM);
// Load the last working memory... // Load the last working memory...
std::list<Signature*> dbSignatures; std::list<Signature*> dbSignatures;
@@ -216,27 +234,8 @@ bool Memory::init(const std::string & dbUrl, bool dbOverwritten, const Parameter
// Last id // Last id
_dbDriver->getLastNodeId(_idCount); _dbDriver->getLastNodeId(_idCount);
_idMapCount = _lastSignature?_lastSignature->mapId()+1:kIdStart; _idMapCount = _lastSignature?_lastSignature->mapId()+1:kIdStart;
}
else
{
if(postInitClosingEvents) UEventsManager::post(new RtabmapEventInit(RtabmapEventInit::kError, std::string("Connecting to database ") + dbUrl + ", path is invalid!"));
}
}
else
{
_idCount = kIdStart;
_idMapCount = kIdStart;
}
_workingMem.insert(std::make_pair(kIdVirtual, 0));
UDEBUG("ids start with %d", _idCount+1);
UDEBUG("map ids start with %d", _idMapCount);
// Now load the dictionary if we have a connection // Now load the dictionary if we have a connection
if(_dbDriver && _dbDriver->isConnected())
{
if(postInitClosingEvents) UEventsManager::post(new RtabmapEventInit("Loading dictionary...")); if(postInitClosingEvents) UEventsManager::post(new RtabmapEventInit("Loading dictionary..."));
if(loadAllNodesInWM) if(loadAllNodesInWM)
{ {
@@ -271,7 +270,6 @@ bool Memory::init(const std::string & dbUrl, bool dbOverwritten, const Parameter
UDEBUG("%d words loaded!", _vwd->getUnusedWordsSize()); UDEBUG("%d words loaded!", _vwd->getUnusedWordsSize());
_vwd->update(); _vwd->update();
if(postInitClosingEvents) UEventsManager::post(new RtabmapEventInit(uFormat("Loading dictionary, done! (%d words)", (int)_vwd->getUnusedWordsSize()))); if(postInitClosingEvents) UEventsManager::post(new RtabmapEventInit(uFormat("Loading dictionary, done! (%d words)", (int)_vwd->getUnusedWordsSize())));
}
if(postInitClosingEvents) UEventsManager::post(new RtabmapEventInit(std::string("Adding word references..."))); if(postInitClosingEvents) UEventsManager::post(new RtabmapEventInit(std::string("Adding word references...")));
// Enable loaded signatures // Enable loaded signatures
@@ -299,9 +297,17 @@ bool Memory::init(const std::string & dbUrl, bool dbOverwritten, const Parameter
UWARN("_vwd->getUnusedWordsSize() must be empty... size=%d", _vwd->getUnusedWordsSize()); UWARN("_vwd->getUnusedWordsSize() must be empty... size=%d", _vwd->getUnusedWordsSize());
} }
UDEBUG("Total word references added = %d", _vwd->getTotalActiveReferences()); UDEBUG("Total word references added = %d", _vwd->getTotalActiveReferences());
}
else
{
_idCount = kIdStart;
_idMapCount = kIdStart;
}
if(postInitClosingEvents) UEventsManager::post(new RtabmapEventInit(RtabmapEventInit::kInitialized)); _workingMem.insert(std::make_pair(kIdVirtual, 0));
return success;
UDEBUG("ids start with %d", _idCount+1);
UDEBUG("map ids start with %d", _idMapCount);
} }
void Memory::close(bool databaseSaved, bool postInitClosingEvents, const std::string & ouputDatabasePath) void Memory::close(bool databaseSaved, bool postInitClosingEvents, const std::string & ouputDatabasePath)
@@ -521,7 +527,12 @@ void Memory::parseParameters(const ParametersMap & parameters)
if((_memoryChanged || _linksChanged) && _dbDriver) if((_memoryChanged || _linksChanged) && _dbDriver)
{ {
UWARN("Switching from Mapping to Localization mode, the database will be saved and reloaded."); UWARN("Switching from Mapping to Localization mode, the database will be saved and reloaded.");
this->init(_dbDriver->getUrl()); bool memoryChanged = _memoryChanged;
bool linksChanged = _linksChanged;
this->clear();
_memoryChanged = memoryChanged;
_linksChanged = linksChanged;
this->loadDataFromDb(false);
UWARN("Switching from Mapping to Localization mode, the database is reloaded!"); UWARN("Switching from Mapping to Localization mode, the database is reloaded!");
} }
} }