mirror of
https://github.com/introlab/rtabmap.git
synced 2026-09-12 06:20:19 +08:00
Detect more loop closures from/to specific map ID only option (#1653)
* Detect more loop closures from/to specific map ID only option * default value -1 * Added elapsed time * Avoid loading ALL signatures in RAM, only load them when necessary * Avoid creating flann index when initializing with Kp/NNStrategy>=3 * Setting opt params by default
This commit is contained in:
@@ -58,6 +58,7 @@ void showUsage()
|
||||
" -i # Iterations (default 1).\n"
|
||||
" --intra Add only intra-session loop closures.\n"
|
||||
" --inter Add only inter-session loop closures.\n"
|
||||
" --session # Add loop closures only from/to that map session ID (use -1 for last session).\n"
|
||||
"\n%s", Parameters::showUsage());
|
||||
exit(1);
|
||||
}
|
||||
@@ -73,12 +74,17 @@ void sighandler(int sig)
|
||||
class PrintProgressState : public ProgressState
|
||||
{
|
||||
public:
|
||||
PrintProgressState() :
|
||||
stamp_(UTimer::now())
|
||||
{}
|
||||
virtual bool callback(const std::string & msg) const
|
||||
{
|
||||
if(!msg.empty())
|
||||
printf("%s \n", msg.c_str());
|
||||
printf("[%f] %s \n", UTimer::now()-stamp_, msg.c_str());
|
||||
return g_loopForever;
|
||||
}
|
||||
private:
|
||||
double stamp_;
|
||||
};
|
||||
|
||||
int main(int argc, char * argv[])
|
||||
@@ -101,6 +107,7 @@ int main(int argc, char * argv[])
|
||||
int iterations = 1;
|
||||
bool intraSession = false;
|
||||
bool interSession = false;
|
||||
int fromToMapId = -2;
|
||||
for(int i=1; i<argc-1; ++i)
|
||||
{
|
||||
if(std::strcmp(argv[i], "--help") == 0)
|
||||
@@ -171,9 +178,25 @@ int main(int argc, char * argv[])
|
||||
showUsage();
|
||||
}
|
||||
}
|
||||
else if(std::strcmp(argv[i], "--session") == 0)
|
||||
{
|
||||
++i;
|
||||
if(i<argc-1)
|
||||
{
|
||||
fromToMapId = uStr2Int(argv[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
showUsage();
|
||||
}
|
||||
}
|
||||
}
|
||||
ParametersMap inputParams = Parameters::parseArguments(argc, argv);
|
||||
|
||||
// Add some optimizations (soft set, can be overriden by arguments)
|
||||
inputParams.insert(ParametersPair(Parameters::kMemLoadVisualLocalFeaturesOnInit(), "false")); // don't need features already loaded in RAM
|
||||
inputParams.insert(ParametersPair(Parameters::kKpNNStrategy(), "3")); // don't need flann index
|
||||
|
||||
std::string dbPath = argv[argc-1];
|
||||
if(!UFile::exists(dbPath))
|
||||
{
|
||||
@@ -221,15 +244,32 @@ int main(int argc, char * argv[])
|
||||
// Get the global optimized map
|
||||
Rtabmap rtabmap;
|
||||
printf("Initialization...\n");
|
||||
UTimer timer;
|
||||
uInsert(parameters, inputParams);
|
||||
rtabmap.init(parameters, dbPath);
|
||||
printf("Initialization... done! (%f sec)\n", timer.ticks());
|
||||
|
||||
float xMin, yMin, cellSize;
|
||||
bool haveOptimizedMap = !rtabmap.getMemory()->load2DMap(xMin, yMin, cellSize).empty();
|
||||
|
||||
if(fromToMapId <= -2)
|
||||
{
|
||||
fromToMapId = -1; // means all below
|
||||
}
|
||||
else
|
||||
{
|
||||
bool last = false;
|
||||
if(fromToMapId == -1)
|
||||
{
|
||||
// get last session ID
|
||||
fromToMapId = rtabmap.getMemory()->getMapId(rtabmap.getMemory()->getLastSignatureId(), true);
|
||||
}
|
||||
printf("From/To Session ID = %d%s\n", fromToMapId, last?" (last session)":"");
|
||||
}
|
||||
|
||||
PrintProgressState progress;
|
||||
printf("Detecting...\n");
|
||||
int detected = rtabmap.detectMoreLoopClosures(clusterRadiusMax, clusterAngle, iterations, intraSession, interSession, &progress, clusterRadiusMin);
|
||||
int detected = rtabmap.detectMoreLoopClosures(clusterRadiusMax, clusterAngle, iterations, intraSession, interSession, &progress, clusterRadiusMin, fromToMapId);
|
||||
if(detected < 0)
|
||||
{
|
||||
if(!g_loopForever)
|
||||
|
||||
Reference in New Issue
Block a user