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  _ui->linear_sigma->setValue(linearSigma);
52  _ui->angular_sigma->setValue(angularSigma);
53 
54  connect(_ui->checkBox_radians, SIGNAL(stateChanged(int)), this, SLOT(switchUnits()));
55  _ui->checkBox_radians->setChecked(false);
56 }
57 
59 {
60  delete _ui;
61 }
62 
64 {
65  double conversion = 180.0/M_PI;
66  if(_ui->checkBox_radians->isChecked())
67  {
68  conversion = M_PI/180.0;
69  }
70  QVector<QDoubleSpinBox*> boxes;
71  boxes.push_back(_ui->roll);
72  boxes.push_back(_ui->pitch);
73  boxes.push_back(_ui->yaw);
74  boxes.push_back(_ui->angular_sigma);
75  for(int i=0; i<boxes.size(); ++i)
76  {
77  double value = boxes[i]->value()*conversion;
78  if(_ui->checkBox_radians->isChecked())
79  {
80  if(boxes[i]!=_ui->angular_sigma)
81  {
82  boxes[i]->setMinimum(-M_PI);
83  }
84  boxes[i]->setMaximum(M_PI);
85  boxes[i]->setSuffix(" rad");
86  boxes[i]->setSingleStep(0.01);
87  }
88  else
89  {
90  if(boxes[i]!=_ui->angular_sigma)
91  {
92  boxes[i]->setMinimum(-180);
93  }
94  boxes[i]->setMaximum(180);
95  boxes[i]->setSuffix(" deg");
96  boxes[i]->setSingleStep(1);
97  }
98  boxes[i]->setValue(value);
99  }
100 }
101 
103 {
104  double conversion = 1.0f;
105  if(!_ui->checkBox_radians->isChecked())
106  {
107  conversion = M_PI/180.0;
108  }
109  return Transform(_ui->x->value(), _ui->y->value(), _ui->z->value(), _ui->roll->value()*conversion, _ui->pitch->value()*conversion, _ui->yaw->value()*conversion);
110 }
111 
113 {
114  return _ui->linear_sigma->value();
115 }
117 {
118  double conversion = 1.0f;
119  if(!_ui->checkBox_radians->isChecked())
120  {
121  conversion = M_PI/180.0;
122  }
123  return _ui->angular_sigma->value()*conversion;
124 }
125 
126 }
GLM_FUNC_DECL T roll(detail::tquat< T, P > const &x)
EditConstraintDialog(const Transform &constraint, double linearSigma=0, double angularSigma=0, QWidget *parent=0)
GLM_FUNC_DECL T pitch(detail::tquat< T, P > const &x)
#define M_PI
Ui_EditConstraintDialog * _ui
GLM_FUNC_DECL T yaw(detail::tquat< T, P > const &x)
void getTranslationAndEulerAngles(float &x, float &y, float &z, float &roll, float &pitch, float &yaw) const
Definition: Transform.cpp:227


rtabmap
Author(s): Mathieu Labbe
autogenerated on Mon Dec 14 2020 03:34:58