CartesianImpedanceControllerConfigWidget.cpp
Go to the documentation of this file.
2 
3 namespace armarx
4 {
5  void
6  clearLayout(QLayout* layout)
7  {
8  QLayoutItem* item;
9  while ((item = layout->takeAt(0)))
10  {
11  if (item->layout())
12  {
13  clearLayout(item->layout());
14  delete item->layout();
15  }
16  if (item->widget())
17  {
18  delete item->widget();
19  }
20  delete item;
21  }
22  }
23 
25  QWidget* parent) :
26  QWidget(parent)
27  {
28  ui.setupUi(this);
29 
30  kxyz.addWidget(ui.doubleSpinBoxKTX);
31  kxyz.addWidget(ui.doubleSpinBoxKTY);
32  kxyz.addWidget(ui.doubleSpinBoxKTZ);
33  kxyz.setMinMax(0, 5000);
34  kxyz.set(1000);
35 
36  krpy.addWidget(ui.doubleSpinBoxKRX);
37  krpy.addWidget(ui.doubleSpinBoxKRY);
38  krpy.addWidget(ui.doubleSpinBoxKRZ);
39  krpy.setMinMax(0, 5000);
40  krpy.set(500);
41 
42  dxyz.addWidget(ui.doubleSpinBoxDTX);
43  dxyz.addWidget(ui.doubleSpinBoxDTY);
44  dxyz.addWidget(ui.doubleSpinBoxDTZ);
45  dxyz.setMinMax(0, 5000);
46  dxyz.set(250);
47 
48  drpy.addWidget(ui.doubleSpinBoxDRX);
49  drpy.addWidget(ui.doubleSpinBoxDRY);
50  drpy.addWidget(ui.doubleSpinBoxDRZ);
51  drpy.setMinMax(0, 5000);
52  drpy.set(100);
53 
55  connect(ui.pushButtonNullspaceUpdateJoints,
56  &QPushButton::clicked,
57  this,
58  &T::on_pushButtonNullspaceUpdateJoints_clicked);
59  connect(ui.pushButtonNullspaceSend,
60  &QPushButton::clicked,
61  this,
62  &T::on_pushButtonNullspaceSend_clicked);
63  connect(ui.pushButtonSettingsSend,
64  &QPushButton::clicked,
65  this,
66  &T::on_pushButtonSettingsSend_clicked);
67  }
68 
69  void
71  const QString& prefix)
72  {
73  if (prefix.size())
74  {
75  settings->beginGroup(prefix);
76  }
77  ///TODO
78  if (prefix.size())
79  {
80  settings->endGroup();
81  }
82  }
83 
84  void
86  const QString& prefix)
87  {
88  if (prefix.size())
89  {
90  settings->beginGroup("layer");
91  }
92  ///TODO
93  if (prefix.size())
94  {
95  settings->endGroup();
96  }
97  }
98 
99  NJointTaskSpaceImpedanceControlConfigPtr
101  const Eigen::Quaternionf& targOri) const
102  {
103  ARMARX_TRACE;
104  ARMARX_CHECK_NOT_NULL(_rns);
105  NJointTaskSpaceImpedanceControlConfigPtr cfg = new NJointTaskSpaceImpedanceControlConfig;
106  cfg->nodeSetName = _rns->getName();
107 
108  cfg->desiredPosition = targPos;
109  cfg->desiredOrientation = targOri;
110 
111  kxyz.get(cfg->Kpos);
112  krpy.get(cfg->Kori);
113  dxyz.get(cfg->Dpos);
114  drpy.get(cfg->Dori);
115 
116  auto [joint, knull, dnull] = readNullspaceCFG();
117  cfg->desiredJointPositions = joint;
118  cfg->Knull = knull;
119  cfg->Dnull = dnull;
120 
121  cfg->torqueLimit = ui.doubleSpinBoxTorqueLim->value();
122  return cfg;
123  }
124  NJointTaskSpaceImpedanceControlRuntimeConfig
126  {
127  ARMARX_TRACE;
128  ARMARX_CHECK_NOT_NULL(_rns);
129  NJointTaskSpaceImpedanceControlRuntimeConfig cfg;
130 
131  kxyz.get(cfg.Kpos);
132  krpy.get(cfg.Kori);
133  dxyz.get(cfg.Dpos);
134  drpy.get(cfg.Dori);
135 
136  auto [joint, knull, dnull] = readNullspaceCFG();
137  cfg.desiredJointPositions = joint;
138  cfg.Knull = knull;
139  cfg.Dnull = dnull;
140 
141  cfg.torqueLimit = ui.doubleSpinBoxTorqueLim->value();
142  return cfg;
143  }
144  std::tuple<Eigen::VectorXf, Eigen::VectorXf, Eigen::VectorXf>
146  {
147  ARMARX_TRACE;
148  return {jointValues.get<Eigen::VectorXf>(),
149  jointKnull.get<Eigen::VectorXf>(),
150  jointDnull.get<Eigen::VectorXf>()};
151  }
152 
153 
154  void
156  {
157  ARMARX_TRACE;
158  if (!_controller)
159  {
160  return;
161  }
162  auto [joint, knull, dnull] = readNullspaceCFG();
163  _controller->setNullspaceConfig(joint, knull, dnull);
164  }
165 
166  void
168  {
169  ARMARX_TRACE;
170  if (!_rns)
171  {
172  return;
173  }
174  jointValues.set(_rns);
175  }
176 
177  void
179  {
180  ARMARX_TRACE;
181  if (!_controller)
182  {
183  return;
184  }
185  _controller->setConfig(readRuntimeCFG());
186  }
187 
188  void
190  const NJointTaskSpaceImpedanceControlInterfacePrx& prx)
191  {
192  _controller = prx;
193  }
194  void
195  CartesianImpedanceControllerConfigWidget::setRNS(const VirtualRobot::RobotNodeSetPtr& rns)
196  {
197  ARMARX_TRACE;
198  _rns = rns;
199  auto lay = ui.gridLayoutNullspace;
200  clearLayout(lay);
201  lay->addWidget(new QLabel{"Joint"}, 0, 0);
202  lay->addWidget(new QLabel{"Target"}, 0, 1);
203  lay->addWidget(new QLabel{"Knull"}, 0, 2);
204  lay->addWidget(new QLabel{"Dnull"}, 0, 3);
205  jointValues.clear();
206  jointKnull.clear();
207  jointDnull.clear();
208 
209  if (!_rns)
210  {
211  return;
212  }
213 
214  int i = 1;
215  for (const auto& rn : _rns->getAllRobotNodes())
216  {
217  ARMARX_TRACE;
218  const auto&& n = rn->getName();
219  lay->addWidget(new QLabel{QString::fromStdString(n)}, i, 0);
220  {
221  auto b = new QDoubleSpinBox;
223  lay->addWidget(b, i, 1);
224  const auto lo = rn->getJointLimitLow();
225  const auto hi = rn->getJointLimitHigh();
226  b->setMinimum(lo);
227  b->setMaximum(hi);
228  b->setValue((lo + hi) / 2);
229  }
230  {
231  auto b = new QDoubleSpinBox;
233  lay->addWidget(b, i, 2);
234  b->setMinimum(0);
235  b->setMaximum(1000);
236  b->setValue(2);
237  }
238  {
239  auto b = new QDoubleSpinBox;
241  lay->addWidget(b, i, 3);
242  b->setMinimum(0);
243  b->setMaximum(1000);
244  b->setValue(1);
245  }
246  ++i;
247  }
248  jointKnull.set(2);
249  jointDnull.set(1);
250 
252  }
253 } // namespace armarx
armarx::SpinBoxToVector::clear
void clear()
Definition: SpinBoxToVector.h:155
armarx::CartesianImpedanceControllerConfigWidget::jointDnull
SpinBoxToVector< QDoubleSpinBox > jointDnull
Definition: CartesianImpedanceControllerConfigWidget.h:45
armarx::CartesianImpedanceControllerConfigWidget::setController
void setController(const NJointTaskSpaceImpedanceControlInterfacePrx &prx)
if null -> send buttons deactivated
Definition: CartesianImpedanceControllerConfigWidget.cpp:189
ARMARX_CHECK_NOT_NULL
#define ARMARX_CHECK_NOT_NULL(ptr)
This macro evaluates whether ptr is not null and if it turns out to be false it will throw an Express...
Definition: ExpressionException.h:206
armarx::CartesianImpedanceControllerConfigWidget::CartesianImpedanceControllerConfigWidget
CartesianImpedanceControllerConfigWidget(QWidget *parent=nullptr)
Definition: CartesianImpedanceControllerConfigWidget.cpp:24
armarx::SpinBoxToVector::get
void get(Eigen::Matrix< Scalar, Rows, Cols > &m) const
Definition: SpinBoxToVector.h:45
lo
#define lo(x)
Definition: AbstractInterface.h:43
armarx::CartesianImpedanceControllerConfigWidget::dxyz
SpinBoxToVector< QDoubleSpinBox, 3 > dxyz
Definition: CartesianImpedanceControllerConfigWidget.h:41
armarx::CartesianImpedanceControllerConfigWidget::saveSettings
void saveSettings(QSettings *settings, const QString &prefix="")
Definition: CartesianImpedanceControllerConfigWidget.cpp:85
armarx::CartesianImpedanceControllerConfigWidget::jointValues
SpinBoxToVector< QDoubleSpinBox > jointValues
Definition: CartesianImpedanceControllerConfigWidget.h:43
armarx::CartesianImpedanceControllerConfigWidget::loadSettings
void loadSettings(QSettings *settings, const QString &prefix="")
Definition: CartesianImpedanceControllerConfigWidget.cpp:70
armarx::CartesianImpedanceControllerConfigWidget::drpy
SpinBoxToVector< QDoubleSpinBox, 3 > drpy
Definition: CartesianImpedanceControllerConfigWidget.h:42
CartesianImpedanceControllerConfigWidget.h
armarx::CartesianImpedanceControllerConfigWidget::readNullspaceCFG
std::tuple< Eigen::VectorXf, Eigen::VectorXf, Eigen::VectorXf > readNullspaceCFG() const
Definition: CartesianImpedanceControllerConfigWidget.cpp:145
ARMARX_TRACE
#define ARMARX_TRACE
Definition: trace.h:69
armarx::CartesianImpedanceControllerConfigWidget::on_pushButtonNullspaceSend_clicked
void on_pushButtonNullspaceSend_clicked()
Definition: CartesianImpedanceControllerConfigWidget.cpp:155
armarx::SpinBoxToVector::addWidget
void addWidget(Qwid *s)
Definition: SpinBoxToVector.h:140
armarx::CartesianImpedanceControllerConfigWidget::on_pushButtonNullspaceUpdateJoints_clicked
void on_pushButtonNullspaceUpdateJoints_clicked()
Definition: CartesianImpedanceControllerConfigWidget.cpp:167
armarx::SpinBoxToVector::setMinMax
void setMinMax(auto min, auto max)
Definition: SpinBoxToVector.h:185
armarx::CartesianImpedanceControllerConfigWidget::jointKnull
SpinBoxToVector< QDoubleSpinBox > jointKnull
Definition: CartesianImpedanceControllerConfigWidget.h:44
armarx::Quaternion< float, 0 >
hi
#define hi(x)
Definition: AbstractInterface.h:42
armarx::CartesianImpedanceControllerConfigWidget::kxyz
SpinBoxToVector< QDoubleSpinBox, 3 > kxyz
Definition: CartesianImpedanceControllerConfigWidget.h:39
armarx::SpinBoxToVector::set
void set(const Eigen::Matrix< Scalar, Rows, Cols > &m)
Definition: SpinBoxToVector.h:108
armarx::CartesianImpedanceControllerConfigWidget::on_pushButtonSettingsSend_clicked
void on_pushButtonSettingsSend_clicked()
Definition: CartesianImpedanceControllerConfigWidget.cpp:178
T
float T
Definition: UnscentedKalmanFilterTest.cpp:35
armarx::CartesianImpedanceControllerConfigWidget::setRNS
void setRNS(const VirtualRobot::RobotNodeSetPtr &rns)
Definition: CartesianImpedanceControllerConfigWidget.cpp:195
armarx::CartesianImpedanceControllerConfigWidget::readFullCFG
NJointTaskSpaceImpedanceControlConfigPtr readFullCFG(const Eigen::Vector3f &targPos, const Eigen::Quaternionf &targOri) const
Definition: CartesianImpedanceControllerConfigWidget.cpp:100
armarx::CartesianImpedanceControllerConfigWidget::ui
Ui::CartesianImpedanceControllerConfigWidget ui
Definition: CartesianImpedanceControllerConfigWidget.h:38
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
armarx::CartesianImpedanceControllerConfigWidget::krpy
SpinBoxToVector< QDoubleSpinBox, 3 > krpy
Definition: CartesianImpedanceControllerConfigWidget.h:40
armarx::clearLayout
void clearLayout(QLayout *layout)
Clear a layout.
Definition: RemoteGuiWidgetController.cpp:38
armarx::CartesianImpedanceControllerConfigWidget::readRuntimeCFG
NJointTaskSpaceImpedanceControlRuntimeConfig readRuntimeCFG() const
Definition: CartesianImpedanceControllerConfigWidget.cpp:125