30 #include <SimoxUtility/json.h>
44 connect(_ui.radioButtonWPJson, &QPushButton::clicked,
this, &T::triggerParsing);
45 connect(_ui.radioButton4f, &QPushButton::clicked,
this, &T::triggerParsing);
46 connect(_ui.textEditWPs, &QTextEdit::textChanged,
this, &T::triggerParsing);
49 _ui.pushButtonExecute, &QPushButton::clicked,
this, &T::on_pushButtonExecute_clicked);
50 connect(_ui.pushButtonZeroFT, &QPushButton::clicked,
this, &T::on_pushButtonZeroFT_clicked);
51 connect(_ui.pushButtonSendSettings,
52 &QPushButton::clicked,
54 &T::on_pushButtonSendSettings_clicked);
55 connect(_ui.pushButtonCopyCurrentPose, &QPushButton::clicked,
this, &T::copyCurrentPose);
58 _ui.pushButtonCreateController,
nullptr, _ui.pushButtonStop,
nullptr);
60 _ui.widgetSpacer->setVisible(
false);
61 _timer = startTimer(50);
80 CartesianWaypointControlGuiWidgetController::createController()
84 _supportsFT = !_ui.lineEditFTName->text().toStdString().empty();
88 CartesianWaypointControlGuiWidgetController::on_pushButtonSendSettings_clicked()
99 CartesianWaypointControlGuiWidgetController::copyCurrentPose()
107 const auto rns =
_robot->getRobotNodeSet(_ui.comboBoxChain->currentText().toStdString());
112 const auto tcp = rns->getTCP();
117 const auto str = simox::json::eigen4f2posquatJson(tcp->getPoseInRootFrame());
118 QApplication::clipboard()->setText(QString::fromStdString(
str));
122 CartesianWaypointControlGuiWidgetController::on_pushButtonZeroFT_clicked()
133 CartesianWaypointControlGuiWidgetController::on_pushButtonExecute_clicked()
139 ARMARX_IMPORTANT <<
"trigger execution of " << _lastParsedWPs.size() <<
" waypoints on "
141 _controller->setWaypoints(_ui.checkBoxWPReverse->isChecked() ?
reverse(_lastParsedWPs)
147 CartesianWaypointControlGuiWidgetController::triggerParsing()
150 _lastParsedWPs.clear();
151 _ui.labelParsingSuccess->setText(
"<pre parsing>");
152 if (_ui.radioButtonWPJson->isChecked())
157 _lastParsedWPs = simox::json::posquatArray2eigen4fVector(
158 _ui.textEditWPs->toPlainText().toStdString());
162 _ui.labelParsingSuccess->setText(
"Failed to parse json array!");
166 else if (_ui.radioButton4f->isChecked())
170 _ui.labelParsingSuccess->setText(
"NYI");
177 _ui.labelParsingSuccess->setText(
"Parsed " + QString::number(_lastParsedWPs.size()) +
181 NJointCartesianWaypointControllerRuntimeConfig
182 CartesianWaypointControlGuiWidgetController::readRunCfg()
const
185 NJointCartesianWaypointControllerRuntimeConfig cfg;
187 cfg.wpCfg.maxPositionAcceleration =
static_cast<float>(_ui.doubleSpinBoxMaxAccPos->value());
188 cfg.wpCfg.maxOrientationAcceleration =
189 static_cast<float>(_ui.doubleSpinBoxMaxAccOri->value());
190 cfg.wpCfg.maxNullspaceAcceleration =
191 static_cast<float>(_ui.doubleSpinBoxMaxAccNull->value());
193 cfg.wpCfg.kpJointLimitAvoidance =
194 static_cast<float>(_ui.doubleSpinBoxLimitAvoidKP->value());
195 cfg.wpCfg.jointLimitAvoidanceScale =
196 static_cast<float>(_ui.doubleSpinBoxLimitAvoidScale->value());
198 cfg.wpCfg.thresholdOrientationNear =
static_cast<float>(_ui.doubleSpinBoxOriNear->value());
199 cfg.wpCfg.thresholdOrientationReached =
200 static_cast<float>(_ui.doubleSpinBoxOriReached->value());
201 cfg.wpCfg.thresholdPositionNear =
static_cast<float>(_ui.doubleSpinBoxPosNear->value());
202 cfg.wpCfg.thresholdPositionReached =
203 static_cast<float>(_ui.doubleSpinBoxPosReached->value());
205 cfg.wpCfg.maxOriVel =
static_cast<float>(_ui.doubleSpinBoxOriMaxVel->value());
206 cfg.wpCfg.maxPosVel =
static_cast<float>(_ui.doubleSpinBoxPosMaxVel->value());
207 cfg.wpCfg.kpOri =
static_cast<float>(_ui.doubleSpinBoxOriKP->value());
208 cfg.wpCfg.kpPos =
static_cast<float>(_ui.doubleSpinBoxPosKP->value());
210 cfg.forceThreshold =
static_cast<float>(_ui.doubleSpinBoxFTLimit->value());
211 cfg.optimizeNullspaceIfTargetWasReached = _ui.checkBoxKeepOptimizing->isChecked();
212 cfg.forceThresholdInRobotRootZ = _ui.checkBoxLimitinZ->isChecked();
213 cfg.skipToClosestWaypoint = _ui.checkBoxSkipWaypoints->isChecked();
219 CartesianWaypointControlGuiWidgetController::timerEvent(QTimerEvent* e)
237 for (
const auto& rnsn :
_robot->getRobotNodeSetNames())
239 _ui.comboBoxChain->addItem(QString::fromStdString(rnsn));
240 if (rnsn ==
"RightArm")
242 _ui.comboBoxChain->setCurrentIndex(_ui.comboBoxChain->count() - 1);
246 if (found &&
_robot->hasRobotNode(
"FT R"))
248 _ui.lineEditFTName->setText(
"FT R");
252 NJointControllerConfigPtr
255 NJointCartesianWaypointControllerConfigPtr cfg =
256 new NJointCartesianWaypointControllerConfig;
257 cfg->rns = _ui.comboBoxChain->currentText().toStdString();
258 cfg->ftName = _ui.lineEditFTName->text().toStdString();
259 cfg->runCfg = readRunCfg();
260 return NJointControllerConfigPtr::dynamicCast(cfg);