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
29namespace 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
55 setOri(const Eigen::Matrix3f& m)
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
68 setPose(const Eigen::Matrix4f& m)
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
94 Eigen::Matrix3f
95 getMat3() const
96 {
97 return simox::math::rpy_to_mat3f(getRPY());
98 }
99
100 Eigen::Matrix4f
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
void setPose(const auto &pos, const auto &ori)
void setPos(const Eigen::Vector3f &pos)
Eigen::Vector3f getPos() const
void setOri(const Eigen::Quaternionf &q)
void setRPYWidgets(Qwid *r, Qwid *p, Qwid *y)
void setOri(const Eigen::Vector3f &rpy)
Eigen::Quaternionf getQuat() const
SpinBoxToVector< Qwid, 3 > & xyzWidgets()
Eigen::Vector3f getRPY() const
void setOri(const Eigen::Matrix3f &m)
SpinBoxToVector< Qwid, 3 > & rpyWidgets()
Eigen::Matrix3f getMat3() const
Eigen::Matrix4f getMat4() const
void setPose(const Eigen::Matrix4f &m)
void setXYZWidgets(Qwid *x, Qwid *y, Qwid *z)
#define q
Quaternion< float, 0 > Quaternionf
This file offers overloads of toIce() and fromIce() functions for STL container types.