mirror of
https://github.com/introlab/rtabmap.git
synced 2026-09-03 01:50:24 +08:00
Tango: fixed database saved in memory option when disabled (now disabled by default)
This commit is contained in:
@@ -187,6 +187,7 @@ void DBDriverSqlite3::setTempStore(int tempStore)
|
||||
|
||||
void DBDriverSqlite3::setDbInMemory(bool dbInMemory)
|
||||
{
|
||||
UDEBUG("dbInMemory=%d", dbInMemory?1:0);
|
||||
if(dbInMemory != _dbInMemory)
|
||||
{
|
||||
if(this->isConnected())
|
||||
|
||||
@@ -41,6 +41,7 @@ public:
|
||||
virtual ~DBDriverSqlite3();
|
||||
|
||||
virtual void parseParameters(const ParametersMap & parameters);
|
||||
virtual bool isInMemory() const {return getUrl().empty() || _dbInMemory;}
|
||||
void setDbInMemory(bool dbInMemory);
|
||||
void setJournalMode(int journalMode);
|
||||
void setCacheSize(unsigned int cacheSize);
|
||||
|
||||
@@ -439,7 +439,7 @@ void FlannIndex::knnSearch(
|
||||
indices.create(query.rows, knn, CV_32S);
|
||||
dists.create(query.rows, knn, featuresType_ == CV_8UC1?CV_32S:CV_32F);
|
||||
|
||||
rtflann::Matrix<int> indicesF((int*)indices.data, indices.rows, indices.cols);
|
||||
rtflann::Matrix<size_t> indicesF((size_t*)indices.data, indices.rows, indices.cols);
|
||||
|
||||
rtflann::SearchParams params = rtflann::SearchParams(checks, eps, sorted);
|
||||
|
||||
|
||||
@@ -316,6 +316,15 @@ void Memory::loadDataFromDb(bool postInitClosingEvents)
|
||||
UWARN("_vwd->getUnusedWordsSize() must be empty... size=%d", _vwd->getUnusedWordsSize());
|
||||
}
|
||||
UDEBUG("Total word references added = %d", _vwd->getTotalActiveReferences());
|
||||
|
||||
if(_lastSignature == 0)
|
||||
{
|
||||
// Memory is empty, save parameters
|
||||
ParametersMap parameters = Parameters::getDefaultParameters();
|
||||
uInsert(parameters, parameters_);
|
||||
UDEBUG("");
|
||||
_dbDriver->addInfoAfterRun(0, 0, 0, 0, 0, parameters);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1275,6 +1284,7 @@ int Memory::getDatabaseMemoryUsed() const
|
||||
{
|
||||
memoryUsed = _dbDriver->getMemoryUsed()/(1024*1024); //Byte to MB
|
||||
}
|
||||
|
||||
return memoryUsed;
|
||||
}
|
||||
|
||||
@@ -2124,6 +2134,25 @@ void Memory::deleteLocation(int locationId, std::list<int> * deletedWords)
|
||||
}
|
||||
}
|
||||
|
||||
void Memory::saveLocationData(int locationId)
|
||||
{
|
||||
UDEBUG("Saving location data %d", locationId);
|
||||
Signature * location = _getSignature(locationId);
|
||||
if( location &&
|
||||
_dbDriver &&
|
||||
!_dbDriver->isInMemory() && // don't push in database if it is also in memory.
|
||||
location->id()>0 &&
|
||||
(_incrementalMemory && !location->isSaved()))
|
||||
{
|
||||
Signature * cpy = new Signature();
|
||||
*cpy = *location;
|
||||
_dbDriver->asyncSave(cpy);
|
||||
|
||||
location->setSaved(true);
|
||||
location->sensorData().clearCompressedData();
|
||||
}
|
||||
}
|
||||
|
||||
void Memory::removeLink(int oldId, int newId)
|
||||
{
|
||||
//this method assumes receiving oldId < newId, if not switch them
|
||||
@@ -2370,7 +2399,7 @@ Transform Memory::computeIcpTransform(
|
||||
|
||||
if(depthsToLoad.size())
|
||||
{
|
||||
_dbDriver->loadNodeData(depthsToLoad);
|
||||
_dbDriver->loadNodeData(depthsToLoad, false, true, false, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2437,7 +2466,7 @@ Transform Memory::computeIcpTransformMulti(
|
||||
}
|
||||
if(depthToLoad.size() && _dbDriver)
|
||||
{
|
||||
_dbDriver->loadNodeData(depthToLoad);
|
||||
_dbDriver->loadNodeData(depthToLoad, false, true, false, false);
|
||||
}
|
||||
|
||||
Signature * fromS = _getSignature(fromId);
|
||||
|
||||
@@ -2505,6 +2505,10 @@ bool Rtabmap::process(
|
||||
signaturesRemoved.push_back(signature->id());
|
||||
_memory->deleteLocation(signature->id());
|
||||
}
|
||||
else
|
||||
{
|
||||
_memory->saveLocationData(signature->id());
|
||||
}
|
||||
}
|
||||
|
||||
// Pass this point signature should not be used, since it could have been transferred...
|
||||
|
||||
@@ -787,7 +787,10 @@ long SensorData::getMemoryUsed() const // Return memory usage in Bytes
|
||||
_groundCellsCompressed.total()*_groundCellsCompressed.elemSize() +
|
||||
_groundCellsRaw.total()*_groundCellsRaw.elemSize() +
|
||||
_obstacleCellsCompressed.total()*_obstacleCellsCompressed.elemSize() +
|
||||
_obstacleCellsRaw.total()*_obstacleCellsRaw.elemSize();
|
||||
_obstacleCellsRaw.total()*_obstacleCellsRaw.elemSize()+
|
||||
_keypoints.size() * sizeof(float) * 7 +
|
||||
_keypoints3D.size() * sizeof(float)*3 +
|
||||
_descriptors.total()*_descriptors.elemSize();
|
||||
}
|
||||
|
||||
} // namespace rtabmap
|
||||
|
||||
@@ -292,4 +292,20 @@ cv::Mat Signature::getPoseCovariance() const
|
||||
return covariance;
|
||||
}
|
||||
|
||||
long Signature::getMemoryUsed(bool withSensorData) const // Return memory usage in Bytes
|
||||
{
|
||||
long total = _words.size() * sizeof(float) * 8 +
|
||||
_words3.size() * sizeof(float) * 4;
|
||||
if(!_wordsDescriptors.empty())
|
||||
{
|
||||
total += _wordsDescriptors.size() * sizeof(int);
|
||||
total += _wordsDescriptors.size() * _wordsDescriptors.begin()->second.total() * _wordsDescriptors.begin()->second.elemSize();
|
||||
}
|
||||
if(withSensorData)
|
||||
{
|
||||
total+=_sensorData.getMemoryUsed();
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
} //namespace rtabmap
|
||||
|
||||
@@ -375,7 +375,7 @@ public:
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
int knnSearch(const Matrix<ElementType>& queries,
|
||||
/*int knnSearch(const Matrix<ElementType>& queries,
|
||||
Matrix<int>& indices,
|
||||
Matrix<DistanceType>& dists,
|
||||
size_t knn,
|
||||
@@ -391,7 +391,7 @@ public:
|
||||
}
|
||||
delete[] indices_.ptr();
|
||||
return result;
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user