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  {
13  addChildren({
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  {
76  addChildren({
77  Label("pos:"),
78  x,
79  y,
80  z,
81  Label("rpy:"),
82  roll,
83  pitch,
84  yaw,
85  });
86 
88  setStepsRPY(30);
89  setDecimalsRPY(2);
90 
91  setRangePosition(-5000.0f, 5000.0f);
92  setStepsPosition(100);
94  }
95 
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
118  {
119  x.setValue(value.x());
120  y.setValue(value.y());
121  z.setValue(value.z());
122  }
123 
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
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
armarx::RemoteGui::Client::FloatSpinBox::hasValueChanged
bool hasValueChanged() const
Definition: Widgets.cpp:364
armarx::RemoteGui::Client::FloatSpinBox::getValue
float getValue() const
Definition: Widgets.cpp:352
armarx::RemoteGui::Client::PoseWidget::pitch
FloatSpinBox pitch
Definition: EigenWidgets.h:39
armarx::RemoteGui::Client::Vector3Widget::y
FloatSpinBox y
Definition: EigenWidgets.h:14
armarx::RemoteGui::Client::PoseWidget::y
FloatSpinBox y
Definition: EigenWidgets.h:35
armarx::RemoteGui::Client::PoseWidget::setRangePosition
void setRangePosition(float allMin, float allMax)
Definition: EigenWidgets.cpp:145
GfxTL::Matrix4f
MatrixXX< 4, 4, float > Matrix4f
Definition: MatrixXX.h:650
armarx::RemoteGui::Client::FloatSpinBox::setValue
void setValue(float newValue)
Definition: Widgets.cpp:358
armarx::RemoteGui::Client::PoseWidget::setOrientation
void setOrientation(Eigen::Matrix3f const &m)
Definition: EigenWidgets.cpp:135
armarx::RemoteGui::Client::FloatSpinBox::setRange
void setRange(float min, float max)
Definition: Widgets.cpp:330
armarx::RemoteGui::Client::PoseWidget::setStepsRPY
void setStepsRPY(int steps)
Definition: EigenWidgets.cpp:169
armarx::RemoteGui::Client::PoseWidget::getPosition
Eigen::Vector3f getPosition() const
Definition: EigenWidgets.cpp:107
armarx::RemoteGui::Client::PoseWidget::setPosition
void setPosition(Eigen::Vector3f value)
Definition: EigenWidgets.cpp:117
armarx::RemoteGui::Client::PoseWidget::setDecimalsPosition
void setDecimalsPosition(int decimals)
Definition: EigenWidgets.cpp:177
armarx::RemoteGui::Client::PoseWidget::getPose
Eigen::Matrix4f getPose() const
Definition: EigenWidgets.cpp:97
visionx::voxelgrid::Label
uint32_t Label
Type of an object label.
Definition: types.h:6
armarx::RemoteGui::Client::PoseWidget::setStepsPosition
void setStepsPosition(int steps)
Definition: EigenWidgets.cpp:153
armarx::RemoteGui::Client::ContainerWidget::addChildren
void addChildren(std::initializer_list< Widget > children)
Definition: Widgets.cpp:101
cxxopts::value
std::shared_ptr< Value > value()
Definition: cxxopts.hpp:855
armarx::RemoteGui::Client::Vector3Widget::hasValueChanged
bool hasValueChanged() const
Definition: EigenWidgets.cpp:69
M_PI
#define M_PI
Definition: MathTools.h:17
EigenWidgets.h
armarx::RemoteGui::Client::PoseWidget::z
FloatSpinBox z
Definition: EigenWidgets.h:36
armarx::RemoteGui::Client::Vector3Widget::setRange
void setRange(float allMin, float allMax)
Definition: EigenWidgets.cpp:45
armarx::RemoteGui::Client::Vector3Widget::x
FloatSpinBox x
Definition: EigenWidgets.h:13
armarx::RemoteGui::Client::PoseWidget::roll
FloatSpinBox roll
Definition: EigenWidgets.h:38
armarx::RemoteGui::Client::Vector3Widget::z
FloatSpinBox z
Definition: EigenWidgets.h:15
armarx::RemoteGui::Client::FloatSpinBox::setDecimals
void setDecimals(int decimals)
Definition: Widgets.cpp:345
armarx::RemoteGui::Client::PoseWidget::getOrientation
Eigen::Matrix3f getOrientation() const
Definition: EigenWidgets.cpp:125
armarx::RemoteGui::Client::FloatSpinBox::setSteps
void setSteps(int steps)
Definition: Widgets.cpp:338
armarx::RemoteGui::Client::PoseWidget::x
FloatSpinBox x
Definition: EigenWidgets.h:34
armarx::RemoteGui::Client::Vector3Widget::getValue
Eigen::Vector3f getValue() const
Definition: EigenWidgets.cpp:27
armarx::RemoteGui::Client::PoseWidget::setRangeRPY
void setRangeRPY(float allMin, float allMax)
Definition: EigenWidgets.cpp:161
armarx::RemoteGui::Client::Vector3Widget::setValue
void setValue(Eigen::Vector3f value)
Definition: EigenWidgets.cpp:37
armarx::RemoteGui::Client::PoseWidget::setDecimalsRPY
void setDecimalsRPY(int decimals)
Definition: EigenWidgets.cpp:185
armarx::RemoteGui::Client::Vector3Widget::Vector3Widget
Vector3Widget()
Definition: EigenWidgets.cpp:11
armarx::RemoteGui::Client::Vector3Widget::setDecimals
void setDecimals(int decimals)
Definition: EigenWidgets.cpp:61
GfxTL::Matrix3f
MatrixXX< 3, 3, float > Matrix3f
Definition: MatrixXX.h:649
armarx::RemoteGui::Client::Vector3Widget::setSteps
void setSteps(int steps)
Definition: EigenWidgets.cpp:53
armarx::RemoteGui::Client::PoseWidget::PoseWidget
PoseWidget()
Definition: EigenWidgets.cpp:74
armarx::RemoteGui::Client
Definition: EigenWidgets.cpp:8
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:27
armarx::RemoteGui::Client::PoseWidget::yaw
FloatSpinBox yaw
Definition: EigenWidgets.h:40