DBReader: changed maxFrames option to stopId and startIndex to startId. Reprocess: added options to start and stop at specific ids in the database.

This commit is contained in:
matlabbe
2020-04-22 16:20:29 -04:00
parent 012439aa0b
commit 94360e19e0
5 changed files with 75 additions and 47 deletions

View File

@@ -50,17 +50,17 @@ public:
bool odometryIgnored = false, bool odometryIgnored = false,
bool ignoreGoalDelay = false, bool ignoreGoalDelay = false,
bool goalsIgnored = false, bool goalsIgnored = false,
int startIndex = 0, int startId = 0,
int cameraIndex = -1, int cameraIndex = -1,
int maxFrames = 0); int stopId = 0);
DBReader(const std::list<std::string> & databasePaths, DBReader(const std::list<std::string> & databasePaths,
float frameRate = 0.0f, // -1 = use Database stamps, 0 = inf float frameRate = 0.0f, // -1 = use Database stamps, 0 = inf
bool odometryIgnored = false, bool odometryIgnored = false,
bool ignoreGoalDelay = false, bool ignoreGoalDelay = false,
bool goalsIgnored = false, bool goalsIgnored = false,
int startIndex = 0, int startId = 0,
int cameraIndex = -1, int cameraIndex = -1,
int maxFrames = 0); int stopId = 0);
virtual ~DBReader(); virtual ~DBReader();
virtual bool init( virtual bool init(
@@ -82,8 +82,8 @@ private:
bool _odometryIgnored; bool _odometryIgnored;
bool _ignoreGoalDelay; bool _ignoreGoalDelay;
bool _goalsIgnored; bool _goalsIgnored;
int _startIndex; int _startId;
int _maxFrames; int _stopId;
int _cameraIndex; int _cameraIndex;
DBDriver * _dbDriver; DBDriver * _dbDriver;
@@ -95,7 +95,6 @@ private:
double _previousStamp; double _previousStamp;
int _previousMapID; int _previousMapID;
bool _calibrated; bool _calibrated;
int _framesPublished;
}; };
} /* namespace rtabmap */ } /* namespace rtabmap */

View File

@@ -47,25 +47,28 @@ DBReader::DBReader(const std::string & databasePath,
bool odometryIgnored, bool odometryIgnored,
bool ignoreGoalDelay, bool ignoreGoalDelay,
bool goalsIgnored, bool goalsIgnored,
int startIndex, int stopId,
int cameraIndex, int cameraIndex,
int maxFrames) : int endId) :
Camera(frameRate), Camera(frameRate),
_paths(uSplit(databasePath, ';')), _paths(uSplit(databasePath, ';')),
_odometryIgnored(odometryIgnored), _odometryIgnored(odometryIgnored),
_ignoreGoalDelay(ignoreGoalDelay), _ignoreGoalDelay(ignoreGoalDelay),
_goalsIgnored(goalsIgnored), _goalsIgnored(goalsIgnored),
_startIndex(startIndex), _startId(stopId),
_maxFrames(maxFrames), _stopId(endId),
_cameraIndex(cameraIndex), _cameraIndex(cameraIndex),
_dbDriver(0), _dbDriver(0),
_currentId(_ids.end()), _currentId(_ids.end()),
_previousMapId(-1), _previousMapId(-1),
_previousStamp(0), _previousStamp(0),
_previousMapID(0), _previousMapID(0),
_calibrated(false), _calibrated(false)
_framesPublished(0)
{ {
if(_stopId>0 && _stopId<_startId)
{
_stopId = _startId;
}
} }
DBReader::DBReader(const std::list<std::string> & databasePaths, DBReader::DBReader(const std::list<std::string> & databasePaths,
@@ -73,25 +76,28 @@ DBReader::DBReader(const std::list<std::string> & databasePaths,
bool odometryIgnored, bool odometryIgnored,
bool ignoreGoalDelay, bool ignoreGoalDelay,
bool goalsIgnored, bool goalsIgnored,
int startIndex, int stopId,
int cameraIndex, int cameraIndex,
int maxFrames) : int endId) :
Camera(frameRate), Camera(frameRate),
_paths(databasePaths), _paths(databasePaths),
_odometryIgnored(odometryIgnored), _odometryIgnored(odometryIgnored),
_ignoreGoalDelay(ignoreGoalDelay), _ignoreGoalDelay(ignoreGoalDelay),
_goalsIgnored(goalsIgnored), _goalsIgnored(goalsIgnored),
_startIndex(startIndex), _startId(stopId),
_maxFrames(maxFrames), _stopId(endId),
_cameraIndex(cameraIndex), _cameraIndex(cameraIndex),
_dbDriver(0), _dbDriver(0),
_currentId(_ids.end()), _currentId(_ids.end()),
_previousMapId(-1), _previousMapId(-1),
_previousStamp(0), _previousStamp(0),
_previousMapID(0), _previousMapID(0),
_calibrated(false), _calibrated(false)
_framesPublished(0)
{ {
if(_stopId>0 && _stopId<_startId)
{
_stopId = _startId;
}
} }
DBReader::~DBReader() DBReader::~DBReader()
@@ -120,7 +126,6 @@ bool DBReader::init(
_previousStamp = 0; _previousStamp = 0;
_previousMapID = 0; _previousMapID = 0;
_calibrated = false; _calibrated = false;
_framesPublished = 0;
if(_paths.size() == 0) if(_paths.size() == 0)
{ {
@@ -153,12 +158,12 @@ bool DBReader::init(
_dbDriver->getAllNodeIds(_ids); _dbDriver->getAllNodeIds(_ids);
_currentId = _ids.begin(); _currentId = _ids.begin();
if(_startIndex>0 && _ids.size()) if(_startId>0 && _ids.size())
{ {
std::set<int>::iterator iter = uIteratorAt(_ids, _startIndex); std::set<int>::iterator iter = _ids.find(_startId);
if(iter == _ids.end()) if(iter == _ids.end())
{ {
UWARN("Start index is too high (%d), the last in database is %d. Starting from beginning...", _startIndex, _ids.size()-1); UWARN("Start index is too high (%d), the last ID in database is %d. Starting from beginning...", _startId, *_ids.rbegin());
} }
else else
{ {
@@ -219,13 +224,12 @@ std::string DBReader::getSerial() const
SensorData DBReader::captureImage(CameraInfo * info) SensorData DBReader::captureImage(CameraInfo * info)
{ {
if(_maxFrames>0 && ++_framesPublished > _maxFrames) SensorData data = this->getNextData(info);
if(data.id()>0 && _stopId>0 && data.id() > _stopId)
{ {
UINFO("Maximum frames (%d) reached!", _maxFrames); UINFO("Last ID %d has been reached! Ignoring", _stopId);
return SensorData(); return SensorData();
} }
SensorData data = this->getNextData(info);
if(data.id() == 0) if(data.id() == 0)
{ {
UINFO("no more images..."); UINFO("no more images...");

View File

@@ -611,8 +611,8 @@ PreferencesDialog::PreferencesDialog(QWidget * parent) :
connect(_ui->source_checkBox_ignoreOdometry, SIGNAL(stateChanged(int)), this, SLOT(makeObsoleteSourcePanel())); connect(_ui->source_checkBox_ignoreOdometry, SIGNAL(stateChanged(int)), this, SLOT(makeObsoleteSourcePanel()));
connect(_ui->source_checkBox_ignoreGoalDelay, SIGNAL(stateChanged(int)), this, SLOT(makeObsoleteSourcePanel())); connect(_ui->source_checkBox_ignoreGoalDelay, SIGNAL(stateChanged(int)), this, SLOT(makeObsoleteSourcePanel()));
connect(_ui->source_checkBox_ignoreGoals, SIGNAL(stateChanged(int)), this, SLOT(makeObsoleteSourcePanel())); connect(_ui->source_checkBox_ignoreGoals, SIGNAL(stateChanged(int)), this, SLOT(makeObsoleteSourcePanel()));
connect(_ui->source_spinBox_databaseStartPos, SIGNAL(valueChanged(int)), this, SLOT(makeObsoleteSourcePanel())); connect(_ui->source_spinBox_databaseStartId, SIGNAL(valueChanged(int)), this, SLOT(makeObsoleteSourcePanel()));
connect(_ui->source_spinBox_databaseMaxFrames, SIGNAL(valueChanged(int)), this, SLOT(makeObsoleteSourcePanel())); connect(_ui->source_spinBox_databaseStopId, SIGNAL(valueChanged(int)), this, SLOT(makeObsoleteSourcePanel()));
connect(_ui->source_checkBox_useDbStamps, SIGNAL(stateChanged(int)), this, SLOT(makeObsoleteSourcePanel())); connect(_ui->source_checkBox_useDbStamps, SIGNAL(stateChanged(int)), this, SLOT(makeObsoleteSourcePanel()));
connect(_ui->source_spinBox_database_cameraIndex, SIGNAL(valueChanged(int)), this, SLOT(makeObsoleteSourcePanel())); connect(_ui->source_spinBox_database_cameraIndex, SIGNAL(valueChanged(int)), this, SLOT(makeObsoleteSourcePanel()));
@@ -1771,8 +1771,8 @@ void PreferencesDialog::resetSettings(QGroupBox * groupBox)
_ui->source_checkBox_ignoreOdometry->setChecked(false); _ui->source_checkBox_ignoreOdometry->setChecked(false);
_ui->source_checkBox_ignoreGoalDelay->setChecked(true); _ui->source_checkBox_ignoreGoalDelay->setChecked(true);
_ui->source_checkBox_ignoreGoals->setChecked(true); _ui->source_checkBox_ignoreGoals->setChecked(true);
_ui->source_spinBox_databaseStartPos->setValue(0); _ui->source_spinBox_databaseStartId->setValue(0);
_ui->source_spinBox_databaseMaxFrames->setValue(0); _ui->source_spinBox_databaseStopId->setValue(0);
_ui->source_spinBox_database_cameraIndex->setValue(-1); _ui->source_spinBox_database_cameraIndex->setValue(-1);
_ui->source_checkBox_useDbStamps->setChecked(true); _ui->source_checkBox_useDbStamps->setChecked(true);
@@ -2384,8 +2384,8 @@ void PreferencesDialog::readCameraSettings(const QString & filePath)
_ui->source_checkBox_ignoreOdometry->setChecked(settings.value("ignoreOdometry", _ui->source_checkBox_ignoreOdometry->isChecked()).toBool()); _ui->source_checkBox_ignoreOdometry->setChecked(settings.value("ignoreOdometry", _ui->source_checkBox_ignoreOdometry->isChecked()).toBool());
_ui->source_checkBox_ignoreGoalDelay->setChecked(settings.value("ignoreGoalDelay", _ui->source_checkBox_ignoreGoalDelay->isChecked()).toBool()); _ui->source_checkBox_ignoreGoalDelay->setChecked(settings.value("ignoreGoalDelay", _ui->source_checkBox_ignoreGoalDelay->isChecked()).toBool());
_ui->source_checkBox_ignoreGoals->setChecked(settings.value("ignoreGoals", _ui->source_checkBox_ignoreGoals->isChecked()).toBool()); _ui->source_checkBox_ignoreGoals->setChecked(settings.value("ignoreGoals", _ui->source_checkBox_ignoreGoals->isChecked()).toBool());
_ui->source_spinBox_databaseStartPos->setValue(settings.value("startPos", _ui->source_spinBox_databaseStartPos->value()).toInt()); _ui->source_spinBox_databaseStartId->setValue(settings.value("startId", _ui->source_spinBox_databaseStartId->value()).toInt());
_ui->source_spinBox_databaseMaxFrames->setValue(settings.value("maxFrames", _ui->source_spinBox_databaseMaxFrames->value()).toInt()); _ui->source_spinBox_databaseStopId->setValue(settings.value("stopId", _ui->source_spinBox_databaseStopId->value()).toInt());
_ui->source_spinBox_database_cameraIndex->setValue(settings.value("cameraIndex", _ui->source_spinBox_database_cameraIndex->value()).toInt()); _ui->source_spinBox_database_cameraIndex->setValue(settings.value("cameraIndex", _ui->source_spinBox_database_cameraIndex->value()).toInt());
_ui->source_checkBox_useDbStamps->setChecked(settings.value("useDatabaseStamps", _ui->source_checkBox_useDbStamps->isChecked()).toBool()); _ui->source_checkBox_useDbStamps->setChecked(settings.value("useDatabaseStamps", _ui->source_checkBox_useDbStamps->isChecked()).toBool());
settings.endGroup(); // Database settings.endGroup(); // Database
@@ -2849,8 +2849,8 @@ void PreferencesDialog::writeCameraSettings(const QString & filePath) const
settings.setValue("ignoreOdometry", _ui->source_checkBox_ignoreOdometry->isChecked()); settings.setValue("ignoreOdometry", _ui->source_checkBox_ignoreOdometry->isChecked());
settings.setValue("ignoreGoalDelay", _ui->source_checkBox_ignoreGoalDelay->isChecked()); settings.setValue("ignoreGoalDelay", _ui->source_checkBox_ignoreGoalDelay->isChecked());
settings.setValue("ignoreGoals", _ui->source_checkBox_ignoreGoals->isChecked()); settings.setValue("ignoreGoals", _ui->source_checkBox_ignoreGoals->isChecked());
settings.setValue("startPos", _ui->source_spinBox_databaseStartPos->value()); settings.setValue("startId", _ui->source_spinBox_databaseStartId->value());
settings.setValue("maxFrames", _ui->source_spinBox_databaseMaxFrames->value()); settings.setValue("stopId", _ui->source_spinBox_databaseStopId->value());
settings.setValue("cameraIndex", _ui->source_spinBox_database_cameraIndex->value()); settings.setValue("cameraIndex", _ui->source_spinBox_database_cameraIndex->value());
settings.setValue("useDatabaseStamps", _ui->source_checkBox_useDbStamps->isChecked()); settings.setValue("useDatabaseStamps", _ui->source_checkBox_useDbStamps->isChecked());
settings.endGroup(); // Database settings.endGroup(); // Database
@@ -3669,8 +3669,8 @@ void PreferencesDialog::selectSourceDatabase()
} }
_ui->source_database_lineEdit_path->setText(paths.size()==1?paths.front():paths.join(";")); _ui->source_database_lineEdit_path->setText(paths.size()==1?paths.front():paths.join(";"));
_ui->source_spinBox_databaseStartPos->setValue(0); _ui->source_spinBox_databaseStartId->setValue(0);
_ui->source_spinBox_databaseMaxFrames->setValue(0); _ui->source_spinBox_databaseStopId->setValue(0);
_ui->source_spinBox_database_cameraIndex->setValue(-1); _ui->source_spinBox_database_cameraIndex->setValue(-1);
} }
} }
@@ -5758,9 +5758,9 @@ Camera * PreferencesDialog::createCamera(bool useRawImages, bool useColor)
_ui->source_checkBox_ignoreOdometry->isChecked(), _ui->source_checkBox_ignoreOdometry->isChecked(),
_ui->source_checkBox_ignoreGoalDelay->isChecked(), _ui->source_checkBox_ignoreGoalDelay->isChecked(),
_ui->source_checkBox_ignoreGoals->isChecked(), _ui->source_checkBox_ignoreGoals->isChecked(),
_ui->source_spinBox_databaseStartPos->value(), _ui->source_spinBox_databaseStartId->value(),
_ui->source_spinBox_database_cameraIndex->value(), _ui->source_spinBox_database_cameraIndex->value(),
_ui->source_spinBox_databaseMaxFrames->value()); _ui->source_spinBox_databaseStopId->value());
} }
else else
{ {

View File

@@ -63,7 +63,7 @@
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>-224</y>
<width>680</width> <width>680</width>
<height>3310</height> <height>3310</height>
</rect> </rect>
@@ -95,7 +95,7 @@
<enum>QFrame::Raised</enum> <enum>QFrame::Raised</enum>
</property> </property>
<property name="currentIndex"> <property name="currentIndex">
<number>36</number> <number>5</number>
</property> </property>
<widget class="QWidget" name="page_22"> <widget class="QWidget" name="page_22">
<layout class="QVBoxLayout" name="verticalLayout_29" stretch="0,1"> <layout class="QVBoxLayout" name="verticalLayout_29" stretch="0,1">
@@ -3109,7 +3109,7 @@ when using the file type, logs are saved in LogRtabmap.txt (located in the worki
<item> <item>
<widget class="QStackedWidget" name="stackedWidget_src"> <widget class="QStackedWidget" name="stackedWidget_src">
<property name="currentIndex"> <property name="currentIndex">
<number>0</number> <number>3</number>
</property> </property>
<widget class="QWidget" name="page_41"> <widget class="QWidget" name="page_41">
<layout class="QVBoxLayout" name="verticalLayout_64"> <layout class="QVBoxLayout" name="verticalLayout_64">
@@ -5665,7 +5665,7 @@ when using the file type, logs are saved in LogRtabmap.txt (located in the worki
<item row="5" column="1"> <item row="5" column="1">
<widget class="QLabel" name="label_58"> <widget class="QLabel" name="label_58">
<property name="text"> <property name="text">
<string>Start position (index).</string> <string>Start position (node ID).</string>
</property> </property>
<property name="textInteractionFlags"> <property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set> <set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
@@ -5673,7 +5673,7 @@ when using the file type, logs are saved in LogRtabmap.txt (located in the worki
</widget> </widget>
</item> </item>
<item row="5" column="0"> <item row="5" column="0">
<widget class="QSpinBox" name="source_spinBox_databaseStartPos"> <widget class="QSpinBox" name="source_spinBox_databaseStartId">
<property name="minimum"> <property name="minimum">
<number>0</number> <number>0</number>
</property> </property>
@@ -5761,7 +5761,10 @@ when using the file type, logs are saved in LogRtabmap.txt (located in the worki
<item row="6" column="1"> <item row="6" column="1">
<widget class="QLabel" name="label_529"> <widget class="QLabel" name="label_529">
<property name="text"> <property name="text">
<string>Maximum frames after start position. 0 means publishing all frames.</string> <string>Stop position (node ID) is the last node to process. If 0, all nodes after start position are published.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property> </property>
<property name="textInteractionFlags"> <property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set> <set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
@@ -5769,7 +5772,7 @@ when using the file type, logs are saved in LogRtabmap.txt (located in the worki
</widget> </widget>
</item> </item>
<item row="6" column="0"> <item row="6" column="0">
<widget class="QSpinBox" name="source_spinBox_databaseMaxFrames"> <widget class="QSpinBox" name="source_spinBox_databaseStopId">
<property name="minimum"> <property name="minimum">
<number>0</number> <number>0</number>
</property> </property>

View File

@@ -58,6 +58,8 @@ void showUsage()
" -c \"path.ini\" Configuration file, overwriting parameters read \n" " -c \"path.ini\" Configuration file, overwriting parameters read \n"
" from the database. If custom parameters are also set as \n" " from the database. If custom parameters are also set as \n"
" arguments, they overwrite those in config file and the database.\n" " arguments, they overwrite those in config file and the database.\n"
" -start # Start from this node ID.\n"
" -stop # Last node to process.\n"
" -g2 Assemble 2D occupancy grid map and save it to \"[output]_map.pgm\".\n" " -g2 Assemble 2D occupancy grid map and save it to \"[output]_map.pgm\".\n"
" -g3 Assemble 3D cloud map and save it to \"[output]_map.pcd\".\n" " -g3 Assemble 3D cloud map and save it to \"[output]_map.pcd\".\n"
" -o2 Assemble OctoMap 2D projection and save it to \"[output]_octomap.pgm\".\n" " -o2 Assemble OctoMap 2D projection and save it to \"[output]_octomap.pgm\".\n"
@@ -152,6 +154,8 @@ int main(int argc, char * argv[])
bool assemble2dOctoMap = false; bool assemble2dOctoMap = false;
bool assemble3dOctoMap = false; bool assemble3dOctoMap = false;
bool useDatabaseRate = false; bool useDatabaseRate = false;
int startId = 0;
int stopId = 0;
ParametersMap configParameters; ParametersMap configParameters;
for(int i=1; i<argc-2; ++i) for(int i=1; i<argc-2; ++i)
{ {
@@ -177,6 +181,24 @@ int main(int argc, char * argv[])
printf("Config file is not set!\n"); printf("Config file is not set!\n");
} }
} }
else if (strcmp(argv[i], "-start") == 0 || strcmp(argv[i], "--start") == 0)
{
++i;
if(i < argc - 2)
{
startId = atoi(argv[i]);
printf("Start at node ID = %d.\n", startId);
}
}
else if (strcmp(argv[i], "-stop") == 0 || strcmp(argv[i], "--stop") == 0)
{
++i;
if(i < argc - 2)
{
stopId = atoi(argv[i]);
printf("Stop at node ID = %d.\n", stopId);
}
}
else if(strcmp(argv[i], "-g2") == 0 || strcmp(argv[i], "--g2") == 0) else if(strcmp(argv[i], "-g2") == 0 || strcmp(argv[i], "--g2") == 0)
{ {
assemble2dMap = true; assemble2dMap = true;
@@ -322,7 +344,7 @@ int main(int argc, char * argv[])
bool rgbdEnabled = Parameters::defaultRGBDEnabled(); bool rgbdEnabled = Parameters::defaultRGBDEnabled();
Parameters::parse(parameters, Parameters::kRGBDEnabled(), rgbdEnabled); Parameters::parse(parameters, Parameters::kRGBDEnabled(), rgbdEnabled);
bool odometryIgnored = !rgbdEnabled; bool odometryIgnored = !rgbdEnabled;
DBReader dbReader(inputDatabasePath, useDatabaseRate?-1:0, odometryIgnored); DBReader dbReader(inputDatabasePath, useDatabaseRate?-1:0, odometryIgnored, false, false, startId, -1, stopId);
dbReader.init(); dbReader.init();
OccupancyGrid grid(parameters); OccupancyGrid grid(parameters);