mirror of
https://github.com/introlab/rtabmap.git
synced 2026-09-02 01:20:25 +08:00
GUI: Updated data recorder action and message info on close
This commit is contained in:
@@ -47,14 +47,17 @@ public:
|
||||
DataRecorder(QWidget * parent = 0);
|
||||
bool init(const QString & path, bool recordInRAM = true);
|
||||
|
||||
void close();
|
||||
void closeRecorder();
|
||||
|
||||
virtual ~DataRecorder();
|
||||
|
||||
const QString & path() const {return path_;}
|
||||
|
||||
public slots:
|
||||
void addData(const rtabmap::SensorData & data);
|
||||
void showImage(const rtabmap::SensorData & data);
|
||||
protected:
|
||||
virtual void closeEvent(QCloseEvent* event);
|
||||
void handleEvent(UEvent * event);
|
||||
|
||||
private:
|
||||
@@ -62,6 +65,7 @@ private:
|
||||
ImageView* imageView_;
|
||||
UTimer timer_;
|
||||
int dataQueue_;
|
||||
QString path_;
|
||||
};
|
||||
|
||||
} /* namespace rtabmap */
|
||||
|
||||
@@ -66,6 +66,7 @@ class DetailedProgressDialog;
|
||||
class TwistGridWidget;
|
||||
class ExportCloudsDialog;
|
||||
class PostProcessingDialog;
|
||||
class DataRecorder;
|
||||
|
||||
class RTABMAPGUI_EXP MainWindow : public QMainWindow, public UEventsHandler
|
||||
{
|
||||
@@ -185,6 +186,7 @@ private slots:
|
||||
void resetOdometry();
|
||||
void triggerNewMap();
|
||||
void dataRecorder();
|
||||
void dataRecorderDestroyed();
|
||||
void updateNodeVisibility(int, bool);
|
||||
|
||||
signals:
|
||||
@@ -260,6 +262,7 @@ private:
|
||||
AboutDialog * _aboutDialog;
|
||||
ExportCloudsDialog * _exportDialog;
|
||||
PostProcessingDialog * _postProcessingDialog;
|
||||
DataRecorder * _dataRecorder;
|
||||
|
||||
QSet<int> _lastIds;
|
||||
int _lastId;
|
||||
|
||||
@@ -35,6 +35,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include <rtabmap/gui/ImageView.h>
|
||||
#include <rtabmap/gui/UCv2Qt.h>
|
||||
#include <QtCore/QMetaType>
|
||||
#include <QMessageBox>
|
||||
#include <QtGui/QCloseEvent>
|
||||
#include <QHBoxLayout>
|
||||
|
||||
namespace rtabmap {
|
||||
@@ -50,6 +52,7 @@ DataRecorder::DataRecorder(QWidget * parent) :
|
||||
|
||||
imageView_->setImageDepthShown(true);
|
||||
QHBoxLayout * layout = new QHBoxLayout(this);
|
||||
layout->setMargin(0);
|
||||
layout->addWidget(imageView_);
|
||||
this->setLayout(layout);
|
||||
}
|
||||
@@ -73,6 +76,7 @@ bool DataRecorder::init(const QString & path, bool recordInRAM)
|
||||
UERROR("Error initializing the memory.");
|
||||
return false;
|
||||
}
|
||||
path_ = path;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
@@ -82,18 +86,23 @@ bool DataRecorder::init(const QString & path, bool recordInRAM)
|
||||
}
|
||||
}
|
||||
|
||||
void DataRecorder::close()
|
||||
void DataRecorder::closeRecorder()
|
||||
{
|
||||
if(memory_)
|
||||
{
|
||||
delete memory_;
|
||||
memory_ = 0;
|
||||
}
|
||||
UINFO("Data recorded to \"%s\".", this->path().toStdString().c_str());
|
||||
if(this->isVisible())
|
||||
{
|
||||
QMessageBox::information(this, tr("Data recorder"), tr("Data recorded to \"%1\".").arg(this->path()));
|
||||
}
|
||||
}
|
||||
|
||||
DataRecorder::~DataRecorder()
|
||||
{
|
||||
this->close();
|
||||
this->closeRecorder();
|
||||
}
|
||||
|
||||
void DataRecorder::addData(const rtabmap::SensorData & data)
|
||||
@@ -125,6 +134,12 @@ void DataRecorder::showImage(const rtabmap::SensorData & data)
|
||||
}
|
||||
}
|
||||
|
||||
void DataRecorder::closeEvent(QCloseEvent* event)
|
||||
{
|
||||
this->closeRecorder();
|
||||
event->accept();
|
||||
}
|
||||
|
||||
void DataRecorder::handleEvent(UEvent * event)
|
||||
{
|
||||
if(event->getClassName().compare("CameraEvent") == 0)
|
||||
|
||||
@@ -115,6 +115,7 @@ MainWindow::MainWindow(PreferencesDialog * prefDialog, QWidget * parent) :
|
||||
_preferencesDialog(0),
|
||||
_aboutDialog(0),
|
||||
_exportDialog(0),
|
||||
_dataRecorder(0),
|
||||
_lastId(0),
|
||||
_processingStatistics(false),
|
||||
_odometryReceived(false),
|
||||
@@ -2809,6 +2810,11 @@ void MainWindow::startDetection()
|
||||
}
|
||||
}
|
||||
|
||||
if(_dataRecorder)
|
||||
{
|
||||
UEventsManager::createPipe(_camera, _dataRecorder, "CameraEvent");
|
||||
}
|
||||
|
||||
_lastOdomPose.setNull();
|
||||
this->post(new RtabmapEventCmd(RtabmapEventCmd::kCmdCleanDataBuffer)); // clean sensors buffer
|
||||
this->post(new RtabmapEventCmd(RtabmapEventCmd::kCmdTriggerNewMap)); // Trigger a new map
|
||||
@@ -2917,6 +2923,13 @@ void MainWindow::stopDetection()
|
||||
delete _odomThread;
|
||||
_odomThread = 0;
|
||||
}
|
||||
|
||||
if(_dataRecorder)
|
||||
{
|
||||
delete _dataRecorder;
|
||||
_dataRecorder = 0;
|
||||
}
|
||||
|
||||
emit stateChanged(kInitialized);
|
||||
}
|
||||
|
||||
@@ -4373,7 +4386,7 @@ void MainWindow::triggerNewMap()
|
||||
|
||||
void MainWindow::dataRecorder()
|
||||
{
|
||||
if(_camera)
|
||||
if(_dataRecorder == 0)
|
||||
{
|
||||
QString path = QFileDialog::getSaveFileName(this, tr("Save to..."), "output.db", "RTAB-Map database (*.db)");
|
||||
if(!path.isEmpty())
|
||||
@@ -4383,38 +4396,45 @@ void MainWindow::dataRecorder()
|
||||
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);
|
||||
_dataRecorder = new DataRecorder(this);
|
||||
_dataRecorder->setWindowFlags(Qt::Dialog);
|
||||
_dataRecorder->setAttribute(Qt::WA_DeleteOnClose, true);
|
||||
_dataRecorder->setWindowTitle(tr("Data recorder (%1)").arg(path));
|
||||
|
||||
QVBoxLayout *layout = new QVBoxLayout();
|
||||
layout->addWidget(recorder);
|
||||
window->setLayout(layout);
|
||||
|
||||
if(recorder->init(path, recordInRAM))
|
||||
if(_dataRecorder->init(path, recordInRAM))
|
||||
{
|
||||
window->show();
|
||||
recorder->registerToEventsManager();
|
||||
UEventsManager::createPipe(_camera, recorder, "CameraEvent");
|
||||
this->connect(_dataRecorder, SIGNAL(destroyed(QObject*)), this, SLOT(dataRecorderDestroyed()));
|
||||
_dataRecorder->show();
|
||||
_dataRecorder->registerToEventsManager();
|
||||
if(_camera)
|
||||
{
|
||||
UEventsManager::createPipe(_camera, _dataRecorder, "CameraEvent");
|
||||
}
|
||||
_ui->actionData_recorder->setEnabled(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
QMessageBox::warning(this, tr(""), tr("Cannot initialize the data recorder!"));
|
||||
UERROR("Cannot initialize the data recorder!");
|
||||
delete window;
|
||||
delete _dataRecorder;
|
||||
_dataRecorder = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
UERROR("Camera should be already created.");
|
||||
UERROR("Only one recorder at the same time.");
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::dataRecorderDestroyed()
|
||||
{
|
||||
_ui->actionData_recorder->setEnabled(true);
|
||||
_dataRecorder = 0;
|
||||
}
|
||||
|
||||
//END ACTIONS
|
||||
|
||||
void MainWindow::saveClouds(const std::map<int, pcl::PointCloud<pcl::PointXYZRGB>::Ptr> & clouds, bool binaryMode)
|
||||
@@ -5011,7 +5031,6 @@ 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(false);
|
||||
_ui->actionOpen_working_directory->setEnabled(true);
|
||||
_ui->actionDownload_all_clouds->setEnabled(false);
|
||||
_ui->actionDownload_graph->setEnabled(false);
|
||||
@@ -5059,7 +5078,6 @@ 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->actionDownload_all_clouds->setEnabled(true);
|
||||
_ui->actionDownload_graph->setEnabled(true);
|
||||
@@ -5096,7 +5114,6 @@ 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->actionDownload_all_clouds->setEnabled(false);
|
||||
_ui->actionDownload_graph->setEnabled(false);
|
||||
|
||||
Reference in New Issue
Block a user