mirror of
https://github.com/introlab/rtabmap_ros.git
synced 2026-10-03 16:27:46 +08:00
rtabmap: setup working directory and deleting memory is done in init() instead of the Rtabmap constructor.
git-svn-id: http://rtabmap.googlecode.com/svn/trunk/rtabmap@731 f169173b-cf89-36c8-b27e-44dbe73f0c83
This commit is contained in:
+1
-1
@@ -45,7 +45,7 @@ int main(int argc, char* argv[])
|
|||||||
/* Start thread's task */
|
/* Start thread's task */
|
||||||
mainWindow->showNormal();
|
mainWindow->showNormal();
|
||||||
|
|
||||||
Rtabmap * rtabmap = new Rtabmap(mainWindow->getWorkingDirectory().toStdString(), false);
|
Rtabmap * rtabmap = new Rtabmap();
|
||||||
rtabmap->start(); // start it not initialized... will be initialized by event from the gui
|
rtabmap->start(); // start it not initialized... will be initialized by event from the gui
|
||||||
UEventsManager::addHandler(rtabmap);
|
UEventsManager::addHandler(rtabmap);
|
||||||
|
|
||||||
|
|||||||
@@ -66,18 +66,18 @@ public:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
static std::string getVersion();
|
static std::string getVersion();
|
||||||
static void readParameters(const char * configFile, ParametersMap & parameters);
|
static void readParameters(const std::string & configFile, ParametersMap & parameters);
|
||||||
static void writeParameters(const char * configFile, const ParametersMap & parameters);
|
static void writeParameters(const std::string & configFile, const ParametersMap & parameters);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Rtabmap(const std::string & workingDirectory = ".", bool deleteMemory = true);
|
Rtabmap();
|
||||||
virtual ~Rtabmap();
|
virtual ~Rtabmap();
|
||||||
|
|
||||||
void process(const cv::Mat & image); // for convenience
|
void process(const cv::Mat & image); // for convenience
|
||||||
void process(const Image & image); // for convenience
|
void process(const Image & image); // for convenience
|
||||||
|
|
||||||
void init(const ParametersMap & param);
|
void init(const ParametersMap & param, bool deleteMemory = true);
|
||||||
void init(const char * configFile = 0);
|
void init(const std::string & configFile = "", bool deleteMemory = true);
|
||||||
void clearBufferedSensors();
|
void clearBufferedSensors();
|
||||||
|
|
||||||
void close();
|
void close();
|
||||||
|
|||||||
+21
-17
@@ -56,7 +56,7 @@ namespace rtabmap
|
|||||||
{
|
{
|
||||||
const char * Rtabmap::kDefaultDatabaseName = "LTM.db";
|
const char * Rtabmap::kDefaultDatabaseName = "LTM.db";
|
||||||
|
|
||||||
Rtabmap::Rtabmap(const std::string & workingDirectory, bool deleteMemory) :
|
Rtabmap::Rtabmap() :
|
||||||
_publishStats(Parameters::defaultRtabmapPublishStats()),
|
_publishStats(Parameters::defaultRtabmapPublishStats()),
|
||||||
_publishImage(Parameters::defaultRtabmapPublishImage()),
|
_publishImage(Parameters::defaultRtabmapPublishImage()),
|
||||||
_publishPdf(Parameters::defaultRtabmapPublishPdf()),
|
_publishPdf(Parameters::defaultRtabmapPublishPdf()),
|
||||||
@@ -81,11 +81,6 @@ Rtabmap::Rtabmap(const std::string & workingDirectory, bool deleteMemory) :
|
|||||||
_foutFloat(0),
|
_foutFloat(0),
|
||||||
_foutInt(0)
|
_foutInt(0)
|
||||||
{
|
{
|
||||||
this->setWorkingDirectory(workingDirectory);
|
|
||||||
if(deleteMemory)
|
|
||||||
{
|
|
||||||
this->resetMemory(true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Rtabmap::~Rtabmap() {
|
Rtabmap::~Rtabmap() {
|
||||||
@@ -258,31 +253,40 @@ void Rtabmap::pushNewState(State newState, const ParametersMap & parameters)
|
|||||||
_imageAdded.release();
|
_imageAdded.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Rtabmap::init(const ParametersMap & parameters)
|
void Rtabmap::init(const ParametersMap & parameters, bool deleteMemory)
|
||||||
{
|
{
|
||||||
if(this->isRunning())
|
if(this->isRunning())
|
||||||
{
|
{
|
||||||
pushNewState(kStateChangingParameters, parameters);
|
pushNewState(kStateChangingParameters, parameters);
|
||||||
|
if(deleteMemory)
|
||||||
|
{
|
||||||
|
pushNewState(kStateDeletingMemory);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if(deleteMemory)
|
||||||
|
{
|
||||||
|
this->resetMemory(true);
|
||||||
|
}
|
||||||
|
|
||||||
this->parseParameters(parameters);
|
this->parseParameters(parameters);
|
||||||
}
|
}
|
||||||
setupLogFiles();
|
setupLogFiles();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Rtabmap::init(const char * configFile)
|
void Rtabmap::init(const std::string & configFile, bool deleteMemory)
|
||||||
{
|
{
|
||||||
// fill ctrl struct with values from the configuration file
|
// fill ctrl struct with values from the configuration file
|
||||||
ParametersMap param;// = Parameters::defaultParameters;
|
ParametersMap param;// = Parameters::defaultParameters;
|
||||||
|
|
||||||
if(configFile)
|
if(!configFile.empty())
|
||||||
{
|
{
|
||||||
ULOGGER_DEBUG("Read parameters from = %s", configFile);
|
ULOGGER_DEBUG("Read parameters from = %s", configFile.c_str());
|
||||||
this->readParameters(configFile, param);
|
this->readParameters(configFile, param);
|
||||||
}
|
}
|
||||||
|
|
||||||
this->init(param);
|
this->init(param, deleteMemory);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Rtabmap::close()
|
void Rtabmap::close()
|
||||||
@@ -1615,10 +1619,10 @@ void Rtabmap::generateLocalGraph(const std::string & path, int id, int margin)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Rtabmap::readParameters(const char * configFile, ParametersMap & parameters)
|
void Rtabmap::readParameters(const std::string & configFile, ParametersMap & parameters)
|
||||||
{
|
{
|
||||||
CSimpleIniA ini;
|
CSimpleIniA ini;
|
||||||
ini.LoadFile(configFile);
|
ini.LoadFile(configFile.c_str());
|
||||||
const CSimpleIniA::TKeyVal * keyValMap = ini.GetSection("Core");
|
const CSimpleIniA::TKeyVal * keyValMap = ini.GetSection("Core");
|
||||||
if(keyValMap)
|
if(keyValMap)
|
||||||
{
|
{
|
||||||
@@ -1638,14 +1642,14 @@ void Rtabmap::readParameters(const char * configFile, ParametersMap & parameters
|
|||||||
{
|
{
|
||||||
ULOGGER_WARN("Section \"Core\" in %s doesn't exist... "
|
ULOGGER_WARN("Section \"Core\" in %s doesn't exist... "
|
||||||
"Ignore this warning if the ini file does not exist yet. "
|
"Ignore this warning if the ini file does not exist yet. "
|
||||||
"The ini file will be automatically created when this node will close.", configFile);
|
"The ini file will be automatically created when this node will close.", configFile.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Rtabmap::writeParameters(const char * configFile, const ParametersMap & parameters)
|
void Rtabmap::writeParameters(const std::string & configFile, const ParametersMap & parameters)
|
||||||
{
|
{
|
||||||
CSimpleIniA ini;
|
CSimpleIniA ini;
|
||||||
ini.LoadFile(configFile);
|
ini.LoadFile(configFile.c_str());
|
||||||
|
|
||||||
for(ParametersMap::const_iterator i=parameters.begin(); i!=parameters.end(); ++i)
|
for(ParametersMap::const_iterator i=parameters.begin(); i!=parameters.end(); ++i)
|
||||||
{
|
{
|
||||||
@@ -1654,7 +1658,7 @@ void Rtabmap::writeParameters(const char * configFile, const ParametersMap & par
|
|||||||
ini.SetValue("Core", key.c_str(), (*i).second.c_str(), NULL, true);
|
ini.SetValue("Core", key.c_str(), (*i).second.c_str(), NULL, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
ini.SaveFile(configFile);
|
ini.SaveFile(configFile.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace rtabmap
|
} // namespace rtabmap
|
||||||
|
|||||||
+1
-1
@@ -62,7 +62,7 @@ int main(int argc, char * argv[])
|
|||||||
// Or SURF hessian treshold:
|
// Or SURF hessian treshold:
|
||||||
// parameters.insert(rtabmap::ParametersPair(rtabmap::Parameters::kSURFHessianThreshold(), "150"));
|
// parameters.insert(rtabmap::ParametersPair(rtabmap::Parameters::kSURFHessianThreshold(), "150"));
|
||||||
|
|
||||||
// Initialize rtabmap: load/create database...
|
// Initialize rtabmap: delete/create database...
|
||||||
rtabmap.init(parameters);
|
rtabmap.init(parameters);
|
||||||
|
|
||||||
// Process each image of the directory...
|
// Process each image of the directory...
|
||||||
|
|||||||
@@ -379,9 +379,12 @@ int main(int argc, char * argv[])
|
|||||||
ULogger::setExitLevel(exitLevel);
|
ULogger::setExitLevel(exitLevel);
|
||||||
|
|
||||||
// Create tasks : memory is deleted
|
// Create tasks : memory is deleted
|
||||||
Rtabmap rtabmap(Parameters::defaultRtabmapWorkingDirectory());
|
Rtabmap rtabmap;
|
||||||
// Disable statistics (we don't need them)
|
// Disable statistics (we don't need them)
|
||||||
pm.insert(ParametersPair(Parameters::kRtabmapPublishStats(), uBool2Str(false)));
|
pm.insert(ParametersPair(Parameters::kRtabmapPublishStats(), uBool2Str(false)));
|
||||||
|
// use default working directory
|
||||||
|
pm.insert(ParametersPair(Parameters::kRtabmapWorkingDirectory(), Parameters::defaultRtabmapWorkingDirectory()));
|
||||||
|
|
||||||
rtabmap.init(pm);
|
rtabmap.init(pm);
|
||||||
rtabmap.setTimeThreshold(timeThreshold); // in ms
|
rtabmap.setTimeThreshold(timeThreshold); // in ms
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user