From ad04fed7e61d8f079299edf2217f96466da7962a Mon Sep 17 00:00:00 2001 From: matlabbe Date: Mon, 23 Jun 2014 00:26:14 +0000 Subject: [PATCH] Added Database recorder menu option git-svn-id: http://rtabmap.googlecode.com/svn/trunk/rtabmap@1433 f169173b-cf89-36c8-b27e-44dbe73f0c83 --- corelib/src/DBReader.cpp | 6 +++ examples/CameraRGBD/main.cpp | 2 +- guilib/include/rtabmap/gui/MainWindow.h | 1 + guilib/src/MainWindow.cpp | 50 +++++++++++++++++++++++++ guilib/src/ui/mainWindow.ui | 9 ++++- 5 files changed, 66 insertions(+), 2 deletions(-) diff --git a/corelib/src/DBReader.cpp b/corelib/src/DBReader.cpp index 893dddce..c1e675da 100644 --- a/corelib/src/DBReader.cpp +++ b/corelib/src/DBReader.cpp @@ -127,6 +127,12 @@ void DBReader::mainLoop() { Image data(image, depth, depth2d, depthConstant, pose, localTransform); this->post(new OdometryEvent(data)); + if(pose.isNull()) + { + UWARN("Reading the database: odometry is null! " + "Please set \"Ignore odometry = true\" if there is " + "no odometry in the database."); + } } else { diff --git a/examples/CameraRGBD/main.cpp b/examples/CameraRGBD/main.cpp index fcb9b464..930b2e4c 100644 --- a/examples/CameraRGBD/main.cpp +++ b/examples/CameraRGBD/main.cpp @@ -49,7 +49,7 @@ int main(int argc, char * argv[]) } UINFO("Using driver %d", driver); - rtabmap::CameraRGBD * camera; + rtabmap::CameraRGBD * camera = 0; if(driver == 0) { camera = new rtabmap::CameraOpenni("", 0); diff --git a/guilib/include/rtabmap/gui/MainWindow.h b/guilib/include/rtabmap/gui/MainWindow.h index d6b3cd79..06088b4e 100644 --- a/guilib/include/rtabmap/gui/MainWindow.h +++ b/guilib/include/rtabmap/gui/MainWindow.h @@ -155,6 +155,7 @@ private slots: void viewMeshes(); void resetOdometry(); void triggerNewMap(); + void dataRecorder(); void updateNodeVisibility(int, bool); signals: diff --git a/guilib/src/MainWindow.cpp b/guilib/src/MainWindow.cpp index 927c1c60..f24ac243 100644 --- a/guilib/src/MainWindow.cpp +++ b/guilib/src/MainWindow.cpp @@ -31,6 +31,7 @@ #include "rtabmap/gui/ImageView.h" #include "rtabmap/gui/KeypointItem.h" +#include "rtabmap/gui/DataRecorder.h" #include #include @@ -260,6 +261,7 @@ MainWindow::MainWindow(PreferencesDialog * prefDialog, QWidget * parent) : connect(_ui->actionView_point_cloud_as_mesh, SIGNAL(triggered()), this, SLOT(viewMeshes())); connect(_ui->actionReset_Odometry, SIGNAL(triggered()), this, SLOT(resetOdometry())); connect(_ui->actionTrigger_a_new_map, SIGNAL(triggered()), this, SLOT(triggerNewMap())); + connect(_ui->actionData_recorder, SIGNAL(triggered()), this, SLOT(dataRecorder())); _ui->actionPause->setShortcut(Qt::Key_Space); _ui->actionSave_point_cloud->setEnabled(false); @@ -3092,6 +3094,50 @@ void MainWindow::triggerNewMap() this->post(new RtabmapEventCmd(RtabmapEventCmd::kCmdTriggerNewMap)); } +void MainWindow::dataRecorder() +{ + if(_camera) + { + QString path = QFileDialog::getSaveFileName(this, tr("Save to..."), "output.db", "RTAB-Map database (*.db)"); + if(!path.isEmpty()) + { + int r = QMessageBox::question(this, tr("Hard drive or RAM?"), tr("Save in RAM?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes); + + if(r == QMessageBox::No || r == QMessageBox::Yes) + { + bool recordInRAM = r == QMessageBox::Yes; + QWidget * window = new QWidget(this, Qt::Popup); + window->setAttribute(Qt::WA_DeleteOnClose); + window->setWindowFlags(Qt::Dialog); + window->setWindowTitle(tr("Data recorder (%1)").arg(path)); + + DataRecorder * recorder = new DataRecorder(window); + + QVBoxLayout *layout = new QVBoxLayout(); + layout->addWidget(recorder); + window->setLayout(layout); + + if(recorder->init(path, recordInRAM)) + { + window->show(); + recorder->registerToEventsManager(); + UEventsManager::createPipe(_camera, recorder, "CameraEvent"); + } + else + { + QMessageBox::warning(this, tr(""), tr("Cannot initialize the data recorder!")); + UERROR("Cannot initialize the data recorder!"); + delete window; + } + } + } + } + else + { + UERROR("Camera should be already created."); + } +} + //END ACTIONS void MainWindow::savePointClouds(const std::map::Ptr> & clouds) @@ -3615,6 +3661,7 @@ void MainWindow::changeState(MainWindow::State newState) _ui->actionGenerate_map->setEnabled(true); _ui->actionGenerate_local_map->setEnabled(true); _ui->actionGenerate_TORO_graph_graph->setEnabled(true); + _ui->actionData_recorder->setEnabled(false); _ui->actionOpen_working_directory->setEnabled(true); _ui->actionApply_settings_to_the_detector->setEnabled(true); _ui->actionDownload_all_clouds->setEnabled(true); @@ -3644,6 +3691,7 @@ void MainWindow::changeState(MainWindow::State newState) _ui->actionGenerate_map->setEnabled(false); _ui->actionGenerate_local_map->setEnabled(false); _ui->actionGenerate_TORO_graph_graph->setEnabled(false); + _ui->actionData_recorder->setEnabled(true); _ui->actionOpen_working_directory->setEnabled(true); _ui->actionApply_settings_to_the_detector->setEnabled(false); _ui->actionDownload_all_clouds->setEnabled(false); @@ -3736,6 +3784,7 @@ void MainWindow::changeState(MainWindow::State newState) _ui->actionGenerate_map->setVisible(false); _ui->actionGenerate_local_map->setVisible(false); _ui->actionGenerate_TORO_graph_graph->setVisible(false); + _ui->actionData_recorder->setVisible(false); _ui->actionOpen_working_directory->setEnabled(false); _ui->actionApply_settings_to_the_detector->setVisible(false); _ui->actionDownload_all_clouds->setEnabled(true); @@ -3764,6 +3813,7 @@ void MainWindow::changeState(MainWindow::State newState) _ui->actionGenerate_map->setVisible(false); _ui->actionGenerate_local_map->setVisible(false); _ui->actionGenerate_TORO_graph_graph->setVisible(false); + _ui->actionData_recorder->setVisible(false); _ui->actionOpen_working_directory->setEnabled(false); _ui->actionApply_settings_to_the_detector->setVisible(false); _ui->actionDownload_all_clouds->setEnabled(true); diff --git a/guilib/src/ui/mainWindow.ui b/guilib/src/ui/mainWindow.ui index a1e46c6c..d2437e67 100644 --- a/guilib/src/ui/mainWindow.ui +++ b/guilib/src/ui/mainWindow.ui @@ -27,7 +27,7 @@ 0 0 1012 - 21 + 22 @@ -57,6 +57,8 @@ + + @@ -1042,6 +1044,11 @@ OpenNI-PCL + + + Data recorder... + +