CloudViewer: fixed opengl not refreshed on update (VTK9). Fixed File Explorer hanging (Qt 5.12). Fixed backup database not deleted after a recovery.

This commit is contained in:
matlabbe
2021-06-18 12:43:08 -04:00
parent 8d2dbe32c4
commit d75cc04ad2
10 changed files with 88 additions and 67 deletions

View File

@@ -50,6 +50,10 @@ int main(int argc, char* argv[])
ULogger::setType(ULogger::kTypeConsole); ULogger::setType(ULogger::kTypeConsole);
ULogger::setLevel(ULogger::kWarning); ULogger::setLevel(ULogger::kWarning);
#ifdef WIN32
CoInitialize(nullptr);
#endif
#ifdef RTABMAP_PYTHON #ifdef RTABMAP_PYTHON
PythonInterface python; // Make sure we initialize python in main thread PythonInterface python; // Make sure we initialize python in main thread
#endif #endif

View File

@@ -151,44 +151,46 @@ bool databaseRecovery(
bool rgbdEnabled = Parameters::defaultRGBDEnabled(); bool rgbdEnabled = Parameters::defaultRGBDEnabled();
Parameters::parse(parameters, Parameters::kRGBDEnabled(), rgbdEnabled); Parameters::parse(parameters, Parameters::kRGBDEnabled(), rgbdEnabled);
bool odometryIgnored = !rgbdEnabled; bool odometryIgnored = !rgbdEnabled;
{
DBReader dbReader(backupPath, 0, odometryIgnored); DBReader dbReader(backupPath, 0, odometryIgnored);
dbReader.init(); dbReader.init();
CameraInfo info; CameraInfo info;
SensorData data = dbReader.takeImage(&info); SensorData data = dbReader.takeImage(&info);
int processed = 0; int processed = 0;
if(progressState) if (progressState)
progressState->callback(uFormat("Recovering data of \"%s\"...", backupPath.c_str())); progressState->callback(uFormat("Recovering data of \"%s\"...", backupPath.c_str()));
while(data.isValid() && (progressState==0 || !progressState->isCanceled())) while (data.isValid() && (progressState == 0 || !progressState->isCanceled()))
{ {
std::string status; std::string status;
if(!odometryIgnored && info.odomPose.isNull()) if (!odometryIgnored && info.odomPose.isNull())
{ {
status = uFormat("Skipping node %d as it doesn't have odometry pose set.", data.id()); status = uFormat("Skipping node %d as it doesn't have odometry pose set.", data.id());
} }
else else
{ {
if(!odometryIgnored && !info.odomCovariance.empty() && info.odomCovariance.at<double>(0,0)>=9999) if (!odometryIgnored && !info.odomCovariance.empty() && info.odomCovariance.at<double>(0, 0) >= 9999)
{ {
status = uFormat("High variance detected, triggering a new map..."); status = uFormat("High variance detected, triggering a new map...");
rtabmap.triggerNewMap(); rtabmap.triggerNewMap();
} }
if(!rtabmap.process(data, info.odomPose, info.odomCovariance, info.odomVelocity)) if (!rtabmap.process(data, info.odomPose, info.odomCovariance, info.odomVelocity))
{ {
status = uFormat("Failed processing node %d.", data.id()); status = uFormat("Failed processing node %d.", data.id());
} }
} }
if(status.empty()) if (status.empty())
{ {
if(progressState) if (progressState)
progressState->callback(status); progressState->callback(status);
} }
data = dbReader.takeImage(&info); data = dbReader.takeImage(&info);
if(progressState) if (progressState)
progressState->callback(uFormat("Processed %d/%d nodes...", ++processed, (int)ids.size())); progressState->callback(uFormat("Processed %d/%d nodes...", ++processed, (int)ids.size()));
} }
}
if(progressState) if(progressState)
{ {

View File

@@ -86,6 +86,8 @@ public:
void saveSettings(QSettings & settings, const QString & group = "") const; void saveSettings(QSettings & settings, const QString & group = "") const;
void loadSettings(QSettings & settings, const QString & group = ""); void loadSettings(QSettings & settings, const QString & group = "");
void refreshView();
bool updateCloudPose( bool updateCloudPose(
const std::string & id, const std::string & id,
const Transform & pose); //including mesh const Transform & pose); //including mesh

View File

@@ -181,7 +181,7 @@ void CameraViewer::showImage(const rtabmap::SensorData & data)
(showScanCheckbox_->isEnabled() && showScanCheckbox_->isChecked())); (showScanCheckbox_->isEnabled() && showScanCheckbox_->isChecked()));
if(cloudView_->isVisible()) if(cloudView_->isVisible())
{ {
cloudView_->update(); cloudView_->refreshView();
} }
if(cloudView_->getAddedClouds().contains("cloud")) if(cloudView_->getAddedClouds().contains("cloud"))
{ {

View File

@@ -521,7 +521,16 @@ void CloudViewer::loadSettings(QSettings & settings, const QString & group)
settings.endGroup(); settings.endGroup();
} }
this->refreshView();
}
void CloudViewer::refreshView()
{
#if VTK_MAJOR_VERSION > 8
this->renderWindow()->Render();
#else
this->update(); this->update();
#endif
} }
bool CloudViewer::updateCloudPose( bool CloudViewer::updateCloudPose(
@@ -2288,7 +2297,7 @@ void CloudViewer::clearTrajectory()
{ {
_trajectory->clear(); _trajectory->clear();
_visualizer->removeShape("trajectory"); _visualizer->removeShape("trajectory");
this->update(); this->refreshView();
} }
bool CloudViewer::isCameraAxisShown() const bool CloudViewer::isCameraAxisShown() const
@@ -2306,7 +2315,7 @@ void CloudViewer::setCameraAxisShown(bool shown)
{ {
this->addOrUpdateCoordinate("reference", Transform::getIdentity(), 0.2); this->addOrUpdateCoordinate("reference", Transform::getIdentity(), 0.2);
} }
this->update(); this->refreshView();
_aShowCameraAxis->setChecked(shown); _aShowCameraAxis->setChecked(shown);
} }
@@ -2355,7 +2364,7 @@ void CloudViewer::setFrustumShown(bool shown)
this->removeLine(*iter); this->removeLine(*iter);
} }
} }
this->update(); this->refreshView();
} }
_aShowFrustum->setChecked(shown); _aShowFrustum->setChecked(shown);
} }
@@ -2375,7 +2384,7 @@ void CloudViewer::setFrustumColor(QColor value)
{ {
_visualizer->setShapeRenderingProperties(pcl::visualization::PCL_VISUALIZER_COLOR, value.redF(), value.greenF(), value.blueF(), iter.key()); _visualizer->setShapeRenderingProperties(pcl::visualization::PCL_VISUALIZER_COLOR, value.redF(), value.greenF(), value.blueF(), iter.key());
} }
this->update(); this->refreshView();
_frustumColor = value; _frustumColor = value;
} }
@@ -2604,7 +2613,7 @@ void CloudViewer::setBackfaceCulling(bool enabled, bool frontfaceCulling)
} }
} }
#endif #endif
this->update(); this->refreshView();
} }
void CloudViewer::setPolygonPicking(bool enabled) void CloudViewer::setPolygonPicking(bool enabled)
@@ -2669,7 +2678,7 @@ void CloudViewer::setEDLShading(bool on)
glrenderer->SetPass(NULL); glrenderer->SetPass(NULL);
} }
this->update(); this->refreshView();
#else #else
if(on) if(on)
{ {
@@ -2697,7 +2706,7 @@ void CloudViewer::setLighting(bool on)
} }
} }
#endif #endif
this->update(); this->refreshView();
} }
void CloudViewer::setShading(bool on) void CloudViewer::setShading(bool on)
@@ -2719,7 +2728,7 @@ void CloudViewer::setShading(bool on)
} }
} }
#endif #endif
this->update(); this->refreshView();
} }
void CloudViewer::setEdgeVisibility(bool visible) void CloudViewer::setEdgeVisibility(bool visible)
@@ -2741,7 +2750,7 @@ void CloudViewer::setEdgeVisibility(bool visible)
} }
} }
#endif #endif
this->update(); this->refreshView();
} }
void CloudViewer::setInteractorLayer(int layer) void CloudViewer::setInteractorLayer(int layer)
@@ -3164,7 +3173,7 @@ void CloudViewer::setCameraOrtho(bool enabled)
if(interactor) if(interactor)
{ {
interactor->setOrthoMode(enabled); interactor->setOrthoMode(enabled);
this->update(); this->refreshView();
} }
_aCameraOrtho->setChecked(enabled); _aCameraOrtho->setChecked(enabled);
} }
@@ -3724,7 +3733,7 @@ void CloudViewer::handleAction(QAction * a)
this->removeGrid(); this->removeGrid();
} }
this->update(); this->refreshView();
} }
else if(a == _aSetGridCellCount) else if(a == _aSetGridCellCount)
{ {
@@ -3747,7 +3756,7 @@ void CloudViewer::handleAction(QAction * a)
else if(a == _aShowNormals) else if(a == _aShowNormals)
{ {
this->setNormalsShown(_aShowNormals->isChecked()); this->setNormalsShown(_aShowNormals->isChecked());
this->update(); this->refreshView();
} }
else if(a == _aSetNormalsStep) else if(a == _aSetNormalsStep)
{ {
@@ -3791,7 +3800,7 @@ void CloudViewer::handleAction(QAction * a)
if(color.isValid()) if(color.isValid())
{ {
this->setDefaultBackgroundColor(color); this->setDefaultBackgroundColor(color);
this->update(); this->refreshView();
} }
} }
else if(a == _aSetRenderingRate) else if(a == _aSetRenderingRate)
@@ -3807,7 +3816,7 @@ void CloudViewer::handleAction(QAction * a)
{ {
if(_aLockViewZ->isChecked()) if(_aLockViewZ->isChecked())
{ {
this->update(); this->refreshView();
} }
} }
else if(a == _aCameraOrtho) else if(a == _aCameraOrtho)

View File

@@ -1105,13 +1105,13 @@ bool DatabaseViewer::closeDatabase()
sliderBValueChanged(0); sliderBValueChanged(0);
constraintsViewer_->clear(); constraintsViewer_->clear();
constraintsViewer_->update(); constraintsViewer_->refreshView();
cloudViewer_->clear(); cloudViewer_->clear();
cloudViewer_->update(); cloudViewer_->refreshView();
occupancyGridViewer_->clear(); occupancyGridViewer_->clear();
occupancyGridViewer_->update(); occupancyGridViewer_->refreshView();
ui_->graphViewer->clearAll(); ui_->graphViewer->clearAll();
ui_->label_loopClosures->clear(); ui_->label_loopClosures->clear();
@@ -1126,7 +1126,7 @@ bool DatabaseViewer::closeDatabase()
ui_->graphicsView_stereo->clear(); ui_->graphicsView_stereo->clear();
stereoViewer_->clear(); stereoViewer_->clear();
stereoViewer_->update(); stereoViewer_->refreshView();
ui_->toolBox_statistics->clear(); ui_->toolBox_statistics->clear();
} }
@@ -5040,7 +5040,7 @@ void DatabaseViewer::update(int value,
#endif #endif
} }
} }
cloudViewer_->updateCameraTargetPosition(pose); cloudViewer_->updateCameraTargetPosition(pose);
cloudViewer_->clearTrajectory(); cloudViewer_->clearTrajectory();
cloudViewer_->refreshView(); cloudViewer_->refreshView();
} }
@@ -5182,7 +5182,7 @@ void DatabaseViewer::update(int value,
ui_->lineEdit_covariance->clear(); ui_->lineEdit_covariance->clear();
ui_->label_type->clear(); ui_->label_type->clear();
ui_->label_type_name->clear(); ui_->label_type_name->clear();
ui_->checkBox_showOptimized->setEnabled(false); ui_->checkBox_showOptimized->setEnabled(false);
} }
constraintsViewer_->refreshView(); constraintsViewer_->refreshView();
@@ -5311,7 +5311,7 @@ void DatabaseViewer::updateStereo(const SensorData * data)
UINFO("correspondences = %d/%d (%f) (time kpt=%fs stereo=%fs)", UINFO("correspondences = %d/%d (%f) (time kpt=%fs stereo=%fs)",
(int)cloud->size(), (int)leftCorners.size(), float(cloud->size())/float(leftCorners.size()), timeKpt, timeStereo); (int)cloud->size(), (int)leftCorners.size(), float(cloud->size())/float(leftCorners.size()), timeKpt, timeStereo);
stereoViewer_->updateCameraTargetPosition(Transform::getIdentity()); stereoViewer_->updateCameraTargetPosition(Transform::getIdentity());
stereoViewer_->addCloud("stereo", cloud); stereoViewer_->addCloud("stereo", cloud);
stereoViewer_->refreshView(); stereoViewer_->refreshView();
@@ -6231,7 +6231,7 @@ void DatabaseViewer::updateConstraintView(
} }
#endif #endif
constraintsViewer_->clearTrajectory(); constraintsViewer_->clearTrajectory();
constraintsViewer_->refreshView(); constraintsViewer_->refreshView();
} }
@@ -6561,7 +6561,7 @@ void DatabaseViewer::sliderIterationsValueChanged(int value)
ui_->graphViewer->updateMap(map8U, cellSize, xMin, yMin); ui_->graphViewer->updateMap(map8U, cellSize, xMin, yMin);
} }
if(ui_->dockWidget_occupancyGridView->isVisible() && ui_->checkBox_grid_2d->isChecked()) if(ui_->dockWidget_occupancyGridView->isVisible() && ui_->checkBox_grid_2d->isChecked())
{ {
occupancyGridViewer_->addOccupancyGridMap(map8U, cellSize, xMin, yMin, 1.0f); occupancyGridViewer_->addOccupancyGridMap(map8U, cellSize, xMin, yMin, 1.0f);
occupancyGridViewer_->refreshView(); occupancyGridViewer_->refreshView();
} }
@@ -6684,7 +6684,7 @@ void DatabaseViewer::sliderIterationsValueChanged(int value)
Transform::getIdentity(), Transform::getIdentity(),
QColor(ui_->lineEdit_emptyColor->text())); QColor(ui_->lineEdit_emptyColor->text()));
occupancyGridViewer_->setCloudPointSize("emptyCellsXYZ", 5); occupancyGridViewer_->setCloudPointSize("emptyCellsXYZ", 5);
occupancyGridViewer_->setCloudOpacity("emptyCellsXYZ", 0.5); occupancyGridViewer_->setCloudOpacity("emptyCellsXYZ", 0.5);
} }
occupancyGridViewer_->refreshView(); occupancyGridViewer_->refreshView();
} }
@@ -7029,7 +7029,7 @@ void DatabaseViewer::updateGrid()
{ {
if(sender() == ui_->checkBox_grid_2d && !ui_->checkBox_grid_2d->isChecked()) if(sender() == ui_->checkBox_grid_2d && !ui_->checkBox_grid_2d->isChecked())
{ {
//just remove map in occupancy grid view //just remove map in occupancy grid view
occupancyGridViewer_->removeOccupancyGridMap(); occupancyGridViewer_->removeOccupancyGridMap();
occupancyGridViewer_->refreshView(); occupancyGridViewer_->refreshView();
} }
@@ -7139,7 +7139,7 @@ void DatabaseViewer::updateOctomapView()
occupancyGridViewer_->setCloudOpacity("octomap_empty", 0.5); occupancyGridViewer_->setCloudOpacity("octomap_empty", 0.5);
occupancyGridViewer_->setCloudPointSize("octomap_empty", 5); occupancyGridViewer_->setCloudPointSize("octomap_empty", 5);
} }
} }
} }
occupancyGridViewer_->refreshView(); occupancyGridViewer_->refreshView();
} }
@@ -8283,7 +8283,7 @@ void DatabaseViewer::updateLoopClosuresSlider(int from, int to)
} }
else else
{ {
ui_->horizontalSlider_loops->setEnabled(false); ui_->horizontalSlider_loops->setEnabled(false);
constraintsViewer_->removeAllClouds(); constraintsViewer_->removeAllClouds();
constraintsViewer_->refreshView(); constraintsViewer_->refreshView();
updateConstraintButtons(); updateConstraintButtons();

View File

@@ -1431,7 +1431,7 @@ void ExportCloudsDialog::viewClouds(
_progressDialog->appendText(tr("Viewing the cloud %1 (%2 points)... done.").arg(iter->first).arg(iter->second->size())); _progressDialog->appendText(tr("Viewing the cloud %1 (%2 points)... done.").arg(iter->first).arg(iter->second->size()));
} }
} }
viewer->update(); viewer->refreshView();
} }
else else
{ {

View File

@@ -140,7 +140,7 @@ void LoopClosureViewer::updateView(const Transform & transform, const Parameters
{ {
UERROR("loop transform is null !?!?"); UERROR("loop transform is null !?!?");
ui_->cloudViewerTransform->removeAllClouds(); ui_->cloudViewerTransform->removeAllClouds();
} }
ui_->cloudViewerTransform->refreshView(); ui_->cloudViewerTransform->refreshView();
} }
} }

View File

@@ -1544,7 +1544,7 @@ void MainWindow::processOdometry(const rtabmap::OdometryEvent & odom, bool dataI
_cloudViewer->updateCameraTargetPosition(_odometryCorrection*odom.pose()); _cloudViewer->updateCameraTargetPosition(_odometryCorrection*odom.pose());
UDEBUG("Time Update Pose: %fs", time.ticks()); UDEBUG("Time Update Pose: %fs", time.ticks());
} }
_cloudViewer->update(); _cloudViewer->refreshView();
if(_ui->graphicsView_graphView->isVisible()) if(_ui->graphicsView_graphView->isVisible())
{ {
@@ -3275,7 +3275,7 @@ void MainWindow::updateMapCloud(
} }
UDEBUG(""); UDEBUG("");
_cloudViewer->update(); _cloudViewer->refreshView();
UDEBUG(""); UDEBUG("");
} }
@@ -4189,7 +4189,7 @@ void MainWindow::updateNodeVisibility(int nodeId, bool visible)
} }
} }
_cloudViewer->update(); _cloudViewer->refreshView();
} }
} }

View File

@@ -36,6 +36,10 @@ int main(int argc, char * argv[])
ULogger::setType(ULogger::kTypeConsole); ULogger::setType(ULogger::kTypeConsole);
ULogger::setLevel(ULogger::kInfo); ULogger::setLevel(ULogger::kInfo);
#ifdef WIN32
CoInitialize(nullptr);
#endif
#if VTK_MAJOR_VERSION >= 8 #if VTK_MAJOR_VERSION >= 8
vtkObject::GlobalWarningDisplayOff(); vtkObject::GlobalWarningDisplayOff();
#endif #endif