Go to the documentation of this file.
40 const std::string & corruptedDatabase,
41 bool keepCorruptedDatabase,
42 std::string * errorMsg,
45 UDEBUG(
"Recovering \"%s\"", corruptedDatabase.c_str());
51 *errorMsg =
uFormat(
"File \"%s\" doesn't exist!", databasePath.c_str());
58 *errorMsg =
uFormat(
"File \"%s\" is not a database (*.db)!", databasePath.c_str());
61 std::list<std::string> strList =
uSplit(databasePath,
'.');
64 std::string recoveryPath;
65 recoveryPath =
uJoin(strList,
".") +
".recovery.db";
71 *errorMsg =
uFormat(
"Failed to remove temporary recovery database \"%s\", is it opened by another app?", recoveryPath.c_str());
80 *errorMsg =
uFormat(
"Failed opening database!");
86 if(parameters.empty())
89 *errorMsg =
uFormat(
"Failed getting parameters from database, recovery cannot be done.");
99 *errorMsg =
uFormat(
"Input database doesn't have any nodes saved in it.");
105 progressState->
callback(
uFormat(
"Found %d nodes to recover.", (
int)ids.size()));
108 std::multimap<int, Link> links;
110 bool corrupted =
false;
111 for(std::multimap<int, Link>::iterator
iter=links.begin();
iter!=links.end(); ++
iter)
124 progressState->
callback(
"Database is indeed corrupted, found one or more neighbor links missing.");
126 progressState->
callback(
"Database doesn't seem to be corrupted, still recovering it.");
132 bool incrementalMemory =
true;
133 bool dbInMemory =
false;
134 Parameters::parse(parameters, Parameters::kMemIncrementalMemory(), incrementalMemory);
136 if(!incrementalMemory)
140 progressState->
callback(
"Database is in localization mode, setting it to mapping mode to recover.");
148 progressState->
callback(
uFormat(
"Database has %s=true, setting it to false to avoid RAM problems during recovery.", Parameters::kDbSqlite3InMemory().
c_str()));
154 rtabmap.init(parameters, recoveryPath);
156 bool rgbdEnabled = Parameters::defaultRGBDEnabled();
158 bool odometryIgnored = !rgbdEnabled;
160 DBReader dbReader(databasePath, 0, odometryIgnored);
167 progressState->
callback(
uFormat(
"Recovering data of \"%s\"...", databasePath.c_str()));
168 while (
data.isValid() && (progressState == 0 || !progressState->
isCanceled()))
171 if (!odometryIgnored &&
info.odomPose.isNull())
173 status =
uFormat(
"Skipping node %d as it doesn't have odometry pose set.",
data.id());
177 if (!odometryIgnored && !
info.odomCovariance.empty() &&
info.odomCovariance.at<
double>(0, 0) >= 9999)
179 status =
uFormat(
"High variance detected, triggering a new map...");
184 status =
uFormat(
"Failed processing node %d.",
data.id());
196 progressState->
callback(
uFormat(
"Processed %d/%d nodes...", ++processed, (
int)ids.size()));
206 *errorMsg =
uFormat(
"Recovery canceled, removing temporary recovery database \"%s\".", recoveryPath.c_str());
214 progressState->
callback(
uFormat(
"Closing database \"%s\"...", recoveryPath.c_str()));
217 progressState->
callback(
uFormat(
"Closing database \"%s\"... done!", recoveryPath.c_str()));
219 if(keepCorruptedDatabase)
221 std::string backupPath;
222 backupPath =
uJoin(strList,
".") +
".backup.db";
246 *errorMsg =
uFormat(
"Failed remove original database file \"%s\". Is it opened by another app? The recovered database cannot be copied back to original name.",
UFile::getName(databasePath).
c_str(),
UFile::getName(recoveryPath).
c_str());
static int rename(const std::string &oldFilePath, const std::string &newFilePath)
std::pair< std::string, std::string > ParametersPair
ParametersMap getLastParameters() const
static int erase(const std::string &filePath)
bool openConnection(const std::string &url, bool overwritten=false)
std::string uJoin(const std::list< std::string > &strings, const std::string &separator="")
virtual bool callback(const std::string &msg) const
std::map< std::string, std::string > ParametersMap
static bool parse(const ParametersMap ¶meters, const std::string &key, bool &value)
static std::string homeDir()
void uInsert(std::map< K, V > &map, const std::pair< K, V > &pair)
virtual bool init(const std::string &calibrationFolder=".", const std::string &cameraName="")
std::string getExtension()
std::multimap< int, Link >::iterator RTABMAP_CORE_EXPORT findLink(std::multimap< int, Link > &links, int from, int to, bool checkBothWays=true, Link::Type type=Link::kUndef)
std::string UTILITE_EXPORT uFormat(const char *fmt,...)
std::string UTILITE_EXPORT uReplaceChar(const std::string &str, char before, char after)
std::list< std::string > uSplit(const std::string &str, char separator=' ')
iterator iter(handle obj)
const char * c_str(Args &&...args)
Wrappers of STL for convenient functions.
void getAllNodeIds(std::set< int > &ids, bool ignoreChildren=false, bool ignoreBadSignatures=false, bool ignoreIntermediateNodes=false) const
SensorData takeImage(SensorCaptureInfo *info=0)
bool RTABMAP_CORE_EXPORT databaseRecovery(const std::string &corruptedDatabase, bool keepCorruptedDatabase=true, std::string *errorMsg=0, ProgressState *progressState=0)
void getAllLinks(std::multimap< int, Link > &links, bool ignoreNullLinks=true, bool withLandmarks=false) const
void closeConnection(bool save=true, const std::string &outputUrl="")
static DBDriver * create(const ParametersMap ¶meters=ParametersMap())
rtabmap
Author(s): Mathieu Labbe
autogenerated on Thu Jul 25 2024 02:50:15