mirror of
https://github.com/introlab/rtabmap.git
synced 2026-10-04 17:17:47 +08:00
Export CLI tool memory optimization (#1391)
* Stashing changes so far * Tested and working * removed unused options * Added density_radius and density_angle options * improved description * backward compatibility fixes, matching texture exported file names with base name * Setting global full opt by default, updated preferences defaulting to g2o or gtsam if one or the other is unavailable
This commit is contained in:
@@ -2483,6 +2483,75 @@ void DBDriverSqlite3::getAllNodeIdsQuery(std::set<int> & ids, bool ignoreChildre
|
||||
}
|
||||
}
|
||||
|
||||
void DBDriverSqlite3::getAllOdomPosesQuery(std::map<int, Transform> & poses, bool ignoreChildren, bool ignoreIntermediateNodes) const
|
||||
{
|
||||
if(_ppDb)
|
||||
{
|
||||
UTimer timer;
|
||||
timer.start();
|
||||
int rc = SQLITE_OK;
|
||||
sqlite3_stmt * ppStmt = 0;
|
||||
std::stringstream query;
|
||||
|
||||
query << "SELECT DISTINCT id, pose "
|
||||
<< "FROM Node ";
|
||||
if(ignoreChildren)
|
||||
{
|
||||
query << "INNER JOIN Link ";
|
||||
query << "ON id = to_id "; // use to_id to ignore all children (which don't have link pointing on them)
|
||||
query << "WHERE from_id != to_id "; // ignore self referring links
|
||||
query << "AND weight>-9 "; //ignore invalid nodes
|
||||
if(ignoreIntermediateNodes)
|
||||
{
|
||||
query << "AND weight!=-1 "; //ignore intermediate nodes
|
||||
}
|
||||
}
|
||||
else if(ignoreIntermediateNodes)
|
||||
{
|
||||
query << "WHERE weight!=-1 "; //ignore intermediate nodes
|
||||
}
|
||||
|
||||
query << "ORDER BY id";
|
||||
|
||||
rc = sqlite3_prepare_v2(_ppDb, query.str().c_str(), -1, &ppStmt, 0);
|
||||
UASSERT_MSG(rc == SQLITE_OK, uFormat("DB error (%s): %s", _version.c_str(), sqlite3_errmsg(_ppDb)).c_str());
|
||||
|
||||
const void * data = 0;
|
||||
int dataSize = 0;
|
||||
|
||||
// Process the result if one
|
||||
rc = sqlite3_step(ppStmt);
|
||||
while(rc == SQLITE_ROW)
|
||||
{
|
||||
int id = sqlite3_column_int(ppStmt, 0); // Signature Id
|
||||
data = sqlite3_column_blob(ppStmt, 1); // Pose
|
||||
dataSize = sqlite3_column_bytes(ppStmt, 1);
|
||||
|
||||
Transform pose;
|
||||
if((unsigned int)dataSize == pose.size()*sizeof(float) && data)
|
||||
{
|
||||
memcpy(pose.data(), data, dataSize);
|
||||
if(uStrNumCmp(_version, "0.15.2") < 0)
|
||||
{
|
||||
pose.normalizeRotation();
|
||||
}
|
||||
}
|
||||
else if(dataSize)
|
||||
{
|
||||
UERROR("Error while loading pose for node %d! Setting to null...", id);
|
||||
}
|
||||
poses.insert(std::make_pair(id, pose));
|
||||
rc = sqlite3_step(ppStmt);
|
||||
}
|
||||
UASSERT_MSG(rc == SQLITE_DONE, uFormat("DB error (%s): %s", _version.c_str(), sqlite3_errmsg(_ppDb)).c_str());
|
||||
|
||||
// Finalize (delete) the statement
|
||||
rc = sqlite3_finalize(ppStmt);
|
||||
UASSERT_MSG(rc == SQLITE_OK, uFormat("DB error (%s): %s", _version.c_str(), sqlite3_errmsg(_ppDb)).c_str());
|
||||
ULOGGER_DEBUG("Time=%f ids=%d", timer.ticks(), (int)poses.size());
|
||||
}
|
||||
}
|
||||
|
||||
void DBDriverSqlite3::getAllLinksQuery(std::multimap<int, Link> & links, bool ignoreNullLinks, bool withLandmarks) const
|
||||
{
|
||||
links.clear();
|
||||
|
||||
Reference in New Issue
Block a user