SpinBoxToPose.h
Go to the documentation of this file.
1 /*
2  * This file is part of ArmarX.
3  *
4  * ArmarX is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation.
7  *
8  * ArmarX is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * @package RobotAPI::ArmarXObjects::NJointControllerGuiPluginUtility
17  * @author Raphael Grimm ( raphael dot grimm at kit dot edu )
18  * @date 2020
19  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20  * GNU General Public License
21  */
22 
23 #pragma once
24 
25 #include <SimoxUtility/math/convert.h>
26 
27 #include "SpinBoxToVector.h"
28 
29 namespace armarx
30 {
31  template <class Qwid = QDoubleSpinBox>
33  {
34  //set
35  public:
36  void
37  setPos(const Eigen::Vector3f& pos)
38  {
39  _xyz.set(pos);
40  }
41 
42  void
43  setOri(const Eigen::Vector3f& rpy)
44  {
45  _rpy.set(rpy);
46  }
47 
48  void
50  {
51  setOri(simox::math::quat_to_rpy(q));
52  }
53 
54  void
56  {
57  setOri(simox::math::mat3f_to_rpy(m));
58  }
59 
60  void
61  setPose(const auto& pos, const auto& ori)
62  {
63  setPos(pos);
64  setOri(ori);
65  }
66 
67  void
69  {
70  setPos(simox::math::mat4f_to_pos(m));
71  setOri(simox::math::mat4f_to_rpy(m));
72  }
73 
74  //get
75  public:
76  Eigen::Vector3f
77  getPos() const
78  {
79  return _xyz.template get<Eigen::Vector3f>();
80  }
81 
82  Eigen::Vector3f
83  getRPY() const
84  {
85  return _rpy.template get<Eigen::Vector3f>();
86  }
87 
89  getQuat() const
90  {
91  return simox::math::rpy_to_quat(getRPY());
92  }
93 
95  getMat3() const
96  {
97  return simox::math::rpy_to_mat3f(getRPY());
98  }
99 
101  getMat4() const
102  {
103  return simox::math::pos_rpy_to_mat4f(getPos(), getRPY());
104  }
105 
106  //set up
107  public:
108  void
109  setXYZWidgets(Qwid* x, Qwid* y, Qwid* z)
110  {
111  _xyz.addWidget(x);
112  _xyz.addWidget(y);
113  _xyz.addWidget(z);
114  }
115 
116  void
117  setRPYWidgets(Qwid* r, Qwid* p, Qwid* y)
118  {
119  _rpy.addWidget(r);
120  _rpy.addWidget(p);
121  _rpy.addWidget(y);
122  }
123 
126  {
127  return _xyz;
128  }
129 
132  {
133  return _rpy;
134  }
135 
136  void
138  {
139  _xyz.setMinMax(-100'000, 100'000);
140  _rpy.setMinMax(-9, 9);
141  }
142 
143  private:
146  };
147 } // namespace armarx
armarx::SpinBoxToPose::setPose
void setPose(const Eigen::Matrix4f &m)
Definition: SpinBoxToPose.h:68
SpinBoxToVector.h
armarx::SpinBoxToPose::setXYZWidgets
void setXYZWidgets(Qwid *x, Qwid *y, Qwid *z)
Definition: SpinBoxToPose.h:109
GfxTL::Matrix4f
MatrixXX< 4, 4, float > Matrix4f
Definition: MatrixXX.h:650
armarx::SpinBoxToPose::setRPYWidgets
void setRPYWidgets(Qwid *r, Qwid *p, Qwid *y)
Definition: SpinBoxToPose.h:117
armarx::SpinBoxToPose::getMat4
Eigen::Matrix4f getMat4() const
Definition: SpinBoxToPose.h:101
armarx::SpinBoxToPose::rpyWidgets
SpinBoxToVector< Qwid, 3 > & rpyWidgets()
Definition: SpinBoxToPose.h:131
armarx::SpinBoxToPose::getQuat
Eigen::Quaternionf getQuat() const
Definition: SpinBoxToPose.h:89
armarx::SpinBoxToPose::setOri
void setOri(const Eigen::Matrix3f &m)
Definition: SpinBoxToPose.h:55
armarx::SpinBoxToPose::getRPY
Eigen::Vector3f getRPY() const
Definition: SpinBoxToPose.h:83
armarx::SpinBoxToVector
Definition: SpinBoxToVector.h:41
armarx::SpinBoxToPose::xyzWidgets
SpinBoxToVector< Qwid, 3 > & xyzWidgets()
Definition: SpinBoxToPose.h:125
Eigen::Quaternionf
Quaternion< float, 0 > Quaternionf
Definition: EigenForwardDeclarations.h:61
armarx::SpinBoxToPose::getPos
Eigen::Vector3f getPos() const
Definition: SpinBoxToPose.h:77
q
#define q
armarx::SpinBoxToPose::setOri
void setOri(const Eigen::Quaternionf &q)
Definition: SpinBoxToPose.h:49
armarx::SpinBoxToPose::getMat3
Eigen::Matrix3f getMat3() const
Definition: SpinBoxToPose.h:95
armarx::Quaternion< float, 0 >
armarx::SpinBoxToPose::setDefaultLimits
void setDefaultLimits()
Definition: SpinBoxToPose.h:137
armarx::SpinBoxToPose
Definition: SpinBoxToPose.h:32
armarx::SpinBoxToPose::setPos
void setPos(const Eigen::Vector3f &pos)
Definition: SpinBoxToPose.h:37
GfxTL::Matrix3f
MatrixXX< 3, 3, float > Matrix3f
Definition: MatrixXX.h:649
armarx::SpinBoxToPose::setOri
void setOri(const Eigen::Vector3f &rpy)
Definition: SpinBoxToPose.h:43
armarx::SpinBoxToPose::setPose
void setPose(const auto &pos, const auto &ori)
Definition: SpinBoxToPose.h:61
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:27