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/rpy_to_mat3f.h>
6 #include <SimoxUtility/math/convert/mat3f_to_rpy.h>
7 
9 {
10 
12  {
14  {
15  Label("x:"), x,
16  Label("y:"), y,
17  Label("z:"), z,
18  });
19 
20  setRange(-5000.0f, 5000.0f);
21  setSteps(100);
22  }
23 
24  Eigen::Vector3f Vector3Widget::getValue() const
25  {
26  Eigen::Vector3f result;
27  result.x() = x.getValue();
28  result.y() = y.getValue();
29  result.z() = z.getValue();
30  return result;
31  }
32 
33  void Vector3Widget::setValue(Eigen::Vector3f value)
34  {
35  x.setValue(value.x());
36  y.setValue(value.y());
37  z.setValue(value.z());
38  }
39 
40  void Vector3Widget::setRange(float allMin, float allMax)
41  {
42  x.setRange(allMin, allMax);
43  y.setRange(allMin, allMax);
44  z.setRange(allMin, allMax);
45  }
46 
47  void Vector3Widget::setSteps(int steps)
48  {
49  x.setSteps(steps);
50  y.setSteps(steps);
51  z.setSteps(steps);
52  }
53 
54  void Vector3Widget::setDecimals(int decimals)
55  {
56  x.setDecimals(decimals);
57  y.setDecimals(decimals);
58  z.setDecimals(decimals);
59  }
60 
62  {
64  }
65 
67  {
69  {
70  Label("pos:"), x, y, z,
71  Label("rpy:"), roll, pitch, yaw,
72  });
73 
75  setStepsRPY(30);
76  setDecimalsRPY(2);
77 
78  setRangePosition(-5000.0f, 5000.0f);
79  setStepsPosition(100);
81  }
82 
84  {
85  Eigen::Matrix4f result;
86  result.block<3, 1>(0, 3) = getPosition();
87  result.block<3, 3>(0, 0) = getOrientation();
88  result.block<1, 4>(3, 0) = Eigen::Vector4f::UnitW();
89  return result;
90  }
91 
92  Eigen::Vector3f PoseWidget::getPosition() const
93  {
94  Eigen::Vector3f result;
95  result.x() = x.getValue();
96  result.y() = y.getValue();
97  result.z() = z.getValue();
98  return result;
99  }
100 
101  void PoseWidget::setPosition(Eigen::Vector3f value)
102  {
103  x.setValue(value.x());
104  y.setValue(value.y());
105  z.setValue(value.z());
106  }
107 
109  {
110  float r = roll.getValue();
111  float p = pitch.getValue();
112  float y = yaw.getValue();
113 
114  return simox::math::rpy_to_mat3f(r, p, y);
115  }
116 
118  {
119  Eigen::Vector3f rpy = simox::math::mat3f_to_rpy(m);
120 
121  roll.setValue(rpy(0));
122  pitch.setValue(rpy(1));
123  yaw.setValue(rpy(2));
124  }
125 
126  void PoseWidget::setRangePosition(float allMin, float allMax)
127  {
128  x.setRange(allMin, allMax);
129  y.setRange(allMin, allMax);
130  z.setRange(allMin, allMax);
131  }
132 
134  {
135  x.setSteps(steps);
136  y.setSteps(steps);
137  z.setSteps(steps);
138  }
139 
140  void PoseWidget::setRangeRPY(float allMin, float allMax)
141  {
142  roll.setRange(allMin, allMax);
143  pitch.setRange(allMin, allMax);
144  yaw.setRange(allMin, allMax);
145  }
146 
147  void PoseWidget::setStepsRPY(int steps)
148  {
149  roll.setSteps(steps);
150  pitch.setSteps(steps);
151  yaw.setSteps(steps);
152  }
153 
155  {
156  x.setDecimals(decimals);
157  y.setDecimals(decimals);
158  z.setDecimals(decimals);
159  }
160 
161  void PoseWidget::setDecimalsRPY(int decimals)
162  {
163  roll.setDecimals(decimals);
164  pitch.setDecimals(decimals);
165  yaw.setDecimals(decimals);
166  }
167 
168 
169 }
armarx::RemoteGui::Client::FloatSpinBox::hasValueChanged
bool hasValueChanged() const
Definition: Widgets.cpp:342
armarx::RemoteGui::Client::FloatSpinBox::getValue
float getValue() const
Definition: Widgets.cpp:332
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:126
armarx::RemoteGui::Client::FloatSpinBox::setValue
void setValue(float newValue)
Definition: Widgets.cpp:337
armarx::RemoteGui::Client::PoseWidget::setOrientation
void setOrientation(Eigen::Matrix3f const &m)
Definition: EigenWidgets.cpp:117
armarx::RemoteGui::Client::FloatSpinBox::setRange
void setRange(float min, float max)
Definition: Widgets.cpp:313
armarx::RemoteGui::Client::PoseWidget::setStepsRPY
void setStepsRPY(int steps)
Definition: EigenWidgets.cpp:147
armarx::RemoteGui::Client::PoseWidget::getPosition
Eigen::Vector3f getPosition() const
Definition: EigenWidgets.cpp:92
armarx::RemoteGui::Client::PoseWidget::setPosition
void setPosition(Eigen::Vector3f value)
Definition: EigenWidgets.cpp:101
armarx::RemoteGui::Client::PoseWidget::setDecimalsPosition
void setDecimalsPosition(int decimals)
Definition: EigenWidgets.cpp:154
armarx::RemoteGui::Client::PoseWidget::getPose
Eigen::Matrix4f getPose() const
Definition: EigenWidgets.cpp:83
visionx::voxelgrid::Label
uint32_t Label
Type of an object label.
Definition: types.h:7
armarx::RemoteGui::Client::PoseWidget::setStepsPosition
void setStepsPosition(int steps)
Definition: EigenWidgets.cpp:133
armarx::RemoteGui::Client::ContainerWidget::addChildren
void addChildren(std::initializer_list< Widget > children)
Definition: Widgets.cpp:100
cxxopts::value
std::shared_ptr< Value > value()
Definition: cxxopts.hpp:926
armarx::RemoteGui::Client::Vector3Widget::hasValueChanged
bool hasValueChanged() const
Definition: EigenWidgets.cpp:61
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:40
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:326
armarx::RemoteGui::Client::PoseWidget::getOrientation
Eigen::Matrix3f getOrientation() const
Definition: EigenWidgets.cpp:108
armarx::RemoteGui::Client::FloatSpinBox::setSteps
void setSteps(int steps)
Definition: Widgets.cpp:320
armarx::RemoteGui::Client::PoseWidget::x
FloatSpinBox x
Definition: EigenWidgets.h:34
armarx::RemoteGui::Client::Vector3Widget::getValue
Eigen::Vector3f getValue() const
Definition: EigenWidgets.cpp:24
GfxTL::Matrix3f
MatrixXX< 3, 3, float > Matrix3f
Definition: MatrixXX.h:600
GfxTL::Matrix4f
MatrixXX< 4, 4, float > Matrix4f
Definition: MatrixXX.h:601
armarx::RemoteGui::Client::PoseWidget::setRangeRPY
void setRangeRPY(float allMin, float allMax)
Definition: EigenWidgets.cpp:140
armarx::RemoteGui::Client::Vector3Widget::setValue
void setValue(Eigen::Vector3f value)
Definition: EigenWidgets.cpp:33
armarx::RemoteGui::Client::PoseWidget::setDecimalsRPY
void setDecimalsRPY(int decimals)
Definition: EigenWidgets.cpp:161
armarx::RemoteGui::Client::Vector3Widget::Vector3Widget
Vector3Widget()
Definition: EigenWidgets.cpp:11
armarx::RemoteGui::Client::Vector3Widget::setDecimals
void setDecimals(int decimals)
Definition: EigenWidgets.cpp:54
armarx::RemoteGui::Client::Vector3Widget::setSteps
void setSteps(int steps)
Definition: EigenWidgets.cpp:47
armarx::RemoteGui::Client::PoseWidget::PoseWidget
PoseWidget()
Definition: EigenWidgets.cpp:66
armarx::RemoteGui::Client
Definition: EigenWidgets.cpp:8
armarx::RemoteGui::Client::PoseWidget::yaw
FloatSpinBox yaw
Definition: EigenWidgets.h:40