GUI: Added Multi-Session Localization view. CameraModel: set localTransform to optical rotation in default constructor (fixed matrix invertion errors with code ignoring setting local transform), save/read local transform in/from camera calibration yaml file (so that local transform is also exported when extracting rgb/depth images). Rtabmap: in localization mode, ignore landmarks farther than RGBD/LocalRadius if no global loop closures are already in odometry cache.

This commit is contained in:
matlabbe
2022-02-12 13:35:23 -05:00
parent f584f42ea4
commit 191e165a28
13 changed files with 612 additions and 24 deletions

View File

@@ -34,6 +34,8 @@ SET(headers_ui
../include/${PROJECT_PREFIX}/gui/RecoveryState.h
../include/${PROJECT_PREFIX}/gui/EditDepthArea.h
../include/${PROJECT_PREFIX}/gui/EditMapArea.h
../include/${PROJECT_PREFIX}/gui/MultiSessionLocWidget.h
../include/${PROJECT_PREFIX}/gui/MultiSessionLocSubView.h
)
SET(uis
@@ -51,6 +53,7 @@ SET(uis
./ui/depthCalibrationDialog.ui
./ui/exportBundlerDialog.ui
./ui/editConstraintDialog.ui
./ui/multiSessionLocSubView.ui
)
SET(qrc
@@ -103,6 +106,8 @@ SET(SRC_FILES
./GraphViewer.cpp
./EditDepthArea.cpp
./EditMapArea.cpp
./MultiSessionLocWidget.cpp
./MultiSessionLocSubView.cpp
./CreateSimpleCalibrationDialog.cpp
./ParametersToolBox.cpp
./DepthCalibrationDialog.cpp

View File

@@ -61,6 +61,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "rtabmap/gui/PostProcessingDialog.h"
#include "rtabmap/gui/DepthCalibrationDialog.h"
#include "rtabmap/gui/RecoveryState.h"
#include "rtabmap/gui/MultiSessionLocWidget.h"
#include <rtabmap/utilite/UStl.h>
#include <rtabmap/utilite/ULogger.h>
@@ -297,6 +298,9 @@ MainWindow::MainWindow(PreferencesDialog * prefDialog, QWidget * parent, bool sh
_ui->rawLikelihoodPlot->addCurve(_rawLikelihoodCurve, false);
_ui->rawLikelihoodPlot->showLegend(false);
_multiSessionLocWidget = new MultiSessionLocWidget(&_cachedSignatures, &_currentMapIds, this);
_ui->layout_multiSessionLoc->layout()->addWidget(_multiSessionLocWidget);
_progressDialog = new ProgressDialog(this);
_progressDialog->setMinimumWidth(800);
connect(_progressDialog, SIGNAL(canceled()), this, SLOT(cancelProgress()));
@@ -327,6 +331,7 @@ MainWindow::MainWindow(PreferencesDialog * prefDialog, QWidget * parent, bool sh
_ui->menuShow_view->addAction(_ui->dockWidget_mapVisibility->toggleViewAction());
_ui->menuShow_view->addAction(_ui->dockWidget_graphViewer->toggleViewAction());
_ui->menuShow_view->addAction(_ui->dockWidget_odometry->toggleViewAction());
_ui->menuShow_view->addAction(_ui->dockWidget_multiSessionLoc->toggleViewAction());
_ui->menuShow_view->addAction(_ui->toolBar->toggleViewAction());
_ui->toolBar->setWindowTitle(tr("File toolbar"));
_ui->menuShow_view->addAction(_ui->toolBar_2->toggleViewAction());
@@ -504,6 +509,7 @@ MainWindow::MainWindow(PreferencesDialog * prefDialog, QWidget * parent, bool sh
connect(_exportBundlerDialog, SIGNAL(configChanged()), this, SLOT(configGUIModified()));
connect(_postProcessingDialog, SIGNAL(configChanged()), this, SLOT(configGUIModified()));
connect(_depthCalibrationDialog, SIGNAL(configChanged()), this, SLOT(configGUIModified()));
connect(_multiSessionLocWidget->getImageView(), SIGNAL(configChanged()), this, SLOT(configGUIModified()));
connect(_ui->toolBar->toggleViewAction(), SIGNAL(toggled(bool)), this, SLOT(configGUIModified()));
connect(_ui->toolBar, SIGNAL(orientationChanged(Qt::Orientation)), this, SLOT(configGUIModified()));
connect(statusBarAction, SIGNAL(toggled(bool)), this, SLOT(configGUIModified()));
@@ -526,6 +532,7 @@ MainWindow::MainWindow(PreferencesDialog * prefDialog, QWidget * parent, bool sh
_ui->dockWidget_odometry->installEventFilter(this);
_ui->dockWidget_cloudViewer->installEventFilter(this);
_ui->dockWidget_imageView->installEventFilter(this);
_ui->dockWidget_multiSessionLoc->installEventFilter(this);
// more connects...
_ui->doubleSpinBox_stats_imgRate->setValue(_preferencesDialog->getGeneralInputRate());
@@ -560,6 +567,7 @@ MainWindow::MainWindow(PreferencesDialog * prefDialog, QWidget * parent, bool sh
_exportBundlerDialog->setWorkingDirectory(_preferencesDialog->getWorkingDirectory());
_cloudViewer->setBackfaceCulling(true, false);
_preferencesDialog->loadWidgetState(_cloudViewer);
_preferencesDialog->loadWidgetState(_multiSessionLocWidget->getImageView());
//dialog states
_preferencesDialog->loadWidgetState(_exportCloudsDialog);
@@ -799,6 +807,7 @@ void MainWindow::closeEvent(QCloseEvent* event)
_ui->dockWidget_mapVisibility->close();
_ui->dockWidget_graphViewer->close();
_ui->dockWidget_odometry->close();
_ui->dockWidget_multiSessionLoc->close();
if(_camera)
{
@@ -2295,6 +2304,7 @@ void MainWindow::processStats(const rtabmap::Statistics & stat)
//======================
// RGB-D Mapping stuff
//======================
_odometryCorrection = stat.mapCorrection();
// update clouds
if(stat.poses().size())
{
@@ -2428,7 +2438,6 @@ void MainWindow::processStats(const rtabmap::Statistics & stat)
}
}
}
_odometryCorrection = stat.mapCorrection();
if( _ui->graphicsView_graphView->isVisible())
{
@@ -2466,6 +2475,11 @@ void MainWindow::processStats(const rtabmap::Statistics & stat)
UDEBUG("time= %d ms (update graph view)", time.restart());
}
if(_multiSessionLocWidget->isVisible())
{
_multiSessionLocWidget->updateView(signature, stat);
}
_cachedSignatures.remove(0); // remove tmp negative ids
// keep only compressed data in cache
@@ -5106,6 +5120,7 @@ void MainWindow::saveConfigGUI()
_preferencesDialog->saveWidgetState(_postProcessingDialog);
_preferencesDialog->saveWidgetState(_depthCalibrationDialog);
_preferencesDialog->saveWidgetState(_ui->graphicsView_graphView);
_preferencesDialog->saveWidgetState(_multiSessionLocWidget->getImageView());
_preferencesDialog->saveSettings();
this->saveFigures();
this->setWindowModified(false);
@@ -7154,6 +7169,7 @@ void MainWindow::clearTheCache()
_ui->imageView_source->setBackgroundColor(_ui->imageView_source->getDefaultBackgroundColor());
_ui->imageView_loopClosure->setBackgroundColor(_ui->imageView_loopClosure->getDefaultBackgroundColor());
_ui->imageView_odometry->setBackgroundColor(_ui->imageView_odometry->getDefaultBackgroundColor());
_multiSessionLocWidget->clear();
#ifdef RTABMAP_OCTOMAP
// re-create one if the resolution has changed
UASSERT(_octomap != 0);
@@ -7264,6 +7280,7 @@ void MainWindow::setDefaultViews()
_ui->dockWidget_odometry->setVisible(true);
_ui->dockWidget_cloudViewer->setVisible(true);
_ui->dockWidget_imageView->setVisible(true);
_ui->dockWidget_multiSessionLoc->setVisible(false);
_ui->toolBar->setVisible(_state != kMonitoring && _state != kMonitoringPaused);
_ui->toolBar_2->setVisible(true);
_ui->statusbar->setVisible(false);

View File

@@ -0,0 +1,75 @@
/*
Copyright (c) 2010-2016, 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.
*/
#include "rtabmap/gui/MultiSessionLocSubView.h"
#include "ui_multiSessionLocSubView.h"
namespace rtabmap {
MultiSessionLocSubView::MultiSessionLocSubView(ImageView * mainView, int mapId, QWidget * parent) :
QWidget(parent),
mapId_(mapId)
{
ui_ = new Ui_multiSessionLocSubView();
ui_->setupUi(this);
ui_->imageView->setFeaturesShown(mainView->isFeaturesShown());
ui_->imageView->setFeaturesSize(mainView->getFeaturesSize());
ui_->imageView->setAlpha(mainView->getAlpha());
ui_->imageView->setDefaultMatchingFeatureColor(mainView->getDefaultMatchingFeatureColor());
}
MultiSessionLocSubView::~MultiSessionLocSubView() {}
void MultiSessionLocSubView::updateView(
int nodeId,
const QImage & image,
const std::multimap<int, cv::KeyPoint> & features,
float locRatio,
const QColor & bgColor)
{
if(image.isNull())
{
ui_->imageView->clear();
}
else
{
ui_->imageView->setImage(image);
ui_->imageView->setFeatures(features, cv::Mat(), ui_->imageView->getDefaultMatchingFeatureColor());
ui_->imageView->setBackgroundColor(bgColor);
}
ui_->label->setText(QString("%1 [%2]").arg(nodeId).arg(mapId_));
ui_->locProgressBar->setValue(locRatio * 100);
}
void MultiSessionLocSubView::clear()
{
ui_->imageView->clear();
ui_->label->setText(QString("[%1]").arg(mapId_));
}
} /* namespace rtabmap */

View File

@@ -0,0 +1,207 @@
/*
Copyright (c) 2010-2016, 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.
*/
#include "rtabmap/gui/MultiSessionLocWidget.h"
#include "rtabmap/gui/MultiSessionLocSubView.h"
#include "rtabmap/gui/ImageView.h"
#include "rtabmap/utilite/UStl.h"
#include "rtabmap/core/Graph.h"
#include <QHBoxLayout>
#include <QPushButton>
#include <QProgressBar>
namespace rtabmap {
MultiSessionLocWidget::MultiSessionLocWidget(
const QMap<int, Signature> * cache,
const std::map<int, int> * mapIds,
QWidget * parent) :
QWidget(parent),
cache_(cache),
mapIds_(mapIds),
totalFrames_(0),
totalLoops_(0)
{
UASSERT(cache != 0);
UASSERT(mapIds != 0);
imageView_ = new ImageView(this);
imageView_->setObjectName("multisession_imageview");
totalLocProgressBar_ = new QProgressBar(this);
resetbutton_ = new QPushButton(this);
resetbutton_->setText("Reset");
// setup layout
this->setLayout(new QHBoxLayout());
QVBoxLayout * vLayout = new QVBoxLayout(this);
vLayout->addWidget(imageView_, 1);
QHBoxLayout * hLayout = new QHBoxLayout(this);
hLayout->addWidget(resetbutton_, 0);
hLayout->addWidget(totalLocProgressBar_, 1);
vLayout->addLayout(hLayout, 0);
((QHBoxLayout*)this->layout())->addLayout(vLayout, 1);
connect(resetbutton_, SIGNAL(clicked()), this, SLOT(clear()));
}
MultiSessionLocWidget::~MultiSessionLocWidget() {}
void MultiSessionLocWidget::updateView(
const Signature & lastSignature,
const Statistics & stats)
{
++totalFrames_;
std::multimap<int, Link> loopLinks = graph::filterLinks(lastSignature.getLinks(), Link::kGlobalClosure, true);
std::multimap<int, Link> localLinks = graph::filterLinks(lastSignature.getLinks(), Link::kLocalSpaceClosure, true);
loopLinks.insert(localLinks.begin(), localLinks.end());
if(!loopLinks.empty())
{
++totalLoops_;
totalLocProgressBar_->setValue(float(totalLoops_)/float(totalFrames_) * 100);
}
if(!lastSignature.sensorData().imageRaw().empty() ||
!lastSignature.sensorData().imageCompressed().empty())
{
cv::Mat image;
lastSignature.sensorData().uncompressDataConst(&image, 0);
if(!image.empty())
{
imageView_->setImage(uCvMat2QImage(image));
imageView_->setFeatures(lastSignature.getWordsKpts(), cv::Mat(), imageView_->getDefaultMatchingFeatureColor());
imageView_->setBackgroundColor(Qt::black);
}
else
{
imageView_->clear();
}
}
else
{
imageView_->clear();
}
std::map<int, std::pair<int, float> > top;
const std::map<int, float> & likelihood = stats.posterior();
for(std::map<int, float>::const_iterator iter=likelihood.begin(); iter!=likelihood.end(); ++iter)
{
if(mapIds_->find(iter->first) != mapIds_->end())
{
int mapId = mapIds_->at(iter->first);
if(subViews_.find(mapId)==subViews_.end())
{
MultiSessionLocSubView * subView = new MultiSessionLocSubView(imageView_, mapId, this);
((QHBoxLayout*)this->layout())->addWidget(subView, 1);
subViews_.insert(std::make_pair(mapId, std::make_pair(subView, 0)));
}
if(top.find(mapId) == top.end() || top.at(mapId).second < iter->second)
{
uInsert(top, std::make_pair(mapId, std::make_pair(iter->first, iter->second)));
}
}
}
// update highest loop closure hypotheses per session
for(std::map<int, std::pair<MultiSessionLocSubView*, int> >::iterator iter=subViews_.begin(); iter!=subViews_.end(); ++iter)
{
for(std::multimap<int, Link>::iterator jter=loopLinks.begin(); jter!=loopLinks.end(); ++jter)
{
if(mapIds_->find(jter->first)!= mapIds_->end())
{
int mapId = mapIds_->at(jter->first);
iter->second.second += mapId==iter->first?1:0;
}
}
if(uContains(top, iter->first))
{
int nodeId = top.at(iter->first).first;
if(cache_->contains(nodeId))
{
cv::Mat image;
const Signature & s = (*cache_)[nodeId];
Link link = loopLinks.find(nodeId) != loopLinks.end()?loopLinks.find(nodeId)->second:Link();
std::multimap<int, cv::KeyPoint> keypoints;
for(std::multimap<int, int>::const_iterator jter=s.getWords().begin(); jter!=s.getWords().end(); ++jter)
{
if(jter->first>0 && lastSignature.getWords().find(jter->first) != lastSignature.getWords().end())
{
keypoints.insert(std::make_pair(jter->first, s.getWordsKpts()[jter->second]));
}
}
if(!keypoints.empty())
{
s.sensorData().uncompressDataConst(&image, 0);
if(!image.empty())
{
iter->second.first->updateView(
nodeId,
uCvMat2QImage(image),
keypoints,
float(iter->second.second)/float(totalFrames_),
link.type() == Link::kLocalSpaceClosure?Qt::yellow:
link.type() == Link::kGlobalClosure?Qt::green:Qt::gray);
}
else
{
iter->second.first->clear();
}
}
else
{
iter->second.first->clear();
}
}
else
{
iter->second.first->clear();
}
}
else
{
iter->second.first->clear();
}
}
}
void MultiSessionLocWidget::clear()
{
for(std::map<int, std::pair<MultiSessionLocSubView*, int> >::iterator iter=subViews_.begin(); iter!=subViews_.end(); ++iter)
{
delete iter->second.first;
}
subViews_.clear();
imageView_->clear();
totalFrames_ = 0;
totalLoops_ = 0;
totalLocProgressBar_->setValue(0);
}
} /* namespace rtabmap */

View File

@@ -1044,6 +1044,33 @@
<addaction name="actionPause"/>
<addaction name="actionStop"/>
</widget>
<widget class="QDockWidget" name="dockWidget_multiSessionLoc">
<property name="windowTitle">
<string>Multi-Session Localization</string>
</property>
<attribute name="dockWidgetArea">
<number>2</number>
</attribute>
<widget class="QWidget" name="layout_multiSessionLoc">
<layout class="QVBoxLayout" name="verticalLayout_12">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
</layout>
</widget>
</widget>
<action name="actionExit">
<property name="icon">
<iconset resource="../GuiLib.qrc">

View File

@@ -0,0 +1,67 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>multiSessionLocSubView</class>
<widget class="QWidget" name="multiSessionLocSubView">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>192</width>
<height>296</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,1,0">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Map 0</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="rtabmap::ImageView" name="imageView" native="true"/>
</item>
<item>
<widget class="QProgressBar" name="locProgressBar">
<property name="value">
<number>24</number>
</property>
<property name="textVisible">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>rtabmap::ImageView</class>
<extends>QWidget</extends>
<header>rtabmap/gui/ImageView.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>