GUI: added options to hide map/odom frames and yellow TF links. CloudViewer: added option to show/hide camera axis

This commit is contained in:
matlabbe
2020-04-03 20:04:15 -04:00
parent 9c62a11316
commit b3f7d1881f
6 changed files with 116 additions and 26 deletions

View File

@@ -90,6 +90,7 @@ CloudViewer::CloudViewer(QWidget *parent, CloudViewerInteractorStyle * style) :
_aShowTrajectory(0),
_aSetTrajectorySize(0),
_aClearTrajectory(0),
_aShowCameraAxis(0),
_aShowFrustum(0),
_aSetFrustumScale(0),
_aSetFrustumColor(0),
@@ -204,7 +205,10 @@ void CloudViewer::clear()
this->removeOccupancyGridMap();
this->removeOctomap();
this->addOrUpdateCoordinate("reference", Transform::getIdentity(), 0.2);
if(_aShowCameraAxis->isChecked())
{
this->addOrUpdateCoordinate("reference", Transform::getIdentity(), 0.2);
}
_lastPose.setNull();
if(_aLockCamera->isChecked() || _aFollowCamera->isChecked())
{
@@ -236,6 +240,9 @@ void CloudViewer::createMenu()
_aShowTrajectory->setChecked(true);
_aSetTrajectorySize = new QAction("Set trajectory size...", this);
_aClearTrajectory = new QAction("Clear trajectory", this);
_aShowCameraAxis= new QAction("Show base frame", this);
_aShowCameraAxis->setCheckable(true);
_aShowCameraAxis->setChecked(true);
_aShowFrustum= new QAction("Show frustum", this);
_aShowFrustum->setCheckable(true);
_aShowFrustum->setChecked(false);
@@ -312,6 +319,7 @@ void CloudViewer::createMenu()
_menu = new QMenu(this);
_menu->addMenu(cameraMenu);
_menu->addMenu(trajectoryMenu);
_menu->addAction(_aShowCameraAxis);
_menu->addMenu(frustumMenu);
_menu->addMenu(gridMenu);
_menu->addMenu(normalsMenu);
@@ -369,6 +377,8 @@ void CloudViewer::saveSettings(QSettings & settings, const QString & group) cons
settings.setValue("trajectory_shown", this->isTrajectoryShown());
settings.setValue("trajectory_size", this->getTrajectorySize());
settings.setValue("camera_axis_shown", this->isCameraAxisShown());
settings.setValue("frustum_shown", this->isFrustumShown());
settings.setValue("frustum_scale", this->getFrustumScale());
settings.setValue("frustum_color", this->getFrustumColor());
@@ -416,6 +426,8 @@ void CloudViewer::loadSettings(QSettings & settings, const QString & group)
this->setTrajectoryShown(settings.value("trajectory_shown", this->isTrajectoryShown()).toBool());
this->setTrajectorySize(settings.value("trajectory_size", this->getTrajectorySize()).toUInt());
this->setCameraAxisShown(settings.value("camera_axis_shown", this->isCameraAxisShown()).toBool());
this->setFrustumShown(settings.value("frustum_shown", this->isFrustumShown()).toBool());
this->setFrustumScale(settings.value("frustum_scale", this->getFrustumScale()).toDouble());
this->setFrustumColor(settings.value("frustum_color", this->getFrustumColor()).value<QColor>());
@@ -2117,6 +2129,25 @@ void CloudViewer::clearTrajectory()
this->update();
}
bool CloudViewer::isCameraAxisShown() const
{
return _aShowCameraAxis->isChecked();
}
void CloudViewer::setCameraAxisShown(bool shown)
{
if(!shown)
{
this->removeCoordinate("reference");
}
else
{
this->addOrUpdateCoordinate("reference", Transform::getIdentity(), 0.2);
}
this->update();
_aShowCameraAxis->setChecked(shown);
}
bool CloudViewer::isFrustumShown() const
{
return _aShowFrustum->isChecked();
@@ -2595,15 +2626,18 @@ void CloudViewer::updateCameraTargetPosition(const Transform & pose)
cameras.front().view[2] = _aLockViewZ->isChecked()?1:Fp[10];
}
if(_aShowCameraAxis->isChecked())
{
#if PCL_VERSION_COMPARE(>=, 1, 7, 2)
if(_coordinates.find("reference") != _coordinates.end())
{
this->updateCoordinatePose("reference", pose);
}
else
if(_coordinates.find("reference") != _coordinates.end())
{
this->updateCoordinatePose("reference", pose);
}
else
#endif
{
this->addOrUpdateCoordinate("reference", pose, 0.2);
{
this->addOrUpdateCoordinate("reference", pose, 0.2);
}
}
_visualizer->setCameraPosition(
@@ -3255,6 +3289,10 @@ void CloudViewer::handleAction(QAction * a)
{
this->clearTrajectory();
}
else if(a == _aShowCameraAxis)
{
this->setCameraAxisShown(a->isChecked());
}
else if(a == _aShowFrustum)
{
this->setFrustumShown(a->isChecked());

View File

@@ -1345,7 +1345,14 @@ void MainWindow::processOdometry(const rtabmap::OdometryEvent & odom, bool dataI
}
_cloudViewer->updateCameraTargetPosition(_odometryCorrection*odom.pose());
#if PCL_VERSION_COMPARE(>=, 1, 7, 2)
_cloudViewer->addOrUpdateLine("odom_to_base_link", _odometryCorrection, _odometryCorrection*odom.pose(), Qt::yellow, false, false);
if(_preferencesDialog->isFramesShown())
{
_cloudViewer->addOrUpdateLine("odom_to_base_link", _odometryCorrection, _odometryCorrection*odom.pose(), Qt::yellow, false, false);
}
else
{
_cloudViewer->removeLine("odom_to_base_link");
}
#endif
}
@@ -2055,9 +2062,18 @@ void MainWindow::processStats(const rtabmap::Statistics & stat)
}
#if PCL_VERSION_COMPARE(>=, 1, 7, 2)
_cloudViewer->addOrUpdateCoordinate("map_frame", Transform::getIdentity(), 0.5, false);
_cloudViewer->addOrUpdateCoordinate("odom_frame", _odometryCorrection, 0.35, false);
_cloudViewer->addOrUpdateLine("map_to_odom", Transform::getIdentity(), _odometryCorrection, Qt::yellow, false, false);
if(_preferencesDialog->isFramesShown())
{
_cloudViewer->addOrUpdateCoordinate("map_frame", Transform::getIdentity(), 0.5, false);
_cloudViewer->addOrUpdateCoordinate("odom_frame", _odometryCorrection, 0.35, false);
_cloudViewer->addOrUpdateLine("map_to_odom", Transform::getIdentity(), _odometryCorrection, Qt::yellow, false, false);
}
else
{
_cloudViewer->removeLine("map_to_odom");
_cloudViewer->removeCoordinate("odom_frame");
_cloudViewer->removeCoordinate("map_frame");
}
#endif
if(_cachedSignatures.contains(0) && stat.refImageId()>0)
@@ -4721,6 +4737,7 @@ void MainWindow::newDatabase()
_cloudViewer->removeLine("map_to_odom");
_cloudViewer->removeLine("odom_to_base_link");
_cloudViewer->removeCoordinate("odom_frame");
_cloudViewer->removeCoordinate("map_frame");
ULOGGER_DEBUG("");
this->clearTheCache();
std::string databasePath = (_preferencesDialog->getWorkingDirectory()+QDir::separator()+QString("rtabmap.tmp.db")).toStdString();

View File

@@ -528,6 +528,7 @@ PreferencesDialog::PreferencesDialog(QWidget * parent) :
connect(_ui->checkBox_showGraphs, SIGNAL(stateChanged(int)), this, SLOT(makeObsoleteCloudRenderingPanel()));
connect(_ui->checkBox_showLabels, SIGNAL(stateChanged(int)), this, SLOT(makeObsoleteCloudRenderingPanel()));
connect(_ui->checkBox_showFrames, SIGNAL(stateChanged(int)), this, SLOT(makeObsoleteCloudRenderingPanel()));
connect(_ui->checkBox_showLandmarks, SIGNAL(stateChanged(int)), this, SLOT(makeObsoleteCloudRenderingPanel()));
connect(_ui->doubleSpinBox_landmarkSize, SIGNAL(valueChanged(double)), this, SLOT(makeObsoleteCloudRenderingPanel()));
connect(_ui->checkBox_showIMUGravity, SIGNAL(stateChanged(int)), this, SLOT(makeObsoleteCloudRenderingPanel()));
@@ -1684,6 +1685,7 @@ void PreferencesDialog::resetSettings(QGroupBox * groupBox)
_ui->checkBox_showGraphs->setChecked(true);
_ui->checkBox_showLabels->setChecked(false);
_ui->checkBox_showFrames->setChecked(true);
_ui->checkBox_showLandmarks->setChecked(true);
_ui->doubleSpinBox_landmarkSize->setValue(0);
_ui->checkBox_showIMUGravity->setChecked(false);
@@ -2134,6 +2136,7 @@ void PreferencesDialog::readGuiSettings(const QString & filePath)
_ui->checkBox_showGraphs->setChecked(settings.value("showGraphs", _ui->checkBox_showGraphs->isChecked()).toBool());
_ui->checkBox_showLabels->setChecked(settings.value("showLabels", _ui->checkBox_showLabels->isChecked()).toBool());
_ui->checkBox_showFrames->setChecked(settings.value("showFrames", _ui->checkBox_showFrames->isChecked()).toBool());
_ui->checkBox_showLandmarks->setChecked(settings.value("showLandmarks", _ui->checkBox_showLandmarks->isChecked()).toBool());
_ui->doubleSpinBox_landmarkSize->setValue(settings.value("landmarkSize", _ui->doubleSpinBox_landmarkSize->value()).toDouble());
_ui->checkBox_showIMUGravity->setChecked(settings.value("showIMUGravity", _ui->checkBox_showIMUGravity->isChecked()).toBool());
@@ -2597,6 +2600,7 @@ void PreferencesDialog::writeGuiSettings(const QString & filePath) const
settings.setValue("showGraphs", _ui->checkBox_showGraphs->isChecked());
settings.setValue("showLabels", _ui->checkBox_showLabels->isChecked());
settings.setValue("showFrames", _ui->checkBox_showFrames->isChecked());
settings.setValue("showLandmarks", _ui->checkBox_showLandmarks->isChecked());
settings.setValue("landmarkSize", _ui->doubleSpinBox_landmarkSize->value());
settings.setValue("showIMUGravity", _ui->checkBox_showIMUGravity->isChecked());
@@ -4940,6 +4944,10 @@ bool PreferencesDialog::isLabelsShown() const
{
return _ui->checkBox_showLabels->isChecked();
}
bool PreferencesDialog::isFramesShown() const
{
return _ui->checkBox_showFrames->isChecked();
}
bool PreferencesDialog::isLandmarksShown() const
{
return _ui->checkBox_showLandmarks->isChecked();

View File

@@ -63,7 +63,7 @@
<property name="geometry">
<rect>
<x>0</x>
<y>-374</y>
<y>-1162</y>
<width>680</width>
<height>3157</height>
</rect>
@@ -95,7 +95,7 @@
<enum>QFrame::Raised</enum>
</property>
<property name="currentIndex">
<number>5</number>
<number>1</number>
</property>
<widget class="QWidget" name="page_22">
<layout class="QVBoxLayout" name="verticalLayout_29" stretch="0,1">
@@ -1847,7 +1847,7 @@ Show a yellow background when the number of odometry inliers goes under this thr
</property>
</widget>
</item>
<item row="6" column="2">
<item row="7" column="2">
<widget class="QLabel" name="label_301">
<property name="text">
<string>Show landmarks.</string>
@@ -1860,7 +1860,7 @@ Show a yellow background when the number of odometry inliers goes under this thr
</property>
</widget>
</item>
<item row="6" column="0">
<item row="7" column="0">
<widget class="QCheckBox" name="checkBox_showLandmarks">
<property name="text">
<string/>
@@ -1870,7 +1870,7 @@ Show a yellow background when the number of odometry inliers goes under this thr
</property>
</widget>
</item>
<item row="7" column="2">
<item row="8" column="2">
<widget class="QLabel" name="label_528">
<property name="text">
<string>Landmark size. If zero, marker's length parameter is used.</string>
@@ -1883,7 +1883,7 @@ Show a yellow background when the number of odometry inliers goes under this thr
</property>
</widget>
</item>
<item row="7" column="0">
<item row="8" column="0">
<widget class="QDoubleSpinBox" name="doubleSpinBox_landmarkSize">
<property name="suffix">
<string> m</string>
@@ -1899,7 +1899,7 @@ Show a yellow background when the number of odometry inliers goes under this thr
</property>
</widget>
</item>
<item row="8" column="2">
<item row="9" column="2">
<widget class="QLabel" name="label_567">
<property name="text">
<string>Show IMU filtered gravity.</string>
@@ -1912,7 +1912,7 @@ Show a yellow background when the number of odometry inliers goes under this thr
</property>
</widget>
</item>
<item row="10" column="2">
<item row="11" column="2">
<widget class="QLabel" name="label_568">
<property name="text">
<string>Show IMU acceleration.</string>
@@ -1925,7 +1925,7 @@ Show a yellow background when the number of odometry inliers goes under this thr
</property>
</widget>
</item>
<item row="10" column="1">
<item row="11" column="1">
<widget class="QCheckBox" name="checkBox_showIMUAcc">
<property name="text">
<string/>
@@ -1935,7 +1935,7 @@ Show a yellow background when the number of odometry inliers goes under this thr
</property>
</widget>
</item>
<item row="8" column="0">
<item row="9" column="0">
<widget class="QCheckBox" name="checkBox_showIMUGravity">
<property name="text">
<string/>
@@ -1945,7 +1945,7 @@ Show a yellow background when the number of odometry inliers goes under this thr
</property>
</widget>
</item>
<item row="8" column="1">
<item row="9" column="1">
<widget class="QCheckBox" name="checkBox_showIMUGravity_odom">
<property name="text">
<string/>
@@ -1955,7 +1955,7 @@ Show a yellow background when the number of odometry inliers goes under this thr
</property>
</widget>
</item>
<item row="9" column="0">
<item row="10" column="0">
<widget class="QDoubleSpinBox" name="doubleSpinBox_lengthIMUGravity">
<property name="suffix">
<string> m</string>
@@ -1971,7 +1971,7 @@ Show a yellow background when the number of odometry inliers goes under this thr
</property>
</widget>
</item>
<item row="9" column="1">
<item row="10" column="1">
<widget class="QDoubleSpinBox" name="doubleSpinBox_lengthIMUGravity_odom">
<property name="suffix">
<string> m</string>
@@ -1987,7 +1987,7 @@ Show a yellow background when the number of odometry inliers goes under this thr
</property>
</widget>
</item>
<item row="9" column="2">
<item row="10" column="2">
<widget class="QLabel" name="label_569">
<property name="text">
<string>IMU filtered gravity length.</string>
@@ -2000,6 +2000,29 @@ Show a yellow background when the number of odometry inliers goes under this thr
</property>
</widget>
</item>
<item row="6" column="2">
<widget class="QLabel" name="label_572">
<property name="text">
<string>Show frames.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QCheckBox" name="checkBox_showFrames">
<property name="text">
<string/>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>