mirror of
https://github.com/introlab/rtabmap_ros.git
synced 2026-10-04 08:47:45 +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);
|
DataRecorder(QWidget * parent = 0);
|
||||||
bool init(const QString & path, bool recordInRAM = true);
|
bool init(const QString & path, bool recordInRAM = true);
|
||||||
|
|
||||||
void close();
|
void closeRecorder();
|
||||||
|
|
||||||
virtual ~DataRecorder();
|
virtual ~DataRecorder();
|
||||||
|
|
||||||
|
const QString & path() const {return path_;}
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void addData(const rtabmap::SensorData & data);
|
void addData(const rtabmap::SensorData & data);
|
||||||
void showImage(const rtabmap::SensorData & data);
|
void showImage(const rtabmap::SensorData & data);
|
||||||
protected:
|
protected:
|
||||||
|
virtual void closeEvent(QCloseEvent* event);
|
||||||
void handleEvent(UEvent * event);
|
void handleEvent(UEvent * event);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -62,6 +65,7 @@ private:
|
|||||||
ImageView* imageView_;
|
ImageView* imageView_;
|
||||||
UTimer timer_;
|
UTimer timer_;
|
||||||
int dataQueue_;
|
int dataQueue_;
|
||||||
|
QString path_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} /* namespace rtabmap */
|
} /* namespace rtabmap */
|
||||||
|
|||||||
@@ -66,6 +66,7 @@ class DetailedProgressDialog;
|
|||||||
class TwistGridWidget;
|
class TwistGridWidget;
|
||||||
class ExportCloudsDialog;
|
class ExportCloudsDialog;
|
||||||
class PostProcessingDialog;
|
class PostProcessingDialog;
|
||||||
|
class DataRecorder;
|
||||||
|
|
||||||
class RTABMAPGUI_EXP MainWindow : public QMainWindow, public UEventsHandler
|
class RTABMAPGUI_EXP MainWindow : public QMainWindow, public UEventsHandler
|
||||||
{
|
{
|
||||||
@@ -185,6 +186,7 @@ private slots:
|
|||||||
void resetOdometry();
|
void resetOdometry();
|
||||||
void triggerNewMap();
|
void triggerNewMap();
|
||||||
void dataRecorder();
|
void dataRecorder();
|
||||||
|
void dataRecorderDestroyed();
|
||||||
void updateNodeVisibility(int, bool);
|
void updateNodeVisibility(int, bool);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
@@ -260,6 +262,7 @@ private:
|
|||||||
AboutDialog * _aboutDialog;
|
AboutDialog * _aboutDialog;
|
||||||
ExportCloudsDialog * _exportDialog;
|
ExportCloudsDialog * _exportDialog;
|
||||||
PostProcessingDialog * _postProcessingDialog;
|
PostProcessingDialog * _postProcessingDialog;
|
||||||
|
DataRecorder * _dataRecorder;
|
||||||
|
|
||||||
QSet<int> _lastIds;
|
QSet<int> _lastIds;
|
||||||
int _lastId;
|
int _lastId;
|
||||||
|
|||||||
@@ -35,6 +35,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
#include <rtabmap/gui/ImageView.h>
|
#include <rtabmap/gui/ImageView.h>
|
||||||
#include <rtabmap/gui/UCv2Qt.h>
|
#include <rtabmap/gui/UCv2Qt.h>
|
||||||
#include <QtCore/QMetaType>
|
#include <QtCore/QMetaType>
|
||||||
|
#include <QMessageBox>
|
||||||
|
#include <QtGui/QCloseEvent>
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
|
|
||||||
namespace rtabmap {
|
namespace rtabmap {
|
||||||
@@ -50,6 +52,7 @@ DataRecorder::DataRecorder(QWidget * parent) :
|
|||||||
|
|
||||||
imageView_->setImageDepthShown(true);
|
imageView_->setImageDepthShown(true);
|
||||||
QHBoxLayout * layout = new QHBoxLayout(this);
|
QHBoxLayout * layout = new QHBoxLayout(this);
|
||||||
|
layout->setMargin(0);
|
||||||
layout->addWidget(imageView_);
|
layout->addWidget(imageView_);
|
||||||
this->setLayout(layout);
|
this->setLayout(layout);
|
||||||
}
|
}
|
||||||
@@ -73,6 +76,7 @@ bool DataRecorder::init(const QString & path, bool recordInRAM)
|
|||||||
UERROR("Error initializing the memory.");
|
UERROR("Error initializing the memory.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
path_ = path;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -82,18 +86,23 @@ bool DataRecorder::init(const QString & path, bool recordInRAM)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataRecorder::close()
|
void DataRecorder::closeRecorder()
|
||||||
{
|
{
|
||||||
if(memory_)
|
if(memory_)
|
||||||
{
|
{
|
||||||
delete memory_;
|
delete memory_;
|
||||||
memory_ = 0;
|
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()
|
DataRecorder::~DataRecorder()
|
||||||
{
|
{
|
||||||
this->close();
|
this->closeRecorder();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataRecorder::addData(const rtabmap::SensorData & data)
|
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)
|
void DataRecorder::handleEvent(UEvent * event)
|
||||||
{
|
{
|
||||||
if(event->getClassName().compare("CameraEvent") == 0)
|
if(event->getClassName().compare("CameraEvent") == 0)
|
||||||
|
|||||||
+36
-19
@@ -115,6 +115,7 @@ MainWindow::MainWindow(PreferencesDialog * prefDialog, QWidget * parent) :
|
|||||||
_preferencesDialog(0),
|
_preferencesDialog(0),
|
||||||
_aboutDialog(0),
|
_aboutDialog(0),
|
||||||
_exportDialog(0),
|
_exportDialog(0),
|
||||||
|
_dataRecorder(0),
|
||||||
_lastId(0),
|
_lastId(0),
|
||||||
_processingStatistics(false),
|
_processingStatistics(false),
|
||||||
_odometryReceived(false),
|
_odometryReceived(false),
|
||||||
@@ -2809,6 +2810,11 @@ void MainWindow::startDetection()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(_dataRecorder)
|
||||||
|
{
|
||||||
|
UEventsManager::createPipe(_camera, _dataRecorder, "CameraEvent");
|
||||||
|
}
|
||||||
|
|
||||||
_lastOdomPose.setNull();
|
_lastOdomPose.setNull();
|
||||||
this->post(new RtabmapEventCmd(RtabmapEventCmd::kCmdCleanDataBuffer)); // clean sensors buffer
|
this->post(new RtabmapEventCmd(RtabmapEventCmd::kCmdCleanDataBuffer)); // clean sensors buffer
|
||||||
this->post(new RtabmapEventCmd(RtabmapEventCmd::kCmdTriggerNewMap)); // Trigger a new map
|
this->post(new RtabmapEventCmd(RtabmapEventCmd::kCmdTriggerNewMap)); // Trigger a new map
|
||||||
@@ -2917,6 +2923,13 @@ void MainWindow::stopDetection()
|
|||||||
delete _odomThread;
|
delete _odomThread;
|
||||||
_odomThread = 0;
|
_odomThread = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(_dataRecorder)
|
||||||
|
{
|
||||||
|
delete _dataRecorder;
|
||||||
|
_dataRecorder = 0;
|
||||||
|
}
|
||||||
|
|
||||||
emit stateChanged(kInitialized);
|
emit stateChanged(kInitialized);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4373,7 +4386,7 @@ void MainWindow::triggerNewMap()
|
|||||||
|
|
||||||
void MainWindow::dataRecorder()
|
void MainWindow::dataRecorder()
|
||||||
{
|
{
|
||||||
if(_camera)
|
if(_dataRecorder == 0)
|
||||||
{
|
{
|
||||||
QString path = QFileDialog::getSaveFileName(this, tr("Save to..."), "output.db", "RTAB-Map database (*.db)");
|
QString path = QFileDialog::getSaveFileName(this, tr("Save to..."), "output.db", "RTAB-Map database (*.db)");
|
||||||
if(!path.isEmpty())
|
if(!path.isEmpty())
|
||||||
@@ -4383,38 +4396,45 @@ void MainWindow::dataRecorder()
|
|||||||
if(r == QMessageBox::No || r == QMessageBox::Yes)
|
if(r == QMessageBox::No || r == QMessageBox::Yes)
|
||||||
{
|
{
|
||||||
bool recordInRAM = 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();
|
if(_dataRecorder->init(path, recordInRAM))
|
||||||
layout->addWidget(recorder);
|
|
||||||
window->setLayout(layout);
|
|
||||||
|
|
||||||
if(recorder->init(path, recordInRAM))
|
|
||||||
{
|
{
|
||||||
window->show();
|
this->connect(_dataRecorder, SIGNAL(destroyed(QObject*)), this, SLOT(dataRecorderDestroyed()));
|
||||||
recorder->registerToEventsManager();
|
_dataRecorder->show();
|
||||||
UEventsManager::createPipe(_camera, recorder, "CameraEvent");
|
_dataRecorder->registerToEventsManager();
|
||||||
|
if(_camera)
|
||||||
|
{
|
||||||
|
UEventsManager::createPipe(_camera, _dataRecorder, "CameraEvent");
|
||||||
|
}
|
||||||
|
_ui->actionData_recorder->setEnabled(false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
QMessageBox::warning(this, tr(""), tr("Cannot initialize the data recorder!"));
|
QMessageBox::warning(this, tr(""), tr("Cannot initialize the data recorder!"));
|
||||||
UERROR("Cannot initialize the data recorder!");
|
UERROR("Cannot initialize the data recorder!");
|
||||||
delete window;
|
delete _dataRecorder;
|
||||||
|
_dataRecorder = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
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
|
//END ACTIONS
|
||||||
|
|
||||||
void MainWindow::saveClouds(const std::map<int, pcl::PointCloud<pcl::PointXYZRGB>::Ptr> & clouds, bool binaryMode)
|
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_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(false);
|
|
||||||
_ui->actionOpen_working_directory->setEnabled(true);
|
_ui->actionOpen_working_directory->setEnabled(true);
|
||||||
_ui->actionDownload_all_clouds->setEnabled(false);
|
_ui->actionDownload_all_clouds->setEnabled(false);
|
||||||
_ui->actionDownload_graph->setEnabled(false);
|
_ui->actionDownload_graph->setEnabled(false);
|
||||||
@@ -5059,7 +5078,6 @@ 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->actionDownload_all_clouds->setEnabled(true);
|
_ui->actionDownload_all_clouds->setEnabled(true);
|
||||||
_ui->actionDownload_graph->setEnabled(true);
|
_ui->actionDownload_graph->setEnabled(true);
|
||||||
@@ -5096,7 +5114,6 @@ 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->actionDownload_all_clouds->setEnabled(false);
|
_ui->actionDownload_all_clouds->setEnabled(false);
|
||||||
_ui->actionDownload_graph->setEnabled(false);
|
_ui->actionDownload_graph->setEnabled(false);
|
||||||
|
|||||||
Reference in New Issue
Block a user