PostProcessingDialog.cpp
Go to the documentation of this file.
1 /*
2 Copyright (c) 2010-2016, Mathieu Labbe - IntRoLab - Universite de Sherbrooke
3 All rights reserved.
4 
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions are met:
7  * Redistributions of source code must retain the above copyright
8  notice, this list of conditions and the following disclaimer.
9  * Redistributions in binary form must reproduce the above copyright
10  notice, this list of conditions and the following disclaimer in the
11  documentation and/or other materials provided with the distribution.
12  * Neither the name of the Universite de Sherbrooke nor the
13  names of its contributors may be used to endorse or promote products
14  derived from this software without specific prior written permission.
15 
16 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
20 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27 
29 #include "ui_postProcessingDialog.h"
30 
31 #include <QPushButton>
32 #include <QMessageBox>
33 #include <rtabmap/core/Optimizer.h>
34 
35 namespace rtabmap {
36 
38  QDialog(parent)
39 {
40  _ui = new Ui_PostProcessingDialog();
41  _ui->setupUi(this);
42 
46  {
47  _ui->sba->setEnabled(false);
48  _ui->sba->setChecked(false);
49  }
50  else
51  {
53  {
54  _ui->comboBox_sbaType->setItemData(1, 0, Qt::UserRole - 1);
55  _ui->comboBox_sbaType->setCurrentIndex(0);
56  }
58  {
59  _ui->comboBox_sbaType->setItemData(0, 0, Qt::UserRole - 1);
60  _ui->comboBox_sbaType->setCurrentIndex(1);
61  }
63  {
64  _ui->comboBox_sbaType->setItemData(2, 0, Qt::UserRole - 1);
65  _ui->comboBox_sbaType->setCurrentIndex(1);
66  }
67  }
68 
70 
71  connect(_ui->buttonBox, SIGNAL(clicked(QAbstractButton *)), this, SLOT(closeDialog(QAbstractButton *)));
72 
73  connect(_ui->detectMoreLoopClosures, SIGNAL(clicked(bool)), this, SLOT(updateButtonBox()));
74  connect(_ui->refineNeighborLinks, SIGNAL(stateChanged(int)), this, SLOT(updateButtonBox()));
75  connect(_ui->refineLoopClosureLinks, SIGNAL(stateChanged(int)), this, SLOT(updateButtonBox()));
76  connect(_ui->sba, SIGNAL(clicked(bool)), this, SLOT(updateButtonBox()));
77  connect(_ui->buttonBox->button(QDialogButtonBox::RestoreDefaults), SIGNAL(clicked()), this, SLOT(restoreDefaults()));
78 
79  connect(_ui->detectMoreLoopClosures, SIGNAL(clicked(bool)), this, SIGNAL(configChanged()));
80  connect(_ui->clusterRadius, SIGNAL(valueChanged(double)), this, SIGNAL(configChanged()));
81  connect(_ui->clusterAngle, SIGNAL(valueChanged(double)), this, SIGNAL(configChanged()));
82  connect(_ui->iterations, SIGNAL(valueChanged(int)), this, SIGNAL(configChanged()));
83  connect(_ui->intraSession, SIGNAL(stateChanged(int)), this, SIGNAL(configChanged()));
84  connect(_ui->interSession, SIGNAL(stateChanged(int)), this, SIGNAL(configChanged()));
85  connect(_ui->refineNeighborLinks, SIGNAL(stateChanged(int)), this, SIGNAL(configChanged()));
86  connect(_ui->refineLoopClosureLinks, SIGNAL(stateChanged(int)), this, SIGNAL(configChanged()));
87 
88  connect(_ui->sba, SIGNAL(clicked(bool)), this, SIGNAL(configChanged()));
89  connect(_ui->sba_iterations, SIGNAL(valueChanged(int)), this, SIGNAL(configChanged()));
90  connect(_ui->comboBox_sbaType, SIGNAL(currentIndexChanged(int)), this, SIGNAL(configChanged()));
91  connect(_ui->comboBox_sbaType, SIGNAL(currentIndexChanged(int)), this, SLOT(updateVisibility()));
92  connect(_ui->sba_rematchFeatures, SIGNAL(stateChanged(int)), this, SIGNAL(configChanged()));
93 
95 }
96 
98 {
99  delete _ui;
100 }
101 
102 void PostProcessingDialog::closeDialog ( QAbstractButton * button )
103 {
104  UDEBUG("");
105 
106  QDialogButtonBox::ButtonRole role = _ui->buttonBox->buttonRole(button);
107  switch(role)
108  {
109  case QDialogButtonBox::RejectRole:
110  this->reject();
111  break;
112 
113  case QDialogButtonBox::AcceptRole:
114  if(validateForm())
115  {
116  this->accept();
117  }
118  break;
119 
120  default:
121  break;
122  }
123 }
124 
126 {
127  if(_ui->detectMoreLoopClosures->isChecked() && !this->intraSession() && !this->interSession())
128  {
129  QMessageBox::warning(this, tr("Configuration error"), tr("Intra-session and inter-session parameters cannot be both disabled at the same time. Please select one (or both)."));
130  return false;
131  }
132  return true;
133 }
134 
136 {
137  _ui->sba_variance->setVisible(_ui->comboBox_sbaType->currentIndex() == 0);
138  _ui->label_variance->setVisible(_ui->comboBox_sbaType->currentIndex() == 0);
139 }
140 
141 void PostProcessingDialog::saveSettings(QSettings & settings, const QString & group) const
142 {
143  if(!group.isEmpty())
144  {
145  settings.beginGroup(group);
146  }
147  settings.setValue("detect_more_lc", this->isDetectMoreLoopClosures());
148  settings.setValue("cluster_radius", this->clusterRadius());
149  settings.setValue("cluster_angle", this->clusterAngle());
150  settings.setValue("iterations", this->iterations());
151  settings.setValue("intra_session", this->intraSession());
152  settings.setValue("inter_session", this->interSession());
153  settings.setValue("refine_neigbors", this->isRefineNeighborLinks());
154  settings.setValue("refine_lc", this->isRefineLoopClosureLinks());
155  settings.setValue("sba", this->isSBA());
156  settings.setValue("sba_iterations", this->sbaIterations());
157  settings.setValue("sba_type", this->sbaType());
158  settings.setValue("sba_variance", this->sbaVariance());
159  settings.setValue("sba_rematch_features", this->sbaRematchFeatures());
160  if(!group.isEmpty())
161  {
162  settings.endGroup();
163  }
164 }
165 
166 void PostProcessingDialog::loadSettings(QSettings & settings, const QString & group)
167 {
168  if(!group.isEmpty())
169  {
170  settings.beginGroup(group);
171  }
172  this->setDetectMoreLoopClosures(settings.value("detect_more_lc", this->isDetectMoreLoopClosures()).toBool());
173  this->setClusterRadius(settings.value("cluster_radius", this->clusterRadius()).toDouble());
174  this->setClusterAngle(settings.value("cluster_angle", this->clusterAngle()).toDouble());
175  this->setIterations(settings.value("iterations", this->iterations()).toInt());
176  this->setIntraSession(settings.value("intra_session", this->intraSession()).toBool());
177  this->setInterSession(settings.value("inter_session", this->interSession()).toBool());
178  this->setRefineNeighborLinks(settings.value("refine_neigbors", this->isRefineNeighborLinks()).toBool());
179  this->setRefineLoopClosureLinks(settings.value("refine_lc", this->isRefineLoopClosureLinks()).toBool());
180  this->setSBA(settings.value("sba", this->isSBA()).toBool());
181  this->setSBAIterations(settings.value("sba_iterations", this->sbaIterations()).toInt());
182  this->setSBAType((Optimizer::Type)settings.value("sba_type", this->sbaType()).toInt());
183  this->setSBAVariance(settings.value("sba_variance", this->sbaVariance()).toDouble());
184  this->setSBARematchFeatures(settings.value("sba_rematch_features", this->sbaRematchFeatures()).toBool());
185 
186  if(!group.isEmpty())
187  {
188  settings.endGroup();
189  }
190 }
191 
193 {
195  setClusterRadius(1);
196  setClusterAngle(30);
197  setIterations(5);
198  setIntraSession(true);
199  setInterSession(true);
200  setRefineNeighborLinks(false);
202  setSBA(false);
203  setSBAIterations(20);
206  {
208  {
209  sbaType = Optimizer::kTypeCVSBA;
210  }
212  {
213  sbaType = Optimizer::kTypeCeres;
214  }
215  }
216  setSBAType(sbaType);
217  setSBAVariance(1.0);
218  setSBARematchFeatures(true);
219 }
220 
222 {
223  _ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(
225 }
226 
228 {
229  return _ui->detectMoreLoopClosures->isChecked();
230 }
231 
233 {
234  return _ui->clusterRadius->value();
235 }
236 
238 {
239  return _ui->clusterAngle->value();
240 }
241 
243 {
244  return _ui->iterations->value();
245 }
246 
248 {
249  return _ui->intraSession->isChecked();
250 }
251 
253 {
254  return _ui->interSession->isChecked();
255 }
256 
258 {
259  return _ui->refineNeighborLinks->isChecked();
260 }
261 
263 {
264  return _ui->refineLoopClosureLinks->isChecked();
265 }
266 
268 {
269  return _ui->sba->isEnabled() && _ui->sba->isChecked();
270 }
271 
273 {
274  return _ui->sba_iterations->value();
275 }
277 {
278  return _ui->sba_variance->value();
279 }
281 {
282  return _ui->comboBox_sbaType->currentIndex()==2?Optimizer::kTypeCeres:_ui->comboBox_sbaType->currentIndex()==1?Optimizer::kTypeCVSBA:Optimizer::kTypeG2O;
283 }
285 {
286  return _ui->sba_rematchFeatures->isChecked();
287 }
288 
289 //setters
291 {
292  _ui->detectMoreLoopClosures->setChecked(on);
293 }
295 {
296  _ui->clusterRadius->setValue(radius);
297 }
299 {
300  _ui->clusterAngle->setValue(angle);
301 }
303 {
304  _ui->iterations->setValue(iterations);
305 }
307 {
308  _ui->intraSession->setChecked(enabled);
309 }
311 {
312  _ui->interSession->setChecked(enabled);
313 }
315 {
316  _ui->refineNeighborLinks->setChecked(on);
317 }
319 {
320  _ui->refineLoopClosureLinks->setChecked(on);
321 }
323 {
324  _ui->sba->setChecked((
328 }
330 {
331  _ui->sba_iterations->setValue(iterations);
332 }
334 {
335  _ui->sba_variance->setValue(variance);
336 }
338 {
339  if(type == Optimizer::kTypeCeres)
340  {
341  _ui->comboBox_sbaType->setCurrentIndex(2);
342  }
343  else if(type == Optimizer::kTypeCVSBA)
344  {
345  _ui->comboBox_sbaType->setCurrentIndex(1);
346  }
347  else
348  {
349  _ui->comboBox_sbaType->setCurrentIndex(0);
350  }
351 }
353 {
354  _ui->sba_rematchFeatures->setChecked(value);
355 }
356 
357 
358 }
void loadSettings(QSettings &settings, const QString &group="")
void closeDialog(QAbstractButton *button)
GLM_FUNC_DECL T angle(detail::tquat< T, P > const &x)
void saveSettings(QSettings &settings, const QString &group="") const
Ui_PostProcessingDialog * _ui
static bool isAvailable(Optimizer::Type type)
Definition: Optimizer.cpp:47
#define UDEBUG(...)
void setSBAType(Optimizer::Type type)


rtabmap
Author(s): Mathieu Labbe
autogenerated on Mon Jan 23 2023 03:37:29