EigenWidgets.cpp
Go to the documentation of this file.
1#include "EigenWidgets.h"
2
3// Warning: This header includes Eigen/Dense for no particular reasons besides some metaprogramming shennanigans
4// Do not use the SimoxUtility/math headers in any header files, since they increase compile time dramatically
5#include <SimoxUtility/math/convert/mat3f_to_rpy.h>
6#include <SimoxUtility/math/convert/rpy_to_mat3f.h>
7
9{
10
12 {
14 Label("x:"),
15 x,
16 Label("y:"),
17 y,
18 Label("z:"),
19 z,
20 });
21
22 setRange(-5000.0f, 5000.0f);
23 setSteps(100);
24 }
25
26 Eigen::Vector3f
28 {
29 Eigen::Vector3f result;
30 result.x() = x.getValue();
31 result.y() = y.getValue();
32 result.z() = z.getValue();
33 return result;
34 }
35
36 void
37 Vector3Widget::setValue(Eigen::Vector3f value)
38 {
39 x.setValue(value.x());
40 y.setValue(value.y());
41 z.setValue(value.z());
42 }
43
44 void
45 Vector3Widget::setRange(float allMin, float allMax)
46 {
47 x.setRange(allMin, allMax);
48 y.setRange(allMin, allMax);
49 z.setRange(allMin, allMax);
50 }
51
52 void
54 {
55 x.setSteps(steps);
56 y.setSteps(steps);
57 z.setSteps(steps);
58 }
59
60 void
62 {
63 x.setDecimals(decimals);
64 y.setDecimals(decimals);
65 z.setDecimals(decimals);
66 }
67
68 bool
70 {
71 return x.hasValueChanged() || y.hasValueChanged() || z.hasValueChanged();
72 }
73
75 {
77 Label("pos:"),
78 x,
79 y,
80 z,
81 Label("rpy:"),
82 roll,
83 pitch,
84 yaw,
85 });
86
88 setStepsRPY(30);
90
91 setRangePosition(-5000.0f, 5000.0f);
94 }
95
96 Eigen::Matrix4f
98 {
99 Eigen::Matrix4f result;
100 result.block<3, 1>(0, 3) = getPosition();
101 result.block<3, 3>(0, 0) = getOrientation();
102 result.block<1, 4>(3, 0) = Eigen::Vector4f::UnitW();
103 return result;
104 }
105
106 Eigen::Vector3f
108 {
109 Eigen::Vector3f result;
110 result.x() = x.getValue();
111 result.y() = y.getValue();
112 result.z() = z.getValue();
113 return result;
114 }
115
116 void
117 PoseWidget::setPosition(Eigen::Vector3f value)
118 {
119 x.setValue(value.x());
120 y.setValue(value.y());
121 z.setValue(value.z());
122 }
123
124 Eigen::Matrix3f
126 {
127 float r = roll.getValue();
128 float p = pitch.getValue();
129 float y = yaw.getValue();
130
131 return simox::math::rpy_to_mat3f(r, p, y);
132 }
133
134 void
135 PoseWidget::setOrientation(Eigen::Matrix3f const& m)
136 {
137 Eigen::Vector3f rpy = simox::math::mat3f_to_rpy(m);
138
139 roll.setValue(rpy(0));
140 pitch.setValue(rpy(1));
141 yaw.setValue(rpy(2));
142 }
143
144 void
145 PoseWidget::setRangePosition(float allMin, float allMax)
146 {
147 x.setRange(allMin, allMax);
148 y.setRange(allMin, allMax);
149 z.setRange(allMin, allMax);
150 }
151
152 void
154 {
155 x.setSteps(steps);
156 y.setSteps(steps);
157 z.setSteps(steps);
158 }
159
160 void
161 PoseWidget::setRangeRPY(float allMin, float allMax)
162 {
163 roll.setRange(allMin, allMax);
164 pitch.setRange(allMin, allMax);
165 yaw.setRange(allMin, allMax);
166 }
167
168 void
170 {
171 roll.setSteps(steps);
172 pitch.setSteps(steps);
173 yaw.setSteps(steps);
174 }
175
176 void
178 {
179 x.setDecimals(decimals);
180 y.setDecimals(decimals);
181 z.setDecimals(decimals);
182 }
183
184 void
186 {
187 roll.setDecimals(decimals);
188 pitch.setDecimals(decimals);
189 yaw.setDecimals(decimals);
190 }
191
192
193} // namespace armarx::RemoteGui::Client
int Label(int n[], int size, int *curLabel, MiscLib::Vector< std::pair< int, size_t > > *labels)
Definition Bitmap.cpp:801
#define M_PI
Definition MathTools.h:17
This file offers overloads of toIce() and fromIce() functions for STL container types.
void addChildren(std::initializer_list< Widget > children)
Definition Widgets.cpp:101
void setRangePosition(float allMin, float allMax)
Eigen::Matrix3f getOrientation() const
void setPosition(Eigen::Vector3f value)
void setOrientation(Eigen::Matrix3f const &m)
void setRangeRPY(float allMin, float allMax)
void setValue(Eigen::Vector3f value)
void setRange(float allMin, float allMax)