27 #include <SimoxUtility/math/convert/mat4f_to_rpy.h>
28 #include <SimoxUtility/math/convert/pos_rpy_to_mat4f.h>
38 while ((item = layout->takeAt(0)))
43 delete item->layout();
47 delete item->widget();
59 _ui.pushButtonCtrlActivate,
60 _ui.pushButtonCtrlDeactivate,
61 _ui.pushButtonCtrlDelete);
63 connect(_ui.pushButtonReadCurrentPose,
64 &QPushButton::clicked,
66 &T::on_pushButtonReadCurrentPose_clicked);
68 _ui.pushButtonTargAdd, &QPushButton::clicked,
this, &T::on_pushButtonTargAdd_clicked);
69 connect(_ui.pushButtonCfgSendDefaultPose,
70 &QPushButton::clicked,
72 &T::on_pushButtonCfgSendDefaultPose_clicked);
73 connect(_ui.pushButtonCfgSendNullspace,
74 &QPushButton::clicked,
76 &T::on_pushButtonCfgSendNullspace_clicked);
77 connect(_ui.pushButtonCfgSendImpedance,
78 &QPushButton::clicked,
80 &T::on_pushButtonCfgSendImpedance_clicked);
81 connect(_ui.pushButtonCfgSendAdmittance,
82 &QPushButton::clicked,
84 &T::on_pushButtonCfgSendAdmittance_clicked);
85 connect(_ui.pushButtonCfgSendForce,
86 &QPushButton::clicked,
88 &T::on_pushButtonCfgSendForce_clicked);
89 connect(_ui.pushButtonCfgSendAll,
90 &QPushButton::clicked,
92 &T::on_pushButtonCfgSendAll_clicked);
94 _ui.pushButtonTargSend, &QPushButton::clicked,
this, &T::on_pushButtonTargSend_clicked);
98 BimanualCartesianAdmittanceControllerGuiWidgetController::setupGuiAfterConnect()
102 const auto fill = [&](
auto rnsname,
auto& lay,
auto& sp)
104 static const std::map<std::string, double> defaults{
110 for (
const auto& rn :
_robot->getRobotNodeSet(rnsname)->getAllRobotNodes())
112 const auto&& n = rn->getName();
113 lay->addWidget(
new QLabel{QString::fromStdString(n)}, i, 0);
114 auto b =
new QDoubleSpinBox;
116 lay->addWidget(b, i, 1);
117 const auto lo = rn->getJointLimitLow();
118 const auto hi = rn->getJointLimitHigh();
121 b->setValue(defaults.count(n) ? defaults.at(n) : (
lo +
hi) / 2);
125 fill(
"LeftArm", _ui.gridLayoutDefaultPoseL, _desiredJointValuesLeft);
126 fill(
"RightArm", _ui.gridLayoutDefaultPoseR, _desiredJointValuesRight);
133 std::array<Ice::FloatSeq, 2>
134 BimanualCartesianAdmittanceControllerGuiWidgetController::readDesiredJointCFG()
const
136 return {_desiredJointValuesLeft.
get<std::vector<float>>(),
137 _desiredJointValuesRight.
get<std::vector<float>>()};
139 detail::NJBmanCartAdmCtrl::Nullspace
140 BimanualCartesianAdmittanceControllerGuiWidgetController::readNullspaceCFG()
const
142 detail::NJBmanCartAdmCtrl::Nullspace
c;
143 c.k = _ui.doubleSpinBoxNK->value();
144 c.d = _ui.doubleSpinBoxND->value();
145 const auto arms = readDesiredJointCFG();
146 c.desiredJointValuesLeft = arms.at(0);
147 c.desiredJointValuesRight = arms.at(1);
150 std::array<detail::NJBmanCartAdmCtrl::Impedance, 2>
151 BimanualCartesianAdmittanceControllerGuiWidgetController::readImpedanceCFG()
const
153 detail::NJBmanCartAdmCtrl::Impedance l;
154 detail::NJBmanCartAdmCtrl::Impedance r;
156 l.KpXYZ(0) = _ui.doubleSpinBoxIPTXL->value();
157 l.KpXYZ(1) = _ui.doubleSpinBoxIPTYL->value();
158 l.KpXYZ(2) = _ui.doubleSpinBoxIPTZL->value();
160 l.KpRPY(0) = _ui.doubleSpinBoxIPRXL->value();
161 l.KpRPY(1) = _ui.doubleSpinBoxIPRYL->value();
162 l.KpRPY(2) = _ui.doubleSpinBoxIPRZL->value();
164 l.KdXYZ(0) = _ui.doubleSpinBoxIDTXL->value();
165 l.KdXYZ(1) = _ui.doubleSpinBoxIDTYL->value();
166 l.KdXYZ(2) = _ui.doubleSpinBoxIDTZL->value();
168 l.KdRPY(0) = _ui.doubleSpinBoxIDRXL->value();
169 l.KdRPY(1) = _ui.doubleSpinBoxIDRYL->value();
170 l.KdRPY(2) = _ui.doubleSpinBoxIDRZL->value();
172 r.KpXYZ(0) = _ui.doubleSpinBoxIPTXR->value();
173 r.KpXYZ(1) = _ui.doubleSpinBoxIPTYR->value();
174 r.KpXYZ(2) = _ui.doubleSpinBoxIPTZR->value();
176 r.KpRPY(0) = _ui.doubleSpinBoxIPRXR->value();
177 r.KpRPY(1) = _ui.doubleSpinBoxIPRYR->value();
178 r.KpRPY(2) = _ui.doubleSpinBoxIPRZR->value();
180 r.KdXYZ(0) = _ui.doubleSpinBoxIDTXR->value();
181 r.KdXYZ(1) = _ui.doubleSpinBoxIDTYR->value();
182 r.KdXYZ(2) = _ui.doubleSpinBoxIDTZR->value();
184 r.KdRPY(0) = _ui.doubleSpinBoxIDRXR->value();
185 r.KdRPY(1) = _ui.doubleSpinBoxIDRYR->value();
186 r.KdRPY(2) = _ui.doubleSpinBoxIDRZR->value();
190 std::array<detail::NJBmanCartAdmCtrl::Force, 2>
191 BimanualCartesianAdmittanceControllerGuiWidgetController::readForceCFG()
const
193 detail::NJBmanCartAdmCtrl::Force l;
194 detail::NJBmanCartAdmCtrl::Force r;
196 l.wrenchXYZ(0) = _ui.doubleSpinBoxFWTXL->value();
197 l.wrenchXYZ(1) = _ui.doubleSpinBoxFWTYL->value();
198 l.wrenchXYZ(2) = _ui.doubleSpinBoxFWTZL->value();
200 l.wrenchRPY(0) = _ui.doubleSpinBoxFWRXL->value();
201 l.wrenchRPY(1) = _ui.doubleSpinBoxFWRYL->value();
202 l.wrenchRPY(2) = _ui.doubleSpinBoxFWRZL->value();
204 l.mass = _ui.doubleSpinBoxFML->value();
206 l.offsetForce(0) = _ui.doubleSpinBoxFOFXL->value();
207 l.offsetForce(1) = _ui.doubleSpinBoxFOFYL->value();
208 l.offsetForce(2) = _ui.doubleSpinBoxFOFZL->value();
210 l.offsetTorque(0) = _ui.doubleSpinBoxFOTXL->value();
211 l.offsetTorque(1) = _ui.doubleSpinBoxFOTYL->value();
212 l.offsetTorque(2) = _ui.doubleSpinBoxFOTZL->value();
214 l.forceThreshold(0) = _ui.doubleSpinBoxFFTXL->value();
215 l.forceThreshold(1) = _ui.doubleSpinBoxFFTYL->value();
216 l.forceThreshold(2) = _ui.doubleSpinBoxFFTZL->value();
218 r.wrenchXYZ(0) = _ui.doubleSpinBoxFWTXR->value();
219 r.wrenchXYZ(1) = _ui.doubleSpinBoxFWTYR->value();
220 r.wrenchXYZ(2) = _ui.doubleSpinBoxFWTZR->value();
222 r.wrenchRPY(0) = _ui.doubleSpinBoxFWRXR->value();
223 r.wrenchRPY(1) = _ui.doubleSpinBoxFWRYR->value();
224 r.wrenchRPY(2) = _ui.doubleSpinBoxFWRZR->value();
226 r.mass = _ui.doubleSpinBoxFMR->value();
228 r.offsetForce(0) = _ui.doubleSpinBoxFOFXR->value();
229 r.offsetForce(1) = _ui.doubleSpinBoxFOFYR->value();
230 r.offsetForce(2) = _ui.doubleSpinBoxFOFZR->value();
232 r.offsetTorque(0) = _ui.doubleSpinBoxFOTXR->value();
233 r.offsetTorque(1) = _ui.doubleSpinBoxFOTYR->value();
234 r.offsetTorque(2) = _ui.doubleSpinBoxFOTZR->value();
236 r.forceThreshold(0) = _ui.doubleSpinBoxFFTXR->value();
237 r.forceThreshold(1) = _ui.doubleSpinBoxFFTYR->value();
238 r.forceThreshold(2) = _ui.doubleSpinBoxFFTZR->value();
241 detail::NJBmanCartAdmCtrl::Admittance
242 BimanualCartesianAdmittanceControllerGuiWidgetController::readAdmittanceCFG()
const
244 detail::NJBmanCartAdmCtrl::Admittance
c;
246 c.KpXYZ(0) = _ui.doubleSpinBoxAPTX->value();
247 c.KpXYZ(1) = _ui.doubleSpinBoxAPTY->value();
248 c.KpXYZ(2) = _ui.doubleSpinBoxAPTZ->value();
250 c.KpRPY(0) = _ui.doubleSpinBoxAPRX->value();
251 c.KpRPY(1) = _ui.doubleSpinBoxAPRY->value();
252 c.KpRPY(2) = _ui.doubleSpinBoxAPRZ->value();
254 c.KdXYZ(0) = _ui.doubleSpinBoxADTX->value();
255 c.KdXYZ(1) = _ui.doubleSpinBoxADTY->value();
256 c.KdXYZ(2) = _ui.doubleSpinBoxADTZ->value();
258 c.KdRPY(0) = _ui.doubleSpinBoxADRX->value();
259 c.KdRPY(1) = _ui.doubleSpinBoxADRY->value();
260 c.KdRPY(2) = _ui.doubleSpinBoxADRZ->value();
262 c.KmXYZ(0) = _ui.doubleSpinBoxAMTX->value();
263 c.KmXYZ(1) = _ui.doubleSpinBoxAMTY->value();
264 c.KmXYZ(2) = _ui.doubleSpinBoxAMTZ->value();
266 c.KmRPY(0) = _ui.doubleSpinBoxAMRX->value();
267 c.KmRPY(1) = _ui.doubleSpinBoxAMRY->value();
268 c.KmRPY(2) = _ui.doubleSpinBoxAMRZ->value();
272 NJointControllerConfigPtr
273 BimanualCartesianAdmittanceControllerGuiWidgetController::readFullCFG()
const
275 NJointBimanualCartesianAdmittanceControllerConfigPtr
c =
276 new NJointBimanualCartesianAdmittanceControllerConfig;
277 c->kinematicChainRight =
"RightArm";
278 c->kinematicChainLeft =
"LeftArm";
279 c->ftSensorRight =
"FT R";
280 c->ftSensorLeft =
"FT L";
281 c->ftSensorRightFrame =
"ArmR_FT";
282 c->ftSensorLeftFrame =
"ArmL_FT";
283 c->box.width = _ui.doubleSpinBoxOBoxw->value();
284 c->filterCoeff = _ui.doubleSpinBoxOFiltCoeff->value();
285 c->torqueLimit = _ui.doubleSpinBoxOTorqueLim->value();
286 c->ftCalibrationTime = _ui.doubleSpinBoxOCalibTime->value();
287 c->nullspace = readNullspaceCFG();
288 c->admittanceObject = readAdmittanceCFG();
289 const auto f = readForceCFG();
290 c->forceLeft = f.at(0);
291 c->forceRight = f.at(1);
292 const auto i = readImpedanceCFG();
293 c->impedanceLeft = i.at(0);
294 c->impedanceRight = i.at(1);
295 return NJointControllerConfigPtr::dynamicCast(
c);
297 std::array<Eigen::Vector3f, 2>
298 BimanualCartesianAdmittanceControllerGuiWidgetController::readPosTarg()
const
303 xyz(0) = _ui.doubleSpinBoxTargTX->value();
304 xyz(1) = _ui.doubleSpinBoxTargTY->value();
305 xyz(2) = _ui.doubleSpinBoxTargTZ->value();
307 rpy(0) = _ui.doubleSpinBoxTargRX->value();
308 rpy(1) = _ui.doubleSpinBoxTargRY->value();
309 rpy(2) = _ui.doubleSpinBoxTargRZ->value();
313 std::array<Eigen::Vector3f, 2>
314 BimanualCartesianAdmittanceControllerGuiWidgetController::readVelTarg()
const
319 xyz(0) = _ui.doubleSpinBoxTargVTX->value();
320 xyz(1) = _ui.doubleSpinBoxTargVTY->value();
321 xyz(2) = _ui.doubleSpinBoxTargVTZ->value();
323 rpy(0) = _ui.doubleSpinBoxTargVRX->value();
324 rpy(1) = _ui.doubleSpinBoxTargVRY->value();
325 rpy(2) = _ui.doubleSpinBoxTargVRZ->value();
334 BimanualCartesianAdmittanceControllerGuiWidgetController::on_pushButtonCfgSendAll_clicked()
342 NJointBimanualCartesianAdmittanceControllerConfigPtr::dynamicCast(readFullCFG()));
346 BimanualCartesianAdmittanceControllerGuiWidgetController::on_pushButtonCfgSendForce_clicked()
353 const auto c = readForceCFG();
358 BimanualCartesianAdmittanceControllerGuiWidgetController::
359 on_pushButtonCfgSendAdmittance_clicked()
366 _controller->setAdmittanceConfig(readAdmittanceCFG());
370 BimanualCartesianAdmittanceControllerGuiWidgetController::
371 on_pushButtonCfgSendImpedance_clicked()
378 const auto c = readImpedanceCFG();
383 BimanualCartesianAdmittanceControllerGuiWidgetController::
384 on_pushButtonCfgSendNullspace_clicked()
391 _controller->setNullspaceConfig(readNullspaceCFG());
395 BimanualCartesianAdmittanceControllerGuiWidgetController::
396 on_pushButtonCfgSendDefaultPose_clicked()
403 const auto c = readDesiredJointCFG();
409 BimanualCartesianAdmittanceControllerGuiWidgetController::on_pushButtonTargSend_clicked()
416 const auto t = readPosTarg();
417 const auto v = readVelTarg();
418 const Eigen::Matrix4f m = simox::math::pos_rpy_to_mat4f(t.at(0), t.at(1));
423 BimanualCartesianAdmittanceControllerGuiWidgetController::on_pushButtonTargAdd_clicked()
430 const auto t = readPosTarg();
431 const Eigen::Matrix4f m = simox::math::pos_rpy_to_mat4f(t.at(0), t.at(1));
436 BimanualCartesianAdmittanceControllerGuiWidgetController::on_pushButtonReadCurrentPose_clicked()
444 const auto rpy = simox::math::mat4f_to_rpy(m);
445 _ui.doubleSpinBoxTargTX->setValue(m(0, 3));
446 _ui.doubleSpinBoxTargTY->setValue(m(1, 3));
447 _ui.doubleSpinBoxTargTZ->setValue(m(2, 3));
448 _ui.doubleSpinBoxTargRX->setValue(rpy(0));
449 _ui.doubleSpinBoxTargRY->setValue(rpy(1));
450 _ui.doubleSpinBoxTargRZ->setValue(rpy(2));