Multi component view (#1729)

* Multi component view implemented except for rotations. Rotations can cause segfaults.

* Implemented: handling rotations and applied rotations on optimized poses. Addition of a notion of main component (for saves in db) abd a node selection tool.

* New feature: merge component using selected nodes

* Refactored with suggestions.

* Fixing QSet error on older Qt versions

---------

Co-authored-by: matlabbe <[email protected]>
This commit is contained in:
Pierre ELIS
2026-08-01 08:33:53 -07:00
committed by GitHub
co-authored by matlabbe
parent d9f3337f97
commit bef4eaf679
11 changed files with 1525 additions and 441 deletions
+40 -2
View File
@@ -33,6 +33,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <QMainWindow>
#include <QtCore/QByteArray>
#include <QtCore/QMap>
#include <QtCore/QPointF>
#include <QtCore/QSet>
#include <QtGui/QImage>
#include <opencv2/core/core.hpp>
@@ -71,6 +72,24 @@ class EditMapArea;
class LinkRefiningDialog;
class Registration;
class RegistrationIcp;
class ExportDialog;
class GraphComponent
{
public:
GraphComponent() : id(0), rootId(0), firstNodeId(0), lastNodeId(0), rotationValue(0), viewScale(-1.0f), optimizationFlavor(0) {}
int id;
int rootId;
int firstNodeId;
int lastNodeId;
int rotationValue;
QPointF rootCoordinates;
float viewScale;
std::set<int> nodeIds;
std::set<int> selectedNodeIds;
int optimizationFlavor;
};
class RTABMAP_GUI_EXPORT DatabaseViewer : public QMainWindow
{
@@ -85,6 +104,10 @@ public:
protected:
virtual void showEvent(QShowEvent* anEvent);
private:
void backupCurrentComponent();
virtual void moveEvent(QMoveEvent* anEvent);
virtual void resizeEvent(QResizeEvent* anEvent);
virtual void keyPressEvent(QKeyEvent *event);
@@ -92,6 +115,7 @@ protected:
virtual bool eventFilter(QObject *obj, QEvent *event);
private Q_SLOTS:
void updateGraphInteractionMode();
void writeSettings();
void restoreDefaultSettings();
void configModified();
@@ -131,6 +155,7 @@ private Q_SLOTS:
void view3DMap();
void generate3DMap();
void detectMoreLoopClosures();
void mergeComponents();
void updateAllNeighborCovariances();
void updateAllLoopClosureCovariances();
void updateAllLandmarkCovariances();
@@ -138,6 +163,7 @@ private Q_SLOTS:
void resetAllChanges();
void graphNodeSelected(int);
void graphLinkSelected(int, int);
void zoomToNode();
void sliderAValueChanged(int);
void sliderBValueChanged(int);
void sliderAMoved(int);
@@ -146,6 +172,7 @@ private Q_SLOTS:
void sliderNeighborValueChanged(int);
void sliderLoopValueChanged(int);
void sliderIterationsValueChanged(int);
void updateGraphViewRootId();
void editConstraint();
void updateGrid();
void updateOctomapView();
@@ -161,6 +188,12 @@ private Q_SLOTS:
void notifyParametersChanged(const QStringList &);
void setupMainLayout(bool vertical);
void updateConstraintButtons();
void optimizationIgnoredStateChanged();
void fitInViewClicked();
void tabBarComponentsValueChanged(int);
void regenerateGraphComponents();
void updateComponentSelectedNodes();
void clearAllSelectedNodes();
private:
QString getIniFilePath() const;
@@ -175,7 +208,7 @@ private:
QLabel * label,
QLabel * stamp,
rtabmap::ImageView * view,
QLabel * labelId,
QToolButton * buttonNodeId,
QLabel * labelMapId,
QLabel * labelPose,
QLabel * labelOptPose,
@@ -205,7 +238,8 @@ private:
std::multimap<int, rtabmap::Link> updateLinksWithModifications(
const std::multimap<int, rtabmap::Link> & edgeConstraints);
void updateNeighborsSlider(int from = 0, int to = 0);
void updateLoopClosuresSlider(int from = 0, int to = 0);
void updateLoopClosuresSlider(int from, int to);
void updateLoopClosuresSlider();
void updateCovariances(const QList<Link> & links);
void refineLinks(const QList<Link> & links);
void refineConstraint(int from, int to, Registration * reg, RegistrationIcp * regIcp, bool silent);
@@ -234,6 +268,9 @@ private:
std::string databaseFileName_;
std::list<std::map<int, rtabmap::Transform> > graphes_;
std::multimap<int, rtabmap::Link> graphLinks_;
std::vector<GraphComponent> components_;
int activeComponentIndex_;
int lastValidNodeId_;
std::map<int, rtabmap::Transform> odomPoses_;
std::map<int, rtabmap::Transform> groundTruthPoses_;
std::map<int, rtabmap::Transform> gpsPoses_;
@@ -253,6 +290,7 @@ private:
QDialog * editMapDialog_;
EditMapArea * editMapArea_;
LinkRefiningDialog * linkRefiningDialog_;
ExportDialog * exportDataDialog_;
bool savedMaximized_;
bool firstCall_;
@@ -53,6 +53,8 @@ public:
int framesIgnored() const;
double targetFramerate() const;
int sessionExported() const;
bool currentComponentOnly() const;
bool selectedNodesOnly() const;
bool isRgbExported() const;
bool isDepthExported() const;
bool isDepth2dExported() const;
+9
View File
@@ -57,6 +57,7 @@ class RTABMAP_GUI_EXPORT GraphViewer : public QGraphicsView {
public:
enum ViewPlane {XY, XZ, YZ};
enum InteractionMode {HandMode, SelectionMode};
public:
GraphViewer(QWidget * parent = 0);
@@ -172,14 +173,21 @@ public:
void setOdomCacheOverlayVisible(bool visible);
void setOrientationENU(bool enabled);
void setViewPlane(ViewPlane plane);
void setInteractionMode(InteractionMode mode);
InteractionMode getInteractionMode() const {return _interactionMode;}
std::set<int> getSelectedNodeIds();
void selectNodesFromIds(const std::set<int> & ids);
void setEnsureFrameVisible(bool visible);
void setFastZoomMinNodes(int value);
QPointF getNodeScenePosition(int id) const;
void centerOnNode(int id);
Q_SIGNALS:
void configChanged();
void mapShownRequested();
void nodeSelected(int);
void linkSelected(int, int);
void nodesSelected(); // Nodes selected by rubber band, call getSelectedNodeIds() to get ids selected
public Q_SLOTS:
void restoreDefaults();
@@ -253,6 +261,7 @@ private:
bool _orientationENU;
bool _mouseTracking;
ViewPlane _viewPlane;
InteractionMode _interactionMode;
bool _ensureFrameVisible;
QPoint _previousMousePos;
QPoint _initialMousePos;
@@ -52,9 +52,13 @@ public:
int nodeIdMax,
int mapIdMin,
int mapIdMax);
void setRangesEnabled(bool selectedNodes, bool currentComponent);
Link::Type getLinkType() const;
void getIntraInterSessions(bool & intra, bool & inter) const;
bool isRangeByCurrentComponent() const;
bool isRangeBySelectedNodeIds() const;
bool isRangeByNodeId() const;
bool isRangeByMapId() const;
void getRangeNodeId(int & from, int & to) const;