Added Database recorder menu option

git-svn-id: http://rtabmap.googlecode.com/svn/trunk/rtabmap@1433 f169173b-cf89-36c8-b27e-44dbe73f0c83
This commit is contained in:
matlabbe
2014-06-23 00:26:14 +00:00
parent 65b79cd7a2
commit ad04fed7e6
5 changed files with 66 additions and 2 deletions

View File

@@ -127,6 +127,12 @@ void DBReader::mainLoop()
{ {
Image data(image, depth, depth2d, depthConstant, pose, localTransform); Image data(image, depth, depth2d, depthConstant, pose, localTransform);
this->post(new OdometryEvent(data)); 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 else
{ {

View File

@@ -49,7 +49,7 @@ int main(int argc, char * argv[])
} }
UINFO("Using driver %d", driver); UINFO("Using driver %d", driver);
rtabmap::CameraRGBD * camera; rtabmap::CameraRGBD * camera = 0;
if(driver == 0) if(driver == 0)
{ {
camera = new rtabmap::CameraOpenni("", 0); camera = new rtabmap::CameraOpenni("", 0);

View File

@@ -155,6 +155,7 @@ private slots:
void viewMeshes(); void viewMeshes();
void resetOdometry(); void resetOdometry();
void triggerNewMap(); void triggerNewMap();
void dataRecorder();
void updateNodeVisibility(int, bool); void updateNodeVisibility(int, bool);
signals: signals:

View File

@@ -31,6 +31,7 @@
#include "rtabmap/gui/ImageView.h" #include "rtabmap/gui/ImageView.h"
#include "rtabmap/gui/KeypointItem.h" #include "rtabmap/gui/KeypointItem.h"
#include "rtabmap/gui/DataRecorder.h"
#include <rtabmap/utilite/UStl.h> #include <rtabmap/utilite/UStl.h>
#include <rtabmap/utilite/ULogger.h> #include <rtabmap/utilite/ULogger.h>
@@ -260,6 +261,7 @@ MainWindow::MainWindow(PreferencesDialog * prefDialog, QWidget * parent) :
connect(_ui->actionView_point_cloud_as_mesh, SIGNAL(triggered()), this, SLOT(viewMeshes())); connect(_ui->actionView_point_cloud_as_mesh, SIGNAL(triggered()), this, SLOT(viewMeshes()));
connect(_ui->actionReset_Odometry, SIGNAL(triggered()), this, SLOT(resetOdometry())); connect(_ui->actionReset_Odometry, SIGNAL(triggered()), this, SLOT(resetOdometry()));
connect(_ui->actionTrigger_a_new_map, SIGNAL(triggered()), this, SLOT(triggerNewMap())); 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->actionPause->setShortcut(Qt::Key_Space);
_ui->actionSave_point_cloud->setEnabled(false); _ui->actionSave_point_cloud->setEnabled(false);
@@ -3092,6 +3094,50 @@ void MainWindow::triggerNewMap()
this->post(new RtabmapEventCmd(RtabmapEventCmd::kCmdTriggerNewMap)); 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 //END ACTIONS
void MainWindow::savePointClouds(const std::map<int, pcl::PointCloud<pcl::PointXYZRGB>::Ptr> & clouds) void MainWindow::savePointClouds(const std::map<int, pcl::PointCloud<pcl::PointXYZRGB>::Ptr> & clouds)
@@ -3615,6 +3661,7 @@ void MainWindow::changeState(MainWindow::State newState)
_ui->actionGenerate_map->setEnabled(true); _ui->actionGenerate_map->setEnabled(true);
_ui->actionGenerate_local_map->setEnabled(true); _ui->actionGenerate_local_map->setEnabled(true);
_ui->actionGenerate_TORO_graph_graph->setEnabled(true); _ui->actionGenerate_TORO_graph_graph->setEnabled(true);
_ui->actionData_recorder->setEnabled(false);
_ui->actionOpen_working_directory->setEnabled(true); _ui->actionOpen_working_directory->setEnabled(true);
_ui->actionApply_settings_to_the_detector->setEnabled(true); _ui->actionApply_settings_to_the_detector->setEnabled(true);
_ui->actionDownload_all_clouds->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_map->setEnabled(false);
_ui->actionGenerate_local_map->setEnabled(false); _ui->actionGenerate_local_map->setEnabled(false);
_ui->actionGenerate_TORO_graph_graph->setEnabled(false); _ui->actionGenerate_TORO_graph_graph->setEnabled(false);
_ui->actionData_recorder->setEnabled(true);
_ui->actionOpen_working_directory->setEnabled(true); _ui->actionOpen_working_directory->setEnabled(true);
_ui->actionApply_settings_to_the_detector->setEnabled(false); _ui->actionApply_settings_to_the_detector->setEnabled(false);
_ui->actionDownload_all_clouds->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_map->setVisible(false);
_ui->actionGenerate_local_map->setVisible(false); _ui->actionGenerate_local_map->setVisible(false);
_ui->actionGenerate_TORO_graph_graph->setVisible(false); _ui->actionGenerate_TORO_graph_graph->setVisible(false);
_ui->actionData_recorder->setVisible(false);
_ui->actionOpen_working_directory->setEnabled(false); _ui->actionOpen_working_directory->setEnabled(false);
_ui->actionApply_settings_to_the_detector->setVisible(false); _ui->actionApply_settings_to_the_detector->setVisible(false);
_ui->actionDownload_all_clouds->setEnabled(true); _ui->actionDownload_all_clouds->setEnabled(true);
@@ -3764,6 +3813,7 @@ void MainWindow::changeState(MainWindow::State newState)
_ui->actionGenerate_map->setVisible(false); _ui->actionGenerate_map->setVisible(false);
_ui->actionGenerate_local_map->setVisible(false); _ui->actionGenerate_local_map->setVisible(false);
_ui->actionGenerate_TORO_graph_graph->setVisible(false); _ui->actionGenerate_TORO_graph_graph->setVisible(false);
_ui->actionData_recorder->setVisible(false);
_ui->actionOpen_working_directory->setEnabled(false); _ui->actionOpen_working_directory->setEnabled(false);
_ui->actionApply_settings_to_the_detector->setVisible(false); _ui->actionApply_settings_to_the_detector->setVisible(false);
_ui->actionDownload_all_clouds->setEnabled(true); _ui->actionDownload_all_clouds->setEnabled(true);

View File

@@ -27,7 +27,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>1012</width> <width>1012</width>
<height>21</height> <height>22</height>
</rect> </rect>
</property> </property>
<widget class="QMenu" name="menuFile"> <widget class="QMenu" name="menuFile">
@@ -57,6 +57,8 @@
<addaction name="actionGenerate_local_map"/> <addaction name="actionGenerate_local_map"/>
<addaction name="actionGenerate_TORO_graph_graph"/> <addaction name="actionGenerate_TORO_graph_graph"/>
<addaction name="separator"/> <addaction name="separator"/>
<addaction name="actionData_recorder"/>
<addaction name="separator"/>
<addaction name="actionView_high_res_point_cloud"/> <addaction name="actionView_high_res_point_cloud"/>
<addaction name="actionSave_point_cloud"/> <addaction name="actionSave_point_cloud"/>
<addaction name="actionView_point_cloud_as_mesh"/> <addaction name="actionView_point_cloud_as_mesh"/>
@@ -1042,6 +1044,11 @@
<string>OpenNI-PCL</string> <string>OpenNI-PCL</string>
</property> </property>
</action> </action>
<action name="actionData_recorder">
<property name="text">
<string>Data recorder...</string>
</property>
</action>
</widget> </widget>
<customwidgets> <customwidgets>
<customwidget> <customwidget>