EditConstraintDialog.cpp
Go to the documentation of this file.
1 /*
2 Copyright (c) 2010-2019, 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_editConstraintDialog.h"
30 
31 #ifndef M_PI
32 #define M_PI 3.14159265358979323846
33 #endif
34 
35 namespace rtabmap {
36 
37 EditConstraintDialog::EditConstraintDialog(const Transform & constraint, double linearSigma, double angularSigma, QWidget * parent) :
38  QDialog(parent)
39 {
40  _ui = new Ui_EditConstraintDialog();
41  _ui->setupUi(this);
42 
43  float x,y,z,roll,pitch,yaw;
44  constraint.getTranslationAndEulerAngles(x, y, z, roll, pitch, yaw);
45  _ui->x->setValue(x);
46  _ui->y->setValue(y);
47  _ui->z->setValue(z);
48  _ui->roll->setValue(roll);
49  _ui->pitch->setValue(pitch);
50  _ui->yaw->setValue(yaw);
51 
52  _ui->checkBox_radians->setChecked(true);
53  _ui->linear_sigma->setValue(linearSigma);
54  _ui->angular_sigma->setValue(angularSigma);
55 
56  connect(_ui->checkBox_radians, SIGNAL(stateChanged(int)), this, SLOT(switchUnits()));
57 }
58 
60 {
61  delete _ui;
62 }
63 
65 {
66  double conversion = 180.0/M_PI;
67  if(_ui->checkBox_radians->isChecked())
68  {
69  conversion = M_PI/180.0;
70  }
71  QVector<QDoubleSpinBox*> boxes;
72  boxes.push_back(_ui->roll);
73  boxes.push_back(_ui->pitch);
74  boxes.push_back(_ui->yaw);
75  boxes.push_back(_ui->angular_sigma);
76  for(int i=0; i<boxes.size(); ++i)
77  {
78  double value = boxes[i]->value()*conversion;
79  if(_ui->checkBox_radians->isChecked())
80  {
81  if(boxes[i]!=_ui->angular_sigma)
82  {
83  boxes[i]->setMinimum(-M_PI);
84  }
85  boxes[i]->setMaximum(M_PI);
86  boxes[i]->setSuffix(" rad");
87  boxes[i]->setSingleStep(0.01);
88  }
89  else
90  {
91  if(boxes[i]!=_ui->angular_sigma)
92  {
93  boxes[i]->setMinimum(-180);
94  }
95  boxes[i]->setMaximum(180);
96  boxes[i]->setSuffix(" deg");
97  boxes[i]->setSingleStep(1);
98  }
99  boxes[i]->setValue(value);
100  }
101 }
102 
104 {
105  double conversion = 1.0f;
106  if(!_ui->checkBox_radians->isChecked())
107  {
108  conversion = M_PI/180.0;
109  }
110  return Transform(_ui->x->value(), _ui->y->value(), _ui->z->value(), _ui->roll->value()*conversion, _ui->pitch->value()*conversion, _ui->yaw->value()*conversion);
111 }
112 
114 {
115  return _ui->linear_sigma->value()*_ui->linear_sigma->value();
116 }
118 {
119  double conversion = 1.0f;
120  if(!_ui->checkBox_radians->isChecked())
121  {
122  conversion = M_PI/180.0;
123  }
124  double value = _ui->angular_sigma->value()*conversion;
125  return value*value;
126 }
127 
128 }
rtabmap::EditConstraintDialog::_ui
Ui_EditConstraintDialog * _ui
Definition: EditConstraintDialog.h:56
glm::yaw
GLM_FUNC_DECL T yaw(detail::tquat< T, P > const &x)
rtabmap::EditConstraintDialog::~EditConstraintDialog
virtual ~EditConstraintDialog()
Definition: EditConstraintDialog.cpp:59
rtabmap::EditConstraintDialog::getLinearVariance
double getLinearVariance() const
Definition: EditConstraintDialog.cpp:113
y
Matrix3f y
rtabmap::EditConstraintDialog::switchUnits
void switchUnits()
Definition: EditConstraintDialog.cpp:64
rtabmap::Transform::getTranslationAndEulerAngles
void getTranslationAndEulerAngles(float &x, float &y, float &z, float &roll, float &pitch, float &yaw) const
Definition: Transform.cpp:258
rtabmap::EditConstraintDialog::getAngularVariance
double getAngularVariance() const
Definition: EditConstraintDialog.cpp:117
z
z
x
x
rtabmap::EditConstraintDialog::getTransform
Transform getTransform() const
Definition: EditConstraintDialog.cpp:103
glm::pitch
GLM_FUNC_DECL T pitch(detail::tquat< T, P > const &x)
rtabmap::Transform
Definition: Transform.h:41
M_PI
#define M_PI
Definition: EditConstraintDialog.cpp:32
rtabmap::EditConstraintDialog::EditConstraintDialog
EditConstraintDialog(const Transform &constraint, double linearSigma=1, double angularSigma=1, QWidget *parent=0)
Definition: EditConstraintDialog.cpp:37
rtabmap
Definition: CameraARCore.cpp:35
value
value
i
int i
glm::roll
GLM_FUNC_DECL T roll(detail::tquat< T, P > const &x)
EditConstraintDialog.h


rtabmap
Author(s): Mathieu Labbe
autogenerated on Thu Jul 25 2024 02:50:09