27 #include <SimoxUtility/math/convert/mat4f_to_pos.h>
28 #include <SimoxUtility/math/convert/mat4f_to_rpy.h>
29 #include <SimoxUtility/math/convert/rpy_to_quat.h>
40 _ui.pushButtonActivate,
41 _ui.pushButtonDeactivate,
42 _ui.pushButtonDelete);
44 _ui.gridLayoutSettings->addWidget(_settings);
47 _ui.doubleSpinBoxTargTX, _ui.doubleSpinBoxTargTY, _ui.doubleSpinBoxTargTZ);
50 _ui.doubleSpinBoxTargRX, _ui.doubleSpinBoxTargRY, _ui.doubleSpinBoxTargRZ);
53 _timer = startTimer(10);
70 for (
const auto& rnsName :
_robot->getRobotNodeSetNames())
72 _ui.comboBoxRNS->addItem(QString::fromStdString(rnsName));
75 for (
const auto& nodeName :
_robot->getRobotNodeNames())
77 _ui.comboBoxLockY->addItem(QString::fromStdString(nodeName));
78 _ui.comboBoxLockZ->addItem(QString::fromStdString(nodeName));
83 _ui.pushButtonTargGet, &QPushButton::clicked,
this, &T::on_pushButtonTargGet_clicked);
85 _ui.pushButtonTargAdd, &QPushButton::clicked,
this, &T::on_pushButtonTargAdd_clicked);
87 _ui.pushButtonTargSet, &QPushButton::clicked,
this, &T::on_pushButtonTargSet_clicked);
88 connect(_ui.comboBoxRNS,
89 SIGNAL(currentIndexChanged(
const QString&)),
91 SLOT(on_comboBoxRNS_currentIndexChanged(
const QString&)));
92 connect(_ui.radioButtonSelectLeft,
93 &QRadioButton::clicked,
95 &T::on_radioButtonSelect_clicked);
96 connect(_ui.radioButtonSelectRight,
97 &QRadioButton::clicked,
99 &T::on_radioButtonSelect_clicked);
100 connect(_ui.radioButtonSelectRNS,
101 &QRadioButton::clicked,
103 &T::on_radioButtonSelect_clicked);
105 _ui.groupBoxAdvanced->setChecked(
false);
106 _ui.radioButtonSelectLeft->setChecked(
true);
127 if (_ui.checkBoxAutoUpdatePose->isChecked())
130 on_pushButtonTargSet_clicked();
132 const bool lockY = _ui.checkBoxLockY->isChecked();
133 const bool lockZ = _ui.checkBoxLockZ->isChecked();
134 bool anyTracking = lockY || lockZ;
135 _ui.widgetTarget->setEnabled(!anyTracking);
136 if (_rns && (lockY || lockZ))
142 pose(1, 3) =
_robot->getRobotNode(_ui.comboBoxLockY->currentText().toStdString())
143 ->getPositionInRootFrame()(1);
147 pose(2, 3) =
_robot->getRobotNode(_ui.comboBoxLockZ->currentText().toStdString())
148 ->getPositionInRootFrame()(2);
152 _controller->setPosition(pose.topRightCorner<3, 1>());
157 else if (!(lockY || lockZ))
160 _ui.radioButtonVisuSet ? _targ.
getMat4()
161 : _rns->getTCP()->getPoseInRootFrame() * _targ.
getMat4();
171 if (_visuHandRobotFile.empty() || !
_robot || !
arviz.topic())
182 .
file(_visuHandRobotProject, _visuHandRobotFile)
184 .pose(
_robot->getGlobalPose() * tcpInRoot * _tcpToBase)
191 NJointControllerConfigPtr
192 CartesianImpedanceControllerWidgetController::readFullCFG()
const
195 auto [pos, quat] = readTargetCFG();
196 return NJointControllerConfigPtr::dynamicCast(_settings->
readFullCFG(pos, quat));
199 std::tuple<Eigen::Vector3f, Eigen::Quaternionf>
200 CartesianImpedanceControllerWidgetController::readTargetCFG()
const
210 CartesianImpedanceControllerWidgetController::createController()
214 _ui.widgetRNSSelect->setEnabled(
false);
219 CartesianImpedanceControllerWidgetController::deleteController()
223 _ui.widgetRNSSelect->setEnabled(
true);
228 CartesianImpedanceControllerWidgetController::on_pushButtonTargSet_clicked()
242 CartesianImpedanceControllerWidgetController::on_pushButtonTargAdd_clicked()
256 CartesianImpedanceControllerWidgetController::on_pushButtonTargGet_clicked()
265 const Eigen::Vector3f pos = simox::math::mat4f_to_pos(pose);
266 const Eigen::Vector3f rpy = simox::math::mat4f_to_rpy(pose);
268 _ui.doubleSpinBoxTargTX->setValue(pos(0));
269 _ui.doubleSpinBoxTargTY->setValue(pos(1));
270 _ui.doubleSpinBoxTargTZ->setValue(pos(2));
272 _ui.doubleSpinBoxTargRX->setValue(rpy(0));
273 _ui.doubleSpinBoxTargRY->setValue(rpy(1));
274 _ui.doubleSpinBoxTargRZ->setValue(rpy(2));
278 CartesianImpedanceControllerWidgetController::on_comboBoxRNS_currentIndexChanged(
287 const std::string rnsName = arg1.toStdString();
288 _rns =
_robot->getRobotNodeSet(rnsName);
292 if (!_rns->getTCP() || side.getTCP() != _rns->getTCP()->getName() ||
293 !side.getRobotNameHelper())
297 const auto arm = side.addRobot(
_robot);
298 _tcpToBase = arm.getTcp2HandRootTransform();
299 _visuHandRobotFile = side.getHandModelPath();
300 _visuHandRobotProject = side.getHandModelPackage();
311 on_pushButtonTargGet_clicked();
315 CartesianImpedanceControllerWidgetController::on_radioButtonSelect_clicked()
319 if (_ui.radioButtonSelectLeft->isChecked())
321 on_comboBoxRNS_currentIndexChanged(QString::fromStdString(_left.
getKinematicChain()));
323 else if (_ui.radioButtonSelectRight->isChecked())
325 on_comboBoxRNS_currentIndexChanged(QString::fromStdString(_right.
getKinematicChain()));
329 on_comboBoxRNS_currentIndexChanged(_ui.comboBoxRNS->currentText());