2011-06-05 14:45:39 +00:00
|
|
|
/*
|
2014-08-11 17:00:55 +00:00
|
|
|
Copyright (c) 2010-2014, Mathieu Labbe - IntRoLab - Universite de Sherbrooke
|
|
|
|
|
All rights reserved.
|
|
|
|
|
|
|
|
|
|
Redistribution and use in source and binary forms, with or without
|
|
|
|
|
modification, are permitted provided that the following conditions are met:
|
|
|
|
|
* Redistributions of source code must retain the above copyright
|
|
|
|
|
notice, this list of conditions and the following disclaimer.
|
|
|
|
|
* Redistributions in binary form must reproduce the above copyright
|
|
|
|
|
notice, this list of conditions and the following disclaimer in the
|
|
|
|
|
documentation and/or other materials provided with the distribution.
|
|
|
|
|
* Neither the name of the Universite de Sherbrooke nor the
|
|
|
|
|
names of its contributors may be used to endorse or promote products
|
|
|
|
|
derived from this software without specific prior written permission.
|
|
|
|
|
|
|
|
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
|
|
|
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
|
|
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
|
|
|
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
|
|
|
|
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
|
|
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
|
|
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
|
|
|
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
|
|
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
*/
|
2011-06-05 14:45:39 +00:00
|
|
|
|
|
|
|
|
#ifndef MAINWINDOW_H_
|
|
|
|
|
#define MAINWINDOW_H_
|
|
|
|
|
|
2013-12-12 22:36:56 +00:00
|
|
|
#include "rtabmap/gui/RtabmapGuiExp.h" // DLL export/import defines
|
2011-06-05 14:45:39 +00:00
|
|
|
|
2013-04-30 20:16:01 +00:00
|
|
|
#include "rtabmap/utilite/UEventsHandler.h"
|
2011-06-05 14:45:39 +00:00
|
|
|
#include <QtGui/QMainWindow>
|
|
|
|
|
#include <QtCore/QSet>
|
|
|
|
|
#include "rtabmap/core/RtabmapEvent.h"
|
2014-08-18 23:14:04 +00:00
|
|
|
#include "rtabmap/core/SensorData.h"
|
2011-06-05 14:45:39 +00:00
|
|
|
#include "rtabmap/gui/PreferencesDialog.h"
|
|
|
|
|
|
2013-12-11 00:12:44 +00:00
|
|
|
#include <pcl/point_cloud.h>
|
|
|
|
|
#include <pcl/point_types.h>
|
|
|
|
|
#include <pcl/PolygonMesh.h>
|
|
|
|
|
|
2011-06-05 14:45:39 +00:00
|
|
|
namespace rtabmap {
|
2013-02-04 16:38:00 +00:00
|
|
|
class CameraThread;
|
2012-06-24 17:19:34 +00:00
|
|
|
class DBReader;
|
2013-12-11 00:12:44 +00:00
|
|
|
class CameraOpenni;
|
2014-06-03 04:42:08 +00:00
|
|
|
class CameraFreenect;
|
2013-12-11 00:12:44 +00:00
|
|
|
class OdometryThread;
|
|
|
|
|
class CloudViewer;
|
2011-06-05 14:45:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class QGraphicsScene;
|
|
|
|
|
class Ui_mainWindow;
|
|
|
|
|
class QActionGroup;
|
|
|
|
|
|
|
|
|
|
namespace rtabmap {
|
|
|
|
|
|
|
|
|
|
class LikelihoodScene;
|
|
|
|
|
class AboutDialog;
|
|
|
|
|
class Plot;
|
|
|
|
|
class PdfPlotCurve;
|
|
|
|
|
class StatsToolBox;
|
|
|
|
|
class DetailedProgressDialog;
|
2012-03-03 01:46:30 +00:00
|
|
|
class TwistGridWidget;
|
2014-10-01 17:52:27 +00:00
|
|
|
class ExportCloudsDialog;
|
2011-06-05 14:45:39 +00:00
|
|
|
|
2013-12-12 22:36:56 +00:00
|
|
|
class RTABMAPGUI_EXP MainWindow : public QMainWindow, public UEventsHandler
|
2011-06-05 14:45:39 +00:00
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
enum State {
|
|
|
|
|
kIdle,
|
2014-10-28 01:20:57 +00:00
|
|
|
kInitializing,
|
|
|
|
|
kInitialized,
|
|
|
|
|
kApplicationClosing,
|
|
|
|
|
kClosing,
|
2011-06-05 14:45:39 +00:00
|
|
|
kStartingDetection,
|
|
|
|
|
kDetecting,
|
|
|
|
|
kPaused,
|
2013-12-11 00:12:44 +00:00
|
|
|
kMonitoring,
|
|
|
|
|
kMonitoringPaused
|
2011-06-05 14:45:39 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
enum SrcType {
|
|
|
|
|
kSrcUndefined,
|
|
|
|
|
kSrcVideo,
|
|
|
|
|
kSrcImages,
|
|
|
|
|
kSrcStream
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
/**
|
|
|
|
|
* @param prefDialog If NULL, a default dialog is created. This
|
|
|
|
|
* dialog is automatically destroyed with the MainWindow.
|
|
|
|
|
*/
|
|
|
|
|
MainWindow(PreferencesDialog * prefDialog = 0, QWidget * parent = 0);
|
2012-03-03 01:46:30 +00:00
|
|
|
virtual ~MainWindow();
|
2011-06-05 14:45:39 +00:00
|
|
|
|
2011-06-30 17:48:14 +00:00
|
|
|
QString getWorkingDirectory() const;
|
2013-12-11 00:12:44 +00:00
|
|
|
void setMonitoringState(bool pauseChecked = false); // in monitoring state, only some actions are enabled
|
2011-06-30 17:48:14 +00:00
|
|
|
|
2011-06-05 14:45:39 +00:00
|
|
|
public slots:
|
2013-12-11 00:12:44 +00:00
|
|
|
void processStats(const rtabmap::Statistics & stat);
|
2011-06-05 14:45:39 +00:00
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
virtual void closeEvent(QCloseEvent* event);
|
|
|
|
|
virtual void handleEvent(UEvent* anEvent);
|
|
|
|
|
virtual void resizeEvent(QResizeEvent* anEvent);
|
|
|
|
|
|
|
|
|
|
private slots:
|
2013-12-11 00:12:44 +00:00
|
|
|
void changeState(MainWindow::State state);
|
2012-06-24 17:19:34 +00:00
|
|
|
void beep();
|
2014-10-28 01:20:57 +00:00
|
|
|
void newDatabase();
|
|
|
|
|
void openDatabase();
|
|
|
|
|
void closeDatabase();
|
|
|
|
|
void editDatabase();
|
2011-06-05 14:45:39 +00:00
|
|
|
void startDetection();
|
|
|
|
|
void pauseDetection();
|
|
|
|
|
void stopDetection();
|
2012-12-11 19:41:44 +00:00
|
|
|
void printLoopClosureIds();
|
2011-06-05 14:45:39 +00:00
|
|
|
void generateMap();
|
2012-12-11 18:05:05 +00:00
|
|
|
void generateLocalMap();
|
2014-01-22 19:49:28 +00:00
|
|
|
void generateTOROMap();
|
2011-06-05 14:45:39 +00:00
|
|
|
void deleteMemory();
|
|
|
|
|
void openWorkingDirectory();
|
|
|
|
|
void updateEditMenu();
|
|
|
|
|
void selectImages();
|
|
|
|
|
void selectVideo();
|
|
|
|
|
void selectStream();
|
|
|
|
|
void selectDatabase();
|
2013-12-11 00:12:44 +00:00
|
|
|
void selectOpenni();
|
2014-06-03 04:42:08 +00:00
|
|
|
void selectFreenect();
|
2014-06-13 03:47:39 +00:00
|
|
|
void selectOpenniCv();
|
|
|
|
|
void selectOpenniCvAsus();
|
2014-06-13 23:44:38 +00:00
|
|
|
void selectOpenni2();
|
2011-06-05 14:45:39 +00:00
|
|
|
void dumpTheMemory();
|
|
|
|
|
void dumpThePrediction();
|
2013-12-11 00:12:44 +00:00
|
|
|
void downloadAllClouds();
|
2014-02-11 23:04:22 +00:00
|
|
|
void downloadPoseGraph();
|
2011-06-05 14:45:39 +00:00
|
|
|
void clearTheCache();
|
|
|
|
|
void saveFigures();
|
|
|
|
|
void loadFigures();
|
2013-12-11 00:12:44 +00:00
|
|
|
void openPreferences();
|
2011-07-23 03:55:05 +00:00
|
|
|
void selectScreenCaptureFormat(bool checked);
|
2014-02-11 23:04:22 +00:00
|
|
|
void takeScreenshot();
|
2011-06-05 14:45:39 +00:00
|
|
|
void updateElapsedTime();
|
2014-09-25 15:04:35 +00:00
|
|
|
void processOdometry(const rtabmap::SensorData & data, int quality, float time, int features, int localMapSize);
|
2011-06-05 14:45:39 +00:00
|
|
|
void applyPrefSettings(PreferencesDialog::PANEL_FLAGS flags);
|
|
|
|
|
void applyPrefSettings(const rtabmap::ParametersMap & parameters);
|
|
|
|
|
void processRtabmapEventInit(int status, const QString & info);
|
2013-12-11 00:12:44 +00:00
|
|
|
void processRtabmapEvent3DMap(const rtabmap::RtabmapEvent3DMap & event);
|
2011-06-05 14:45:39 +00:00
|
|
|
void changeImgRateSetting();
|
2013-12-11 00:12:44 +00:00
|
|
|
void changeDetectionRateSetting();
|
2011-06-05 14:45:39 +00:00
|
|
|
void changeTimeLimitSetting();
|
2013-12-11 00:12:44 +00:00
|
|
|
void changeMappingMode();
|
2011-06-05 14:45:39 +00:00
|
|
|
void captureScreen();
|
2012-06-24 17:19:34 +00:00
|
|
|
void setAspectRatio(int w, int h);
|
|
|
|
|
void setAspectRatio16_9();
|
|
|
|
|
void setAspectRatio16_10();
|
|
|
|
|
void setAspectRatio4_3();
|
|
|
|
|
void setAspectRatio240p();
|
|
|
|
|
void setAspectRatio360p();
|
|
|
|
|
void setAspectRatio480p();
|
|
|
|
|
void setAspectRatio720p();
|
|
|
|
|
void setAspectRatio1080p();
|
2014-07-29 00:52:35 +00:00
|
|
|
void exportGridMap();
|
2014-07-29 14:11:08 +00:00
|
|
|
void exportScans();
|
|
|
|
|
void exportClouds();
|
|
|
|
|
void viewScans();
|
2014-07-29 00:52:35 +00:00
|
|
|
void viewClouds();
|
2013-12-11 00:12:44 +00:00
|
|
|
void resetOdometry();
|
|
|
|
|
void triggerNewMap();
|
2014-06-23 00:26:14 +00:00
|
|
|
void dataRecorder();
|
2014-01-22 19:49:28 +00:00
|
|
|
void updateNodeVisibility(int, bool);
|
2011-06-05 14:45:39 +00:00
|
|
|
|
|
|
|
|
signals:
|
|
|
|
|
void statsReceived(const rtabmap::Statistics &);
|
2014-09-25 15:04:35 +00:00
|
|
|
void odometryReceived(const rtabmap::SensorData &, int, float, int, int);
|
2011-06-05 14:45:39 +00:00
|
|
|
void thresholdsChanged(int, int);
|
|
|
|
|
void stateChanged(MainWindow::State);
|
|
|
|
|
void rtabmapEventInitReceived(int status, const QString & info);
|
2013-12-11 00:12:44 +00:00
|
|
|
void rtabmapEvent3DMapReceived(const rtabmap::RtabmapEvent3DMap & event);
|
2011-06-05 14:45:39 +00:00
|
|
|
void imgRateChanged(double);
|
2013-12-11 00:12:44 +00:00
|
|
|
void detectionRateChanged(double);
|
2012-03-03 01:46:30 +00:00
|
|
|
void timeLimitChanged(float);
|
2013-12-11 00:12:44 +00:00
|
|
|
void mappingModeChanged(bool);
|
2011-06-05 14:45:39 +00:00
|
|
|
void noMoreImagesReceived();
|
|
|
|
|
void loopClosureThrChanged(float);
|
2012-03-03 01:46:30 +00:00
|
|
|
void twistReceived(float x, float y, float z, float roll, float pitch, float yaw, int row, int col);
|
2011-06-05 14:45:39 +00:00
|
|
|
|
|
|
|
|
private:
|
2013-12-11 00:12:44 +00:00
|
|
|
void update3DMapVisibility(bool cloudsShown, bool scansShown);
|
2014-10-28 01:20:57 +00:00
|
|
|
void updateMapCloud(const std::map<int, Transform> & poses, const Transform & pose, const std::multimap<int, Link> & constraints, bool verboseProgress = false);
|
2014-06-23 20:43:08 +00:00
|
|
|
void createAndAddCloudToMap(int nodeId, const Transform & pose);
|
|
|
|
|
void createAndAddScanToMap(int nodeId, const Transform & pose);
|
2011-06-05 14:45:39 +00:00
|
|
|
void drawKeypoints(const std::multimap<int, cv::KeyPoint> & refWords, const std::multimap<int, cv::KeyPoint> & loopWords);
|
|
|
|
|
void setupMainLayout(bool vertical);
|
2012-06-24 17:19:34 +00:00
|
|
|
void updateSelectSourceImageMenu(int type);
|
|
|
|
|
void updateSelectSourceDatabase(bool used);
|
2014-06-13 03:47:39 +00:00
|
|
|
void updateSelectSourceRGBDMenu(bool used, PreferencesDialog::Src src);
|
2013-12-11 00:12:44 +00:00
|
|
|
|
2014-07-29 00:52:35 +00:00
|
|
|
pcl::PointCloud<pcl::PointXYZRGB>::Ptr getAssembledCloud(
|
|
|
|
|
const std::map<int, Transform> & poses,
|
|
|
|
|
float assembledVoxelSize,
|
|
|
|
|
bool regenerateClouds,
|
|
|
|
|
int regenerateDecimation,
|
|
|
|
|
float regenerateVoxelSize,
|
|
|
|
|
float regenerateMaxDepth) const;
|
2013-12-11 00:12:44 +00:00
|
|
|
pcl::PointCloud<pcl::PointXYZRGB>::Ptr createCloud(
|
|
|
|
|
int id,
|
|
|
|
|
const cv::Mat & rgb,
|
|
|
|
|
const cv::Mat & depth,
|
2014-07-26 04:36:00 +00:00
|
|
|
float fx,
|
|
|
|
|
float fy,
|
|
|
|
|
float cx,
|
|
|
|
|
float cy,
|
2013-12-11 00:12:44 +00:00
|
|
|
const Transform & localTransform,
|
|
|
|
|
const Transform & pose,
|
|
|
|
|
float voxelSize,
|
|
|
|
|
int decimation,
|
2014-06-23 20:43:08 +00:00
|
|
|
float maxDepth) const;
|
2014-07-29 00:52:35 +00:00
|
|
|
std::map<int, pcl::PointCloud<pcl::PointXYZRGB>::Ptr > getClouds(
|
|
|
|
|
const std::map<int, Transform> & poses,
|
|
|
|
|
bool regenerateClouds,
|
|
|
|
|
int regenerateDecimation,
|
|
|
|
|
float regenerateVoxelSize,
|
|
|
|
|
float regenerateMaxDepth) const;
|
2013-12-11 00:12:44 +00:00
|
|
|
|
2014-07-29 14:11:08 +00:00
|
|
|
bool getExportedScans(std::map<int, pcl::PointCloud<pcl::PointXYZ>::Ptr > & scans);
|
2014-07-29 00:52:35 +00:00
|
|
|
bool getExportedClouds(std::map<int, pcl::PointCloud<pcl::PointXYZRGB>::Ptr> & clouds, std::map<int, pcl::PolygonMesh::Ptr> & meshes, bool toSave);
|
|
|
|
|
void saveClouds(const std::map<int, pcl::PointCloud<pcl::PointXYZRGB>::Ptr> & clouds);
|
2013-12-11 00:12:44 +00:00
|
|
|
void saveMeshes(const std::map<int, pcl::PolygonMesh::Ptr> & meshes);
|
2014-07-29 14:11:08 +00:00
|
|
|
void saveScans(const std::map<int, pcl::PointCloud<pcl::PointXYZ>::Ptr> & clouds);
|
2011-06-05 14:45:39 +00:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
Ui_mainWindow * _ui;
|
|
|
|
|
|
|
|
|
|
State _state;
|
2013-02-04 16:38:00 +00:00
|
|
|
rtabmap::CameraThread * _camera;
|
2012-06-24 17:19:34 +00:00
|
|
|
rtabmap::DBReader * _dbReader;
|
2013-12-11 00:12:44 +00:00
|
|
|
rtabmap::OdometryThread * _odomThread;
|
2011-06-05 14:45:39 +00:00
|
|
|
|
|
|
|
|
SrcType _srcType;
|
|
|
|
|
QString _srcPath;
|
|
|
|
|
|
|
|
|
|
//Dialogs
|
|
|
|
|
PreferencesDialog * _preferencesDialog;
|
|
|
|
|
AboutDialog * _aboutDialog;
|
2014-10-01 17:52:27 +00:00
|
|
|
ExportCloudsDialog * _exportDialog;
|
2011-06-05 14:45:39 +00:00
|
|
|
|
|
|
|
|
QSet<int> _lastIds;
|
|
|
|
|
int _lastId;
|
2012-03-03 01:46:30 +00:00
|
|
|
bool _processingStatistics;
|
2013-12-11 00:12:44 +00:00
|
|
|
bool _odometryReceived;
|
2014-10-28 01:20:57 +00:00
|
|
|
QString _openedDatabasePath;
|
2011-06-05 14:45:39 +00:00
|
|
|
|
2014-10-26 21:47:29 +00:00
|
|
|
QMap<int, Signature> _cachedSignatures;
|
2014-10-01 21:44:46 +00:00
|
|
|
QMap<int, int> _mapIds;
|
2013-12-11 00:12:44 +00:00
|
|
|
std::map<int, Transform> _currentPosesMap;
|
2014-10-20 02:14:31 +00:00
|
|
|
std::map<int, pcl::PointCloud<pcl::PointXYZRGB>::Ptr > _createdClouds;
|
2014-07-29 21:48:37 +00:00
|
|
|
std::map<int, pcl::PointCloud<pcl::PointXYZ>::Ptr > _createdScans;
|
2014-10-20 02:14:31 +00:00
|
|
|
std::map<int, std::pair<cv::Mat, cv::Mat> > _occupancyLocalMaps; // <ground, obstacles>
|
2013-12-11 00:12:44 +00:00
|
|
|
Transform _odometryCorrection;
|
|
|
|
|
Transform _lastOdomPose;
|
|
|
|
|
bool _lastOdometryProcessed;
|
2011-06-05 14:45:39 +00:00
|
|
|
|
|
|
|
|
QTimer * _oneSecondTimer;
|
|
|
|
|
QTime * _elapsedTime;
|
|
|
|
|
QTime * _logEventTime;
|
|
|
|
|
|
|
|
|
|
PdfPlotCurve * _posteriorCurve;
|
|
|
|
|
PdfPlotCurve * _likelihoodCurve;
|
2012-12-11 18:05:05 +00:00
|
|
|
PdfPlotCurve * _rawLikelihoodCurve;
|
2012-06-24 17:19:34 +00:00
|
|
|
|
2011-06-05 14:45:39 +00:00
|
|
|
DetailedProgressDialog * _initProgressDialog;
|
|
|
|
|
|
|
|
|
|
QString _graphSavingFileName;
|
2014-01-22 19:49:28 +00:00
|
|
|
QString _toroSavingFileName;
|
2014-02-11 23:04:22 +00:00
|
|
|
bool _autoScreenCaptureOdomSync;
|
2012-12-11 19:41:44 +00:00
|
|
|
|
|
|
|
|
QVector<int> _refIds;
|
|
|
|
|
QVector<int> _loopClosureIds;
|
2011-06-05 14:45:39 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif /* MainWindow_H_ */
|