7 NJointControllerRegistration<NJointAnomalyDetectionAdaptiveWipingController>
9 "NJointAnomalyDetectionAdaptiveWipingController");
12 const RobotUnitPtr& robUnit,
13 const armarx::NJointControllerConfigPtr& config,
17 cfg = NJointAnomalyDetectionAdaptiveWipingControllerConfigPtr::dynamicCast(config);
19 VirtualRobot::RobotNodeSetPtr rns =
rtGetRobot()->getRobotNodeSet(cfg->nodeSetName);
22 for (
size_t i = 0; i < rns->getSize(); ++i)
24 std::string jointName = rns->getNode(i)->getName();
27 targets.push_back(ct->
asA<ControlTarget1DoFActuatorTorque>());
29 const SensorValue1DoFActuatorVelocity* velocitySensor =
30 sv->
asA<SensorValue1DoFActuatorVelocity>();
31 const SensorValue1DoFActuatorPosition* positionSensor =
32 sv->
asA<SensorValue1DoFActuatorPosition>();
34 velocitySensors.push_back(velocitySensor);
35 positionSensors.push_back(positionSensor);
38 useDMPInGlobalFrame = cfg->useDMPInGlobalFrame;
42 nodeSetName = cfg->nodeSetName;
43 ik.reset(
new VirtualRobot::DifferentialIK(
44 rns, rns->getRobot()->getRootNode(), VirtualRobot::JacobiProvider::eSVDDamped));
50 taskSpaceDMPConfig.
DMPMode =
"Linear";
51 taskSpaceDMPConfig.
DMPStyle =
"Periodic";
62 lastCanVal = cfg->timeDuration;
68 for (
size_t i = 0; i < 6; ++i)
79 velocityHorizon = cfg->velocityHorizon;
82 frictionHorizon = cfg->frictionHorizon;
83 estimatedFriction << 0.0, 0.0;
84 lastForceInToolXY.setZero();
91 kpos << cfg->Kpos[0], cfg->Kpos[1], cfg->Kpos[2];
92 dpos << cfg->Dpos[0], cfg->Dpos[1], cfg->Dpos[2];
93 kori << cfg->Kori[0], cfg->Kori[1], cfg->Kori[2];
94 dori << cfg->Dori[0], cfg->Dori[1], cfg->Dori[2];
96 isForceCtrlInForceDir = cfg->isForceCtrlInForceDir;
97 isForceControlEnabled = cfg->isForceControlEnabled;
98 isRotControlEnabled = cfg->isRotControlEnabled;
99 isTorqueControlEnabled = cfg->isTorqueControlEnabled;
100 isLCRControlEnabled = cfg->isLCRControlEnabled;
102 cfg->pidForce[0], cfg->pidForce[1], cfg->pidForce[2], cfg->pidForce[3]));
104 new PIDController(cfg->pidRot[0], cfg->pidRot[1], cfg->pidRot[2], cfg->pidRot[3]));
106 cfg->pidTorque[0], cfg->pidTorque[1], cfg->pidTorque[2], cfg->pidTorque[3]));
108 new PIDController(cfg->pidLCR[0], cfg->pidLCR[1], cfg->pidLCR[2], cfg->pidLCR[3]));
109 adaptKpForce = cfg->pidForce[0];
110 adaptKpRot = cfg->pidRot[0];
112 knull.setZero(targets.size());
113 dnull.setZero(targets.size());
115 for (
size_t i = 0; i < targets.size(); ++i)
117 knull(i) = cfg->Knull.at(i);
118 dnull(i) = cfg->Dnull.at(i);
121 nullSpaceJointsVec.resize(cfg->desiredNullSpaceJointValues.size());
122 for (
size_t i = 0; i < cfg->desiredNullSpaceJointValues.size(); ++i)
124 nullSpaceJointsVec(i) = cfg->desiredNullSpaceJointValues.at(i);
129 robUnit->getSensorDevice(cfg->forceSensorName)->getSensorValue();
135 currentForceOffset.setZero();
136 forceOffset << cfg->ftOffset[0], cfg->ftOffset[1], cfg->ftOffset[2];
137 torqueOffset << cfg->ftOffset[3], cfg->ftOffset[4], cfg->ftOffset[5];
139 handMass = cfg->handMass;
140 handCOM << cfg->handCOM[0], cfg->handCOM[1], cfg->handCOM[2];
143 filteredForce.setZero();
144 filteredTorque.setZero();
145 filteredFTCommand.setZero();
146 filteredForceInRoot.setZero();
147 filteredTorqueInRoot.setZero();
148 targetFTInToolFrame.setZero();
150 UserToRTData initUserData;
151 initUserData.targetForce = 0;
154 oriToolDir << 0, 0, 1;
155 gravityInRoot << 0, 0, -9.8;
157 qvel_filtered.setZero(targets.size());
184 abnormalFlag =
false;
185 lastAbnormalFlag =
false;
186 positionOffset.setZero();
199 RTToControllerData initSensorData;
200 initSensorData.deltaT = 0;
201 initSensorData.currentTime = 0;
202 initSensorData.currentPose = tcp->getPoseInRootFrame();
203 initSensorData.currentTwist.setZero();
204 initSensorData.isPhaseStop =
false;
207 RTToUserData initInterfaceData;
208 initInterfaceData.currentTcpPose = tcp->getPoseInRootFrame();
209 initInterfaceData.waitTimeForCalibration = 0;
214 runTask(
"NJointAnomalyDetectionAdaptiveWipingController",
219 while (
getState() == eManagedIceObjectStarted)
225 c.waitForCycleDuration();
233 return "NJointAnomalyDetectionAdaptiveWipingController";
249 Eigen::VectorXf targetVels(6);
254 targetVels.setZero();
265 dmpCtrl->flow(deltaT, currentPose, currentTwist);
267 targetVels = dmpCtrl->getTargetVelocity();
268 targetDMPPose = dmpCtrl->getTargetPoseMat();
270 debugOutputData.
getWriteBuffer().latestTargetVelocities[
"x_vel"] = targetVels(0);
271 debugOutputData.
getWriteBuffer().latestTargetVelocities[
"y_vel"] = targetVels(1);
272 debugOutputData.
getWriteBuffer().latestTargetVelocities[
"z_vel"] = targetVels(2);
273 debugOutputData.
getWriteBuffer().latestTargetVelocities[
"roll_vel"] = targetVels(3);
274 debugOutputData.
getWriteBuffer().latestTargetVelocities[
"pitch_vel"] = targetVels(4);
275 debugOutputData.
getWriteBuffer().latestTargetVelocities[
"yaw_vel"] = targetVels(5);
276 debugOutputData.
getWriteBuffer().currentPose[
"currentPose_x"] = currentPose(0, 3);
277 debugOutputData.
getWriteBuffer().currentPose[
"currentPose_y"] = currentPose(1, 3);
278 debugOutputData.
getWriteBuffer().currentPose[
"currentPose_z"] = currentPose(2, 3);
280 VirtualRobot::MathTools::eigen4f2quat(currentPose);
281 debugOutputData.
getWriteBuffer().currentPose[
"currentPose_qw"] = currentQ.w;
282 debugOutputData.
getWriteBuffer().currentPose[
"currentPose_qx"] = currentQ.x;
283 debugOutputData.
getWriteBuffer().currentPose[
"currentPose_qy"] = currentQ.y;
284 debugOutputData.
getWriteBuffer().currentPose[
"currentPose_qz"] = currentQ.z;
285 debugOutputData.
getWriteBuffer().currentCanVal = dmpCtrl->debugData.canVal;
286 debugOutputData.
getWriteBuffer().mpcFactor = dmpCtrl->debugData.mpcFactor;
287 debugOutputData.
getWriteBuffer().error = dmpCtrl->debugData.poseError;
288 debugOutputData.
getWriteBuffer().posError = dmpCtrl->debugData.posiError;
289 debugOutputData.
getWriteBuffer().oriError = dmpCtrl->debugData.oriError;
307 double deltaT = timeSinceLastIteration.toSecondsDouble();
308 float dTf = (
float)deltaT;
313 Eigen::Vector3f currentToolDir;
314 currentToolDir.setZero();
315 Eigen::MatrixXf jacobi =
316 ik->getJacobianMatrix(tcp, VirtualRobot::IKSolver::CartesianSelection::All);
318 Eigen::VectorXf qpos(positionSensors.size());
319 Eigen::VectorXf qvel(velocitySensors.size());
320 for (
size_t i = 0; i < positionSensors.size(); ++i)
322 qpos(i) = positionSensors[i]->position;
323 qvel(i) = velocitySensors[i]->velocity;
326 qvel_filtered = (1 - cfg->velFilter) * qvel_filtered + cfg->velFilter * qvel;
327 Eigen::VectorXf currentTwist = jacobi * qvel_filtered;
329 velocityHorizonList.push_back(currentTwist);
330 if (velocityHorizonList.size() > velocityHorizon)
332 velocityHorizonList.pop_front();
335 Eigen::VectorXf targetVel(6);
336 Eigen::Vector3f axis;
337 Eigen::Vector3f forceInToolFrame;
338 Eigen::Vector3f torqueInToolFrame;
340 Eigen::Vector3f velPInToolFrame;
343 forceInToolFrame.setZero();
344 torqueInToolFrame.setZero();
345 targetFTInRootFrame.setZero();
346 velPInToolFrame.setZero();
348 bool isPhaseStop =
false;
350 if (firstRun || !dmpRunning)
352 initHandPose = currentPose;
353 lastPosition = currentPose.block<2, 1>(0, 3);
354 targetPose = currentPose;
356 filteredForce.setZero();
357 Eigen::Vector3f currentForce = forceSensor->
force - forceOffset;
360 ->getRobotNode(cfg->forceFrameName)
361 ->getPoseInRootFrame()
363 Eigen::Vector3f gravityInForceFrame = forceFrameOri.transpose() * gravityInRoot;
364 Eigen::Vector3f handGravity = handMass * gravityInForceFrame;
365 currentForce = currentForce - handGravity;
367 currentForceOffset = 0.1 * currentForceOffset + 0.9 * currentForce;
368 origHandOri = currentPose.block<3, 3>(0, 0);
369 toolTransform = origHandOri.transpose();
378 Eigen::Matrix3f currentToolOri = currentPose.block<3, 3>(0, 0) * toolTransform;
382 targetVel.head(3) = currentToolOri * targetVel.head(3);
383 targetVel.tail(3) = currentToolOri * targetVel.tail(3);
386 if (canVal - lastCanVal > 0.9 * cfg->timeDuration)
394 Eigen::Vector3f currentForce = forceSensor->
force - forceOffset - currentForceOffset;
397 ->getRobotNode(cfg->forceFrameName)
398 ->getPoseInRootFrame()
400 Eigen::Vector3f gravityInForceFrame = forceFrameOri.transpose() * gravityInRoot;
401 Eigen::Vector3f handGravity = handMass * gravityInForceFrame;
403 currentForce = currentForce - handGravity;
405 (1 - cfg->forceFilter) * filteredForce + cfg->forceFilter * currentForce;
407 Eigen::Vector3f currentTorque = forceSensor->
torque - torqueOffset;
408 Eigen::Vector3f handTorque = handCOM.cross(gravityInForceFrame);
409 currentTorque = currentTorque - handTorque;
411 (1 - cfg->forceFilter) * filteredTorque + cfg->forceFilter * currentTorque;
413 Eigen::Vector3f forceInRootForFricEst = forceFrameOri * filteredForce;
414 Eigen::Vector3f forceInToolForFricEst =
415 currentToolOri.transpose() * forceInRootForFricEst;
417 for (
size_t i = 0; i < 3; ++i)
419 if (fabs(filteredForce(i)) > cfg->forceDeadZone)
422 (filteredForce(i) / fabs(filteredForce(i))) * cfg->forceDeadZone;
426 filteredForce(i) = 0;
430 filteredForceInRoot = forceFrameOri * filteredForce;
431 filteredTorqueInRoot = forceFrameOri * filteredTorque;
434 forceInToolFrame = currentToolOri.transpose() * filteredForceInRoot;
436 torqueInToolFrame = currentToolOri.transpose() * filteredTorqueInRoot;
437 velPInToolFrame = currentToolOri.transpose() * currentTwist.head(3);
443 if (abnormalFlag ==
true && filteredForceInRoot.norm() > cfg->dragForceDeadZone)
447 adaptKpForce *= cfg->adaptRateDecrease;
448 adaptKpRot *= cfg->adaptRateDecreaseRot;
449 forcePID->Kp = adaptKpForce;
450 torquePID->Kp = adaptKpRot;
457 adaptK *= cfg->adaptRateDecrease;
458 adaptD *= cfg->adaptRateDecrease;
459 if (cfg->isAdaptOriImpEnabled)
461 adaptKOri *= cfg->adaptRateDecrease;
462 adaptDOri *= cfg->adaptRateDecrease;
464 adaptKNull *= cfg->adaptRateDecrease;
465 adaptDNull *= cfg->adaptRateDecrease;
467 positionOffset.setZero();
475 fmin(adaptKpForce + dTf * cfg->increaseKpForceCoeff, cfg->pidForce[0]);
476 adaptKpRot = fmin(adaptKpRot + dTf * cfg->increaseKpRotCoeff, cfg->pidRot[0]);
479 forcePID->Kp = adaptKpForce;
480 torquePID->Kp = adaptKpRot;
481 for (
int i = 0; i < 3; i++)
483 adaptK(i) = fmin(adaptK(i) + fabs(dTf * cfg->adaptCoeff), kpos(i));
484 adaptD(i) = fmin(adaptD(i) + fabs(dTf * cfg->adaptCoeffKdImpIncrease), dpos(i));
485 if (cfg->isAdaptOriImpEnabled)
488 fmin(adaptKOri(i) + fabs(dTf * cfg->increaseKpOriCoeff), kori(i));
490 fmin(adaptDOri(i) + fabs(dTf * cfg->increaseKdOriCoeff), dori(i));
493 for (
size_t i = 0; i < targets.size(); i++)
496 fmin(adaptKNull(i) + fabs(dTf * cfg->increaseKpNullCoeff), knull(i));
498 fmin(adaptDNull(i) + fabs(dTf * cfg->increaseKdNullCoeff), dnull(i));
505 if (!isContactedOnce && fabs(forceInToolFrame(2)) > targetForce)
507 isContactedOnce =
true;
509 if (cfg->loseContactDetectionEnabled && isContactedOnce)
511 if (abnormalFlag && !lastAbnormalFlag)
513 startLoseContactDetection =
true;
514 loseContactCounter = 0;
517 if (startLoseContactDetection && loseContactCounter < cfg->loseContactCounterMax)
519 forceIntegral += forceInToolFrame.norm() * deltaT;
520 loseContactCounter++;
522 if (loseContactCounter >= cfg->loseContactCounterMax &&
523 forceIntegral < cfg->loseContactForceIntThreshold)
525 isLoseContact =
true;
527 lastAbnormalFlag = abnormalFlag;
542 Eigen::Vector2f v_xy;
543 Eigen::Vector2f f_xy;
544 v_xy << velPInToolFrame(0), velPInToolFrame(1);
545 f_xy << forceInToolForFricEst(0), forceInToolForFricEst(1);
546 f_xy = cfg->fricEstiFilter * f_xy + (1 - cfg->fricEstiFilter) * lastForceInToolXY;
547 lastForceInToolXY = f_xy;
549 if (wipingCounter > 0)
551 if (v_xy.norm() > cfg->velNormThreshold &&
552 fabs(forceInToolForFricEst(2) - targetForce) < 0.5 * targetForce)
554 recordFrictionNorm.push_back(f_xy.norm());
555 recordForceNormToSurface.push_back(forceInToolForFricEst(2));
557 if (recordFrictionNorm.size() > frictionHorizon)
559 recordFrictionNorm.pop_front();
560 recordForceNormToSurface.pop_front();
561 float dotProduct = 0.0;
562 float normSquare = 0.0;
563 for (
size_t i = 0; i < recordFrictionNorm.size(); i++)
565 dotProduct += (recordFrictionNorm[i] * recordForceNormToSurface[i]);
566 normSquare += (recordForceNormToSurface[i] * recordForceNormToSurface[i]);
570 float mu_tmp = dotProduct / normSquare;
573 mu = fmax(fmin(mu, mu_tmp), safeFrictionConeLowerLimit);
576 if (v_xy.norm() > cfg->velNormThreshold)
578 estimatedFriction = -v_xy * mu * forceInToolForFricEst(2) / v_xy.norm();
585 if (isForceCtrlInForceDir)
587 forcePID->update(deltaT, forceInToolFrame.norm(), targetForce);
591 forcePID->update(deltaT, forceInToolFrame(2), targetForce);
593 torquePID->update(deltaT, torqueInToolFrame(1), 0.0);
597 currentToolDir = currentToolOri * oriToolDir;
598 for (
int i = 3; i < 6; ++i)
603 if (cfg->frictionCone < 0.0)
605 frictionCone = atan(mu);
610 frictionCone = cfg->frictionCone;
612 float adaptedAngularKp = 0.0;
613 Eigen::Vector3f angularDiff;
614 angularDiff.setZero();
616 if (filteredForceInRoot.norm() > fabs(cfg->minimumReactForce))
618 Eigen::Vector3f toolYDir;
619 toolYDir << 0, 1.0, 0;
620 Eigen::Vector3f toolYDirInRoot = currentToolOri * toolYDir;
621 Eigen::Vector3f projectedFilteredForceInRoot =
622 filteredForceInRoot - filteredForceInRoot.dot(toolYDirInRoot) * toolYDirInRoot;
623 Eigen::Vector3f desiredToolDir =
624 projectedFilteredForceInRoot
626 currentToolDir.normalize();
628 axis = currentToolDir.cross(desiredToolDir);
629 axis = axis.normalized();
630 angle = acosf(currentToolDir.dot(desiredToolDir));
642 cfg->pidRot[0] / (1 + exp(10 * (
angle - cfg->rotAngleSigmoid)));
643 adaptedAngularKp = fmin(adaptedAngularKp, cfg->pidRot[0]);
644 rotPID->Kp = adaptedAngularKp;
645 angle -= frictionCone;
651 rotPID->Kp = cfg->pidRot[0];
654 rotPID->update(deltaT,
angle, 0.0);
716 float diff = (targetPose.block<2, 1>(0, 3) - currentPose.block<2, 1>(0, 3)).
norm();
717 if (diff > cfg->phaseDist0)
730 if (isForceControlEnabled)
732 if (isForceCtrlInForceDir)
734 float forcePIDVel = -(
float)forcePID->getControlValue();
735 Eigen::Vector3f targetVelInTool;
736 if (forceInToolFrame.norm() < 1e-4)
738 targetVelInTool << 0, 0, forcePIDVel;
742 targetVelInTool = forceInToolFrame / forceInToolFrame.norm() * forcePIDVel;
744 targetVel.head(3) += currentToolOri * targetVelInTool;
749 Eigen::Vector3f localVel;
750 localVel << 0, 0, -(
float)forcePID->getControlValue();
751 positionOffset += currentToolOri * localVel * deltaT;
753 targetVel(2) -= (
float)forcePID->getControlValue();
754 targetVel.head(3) = currentToolOri * targetVel.head(3);
759 positionOffset.setZero();
762 if (isRotControlEnabled)
766 targetVel(4) -= (
float)rotPID->getControlValue();
768 if (isTorqueControlEnabled)
771 targetVel(4) += (
float)torquePID->getControlValue();
787 if (useDMPInGlobalFrame)
790 targetPose.block<3, 1>(0, 3) += positionOffset;
794 targetPose.block<3, 1>(0, 3) =
795 targetPose.block<3, 1>(0, 3) + dTf * targetVel.block<3, 1>(0, 0);
797 dTf * targetVel(3), dTf * targetVel(4), dTf * targetVel(5));
798 targetPose.block<3, 3>(0, 0) = rotMat * targetPose.block<3, 3>(0, 0);
802 Eigen::Vector2f currentXY = currentPose.block<2, 1>(0, 3);
803 if ((lastPosition - currentXY).norm() < cfg->changePositionTolerance)
805 changeTimer += deltaT;
809 lastPosition = currentPose.block<2, 1>(0, 3);
813 if (changeTimer > cfg->changeTimerThreshold)
815 targetPose(0, 3) = currentPose(0, 3);
816 targetPose(1, 3) = currentPose(1, 3);
827 targetPose(0, 3) = targetPose(0, 3) > cfg->ws_x[0] ? targetPose(0, 3) : cfg->ws_x[0];
828 targetPose(0, 3) = targetPose(0, 3) < cfg->ws_x[1] ? targetPose(0, 3) : cfg->ws_x[1];
830 targetPose(1, 3) = targetPose(1, 3) > cfg->ws_y[0] ? targetPose(1, 3) : cfg->ws_y[0];
831 targetPose(1, 3) = targetPose(1, 3) < cfg->ws_y[1] ? targetPose(1, 3) : cfg->ws_y[1];
833 targetPose(2, 3) = targetPose(2, 3) > cfg->ws_z[0] ? targetPose(2, 3) : cfg->ws_z[0];
834 targetPose(2, 3) = targetPose(2, 3) < cfg->ws_z[1] ? targetPose(2, 3) : cfg->ws_z[1];
839 jacobi.block<3, 8>(0, 0) = 0.001 * jacobi.block<3, 8>(0, 0);
842 targetPose.block<3, 3>(0, 0) * currentPose.block<3, 3>(0, 0).transpose();
843 Eigen::Vector3f rpy = VirtualRobot::MathTools::eigen3f2rpy(diffMat);
850 taskFTControlCommand.head(3) =
851 adaptK.cwiseProduct(targetPose.block<3, 1>(0, 3) - currentPose.block<3, 1>(0, 3)) *
853 adaptD.cwiseProduct(-currentTwist.head(3)) * 0.001 + targetFTInRootFrame.head(3);
854 taskFTControlCommand.tail(3) = kori.cwiseProduct(rpy) +
855 dori.cwiseProduct(-currentTwist.tail(3)) +
856 targetFTInRootFrame.tail(3);
858 filteredFTCommand = cfg->ftCommandFilter * taskFTControlCommand +
859 (1 - cfg->ftCommandFilter) * filteredFTCommand;
864 Eigen::VectorXf nullspaceTorque =
865 knull.cwiseProduct(nullSpaceJointsVec - qpos) - dnull.cwiseProduct(qvel);
866 Eigen::MatrixXf jtpinv = ik->computePseudoInverseJacobianMatrix(jacobi.transpose(), 2.0);
867 Eigen::VectorXf jointDesiredTorques = jacobi.transpose() * filteredFTCommand +
868 (I - jacobi.transpose() * jtpinv) * nullspaceTorque;
874 for (
size_t i = 0; i < targets.size(); ++i)
876 targets.at(i)->torque = jointDesiredTorques(i);
878 if (!targets.at(i)->isValid())
880 targets.at(i)->torque = 0.0f;
884 if (fabs(targets.at(i)->torque) > fabs(cfg->maxJointTorque))
886 targets.at(i)->torque = fabs(cfg->maxJointTorque) *
887 (targets.at(i)->torque / fabs(targets.at(i)->torque));
895 tcp->getRobot()->getRootNode()->toGlobalCoordinateSystemVec(currentToolDir);
898 tcp->getRobot()->getRootNode()->toGlobalCoordinateSystem(targetPose);
900 debugRT.
getWriteBuffer().filteredForceInRoot = filteredForceInRoot;
904 tcp->getRobot()->getRootNode()->toGlobalCoordinateSystemVec(filteredForceInRoot);
919 debugRT.
getWriteBuffer().loseContactForceIntegral = forceIntegral;
935 const Ice::StringSeq& fileNames,
941 dmpCtrl->learnDMPFromFiles(fileNames);
946 const TrajectoryBasePtr& trajectory,
951 TrajectoryPtr dmpTraj = TrajectoryPtr::dynamicCast(trajectory);
955 dmpCtrl->learnDMPFromTrajectory(dmpTraj);
962 dmpCtrl->setSpeed(times);
968 const Ice::Current& ice)
971 dmpCtrl->setGoalPoseVec(goals);
979 dmpCtrl->setAmplitude(amp);
998 cfg->waitTimeForCalibration)
1007 dmpCtrl->prepareExecution(dmpCtrl->eigen4f2vec(pose), goals);
1008 dmpCtrl->setSpeed(tau);
1017 const Ice::Current&)
1019 abnormalFlag = abnormal;
1027 std::vector<float> tvelvec = {
1028 tvel(0), tvel(1), tvel(2), tpos(0, 3) / 1000, tpos(1, 3) / 1000, tpos(2, 3) / 1000};
1036 std::vector<float> forceVec = {force(0), force(1), force(2)};
1047 std::string datafieldName;
1048 std::string debugName =
"Periodic";
1052 datafields[
"target_x"] =
new Variant(targetPoseDebug(0, 3));
1053 datafields[
"target_y"] =
new Variant(targetPoseDebug(1, 3));
1054 datafields[
"target_z"] =
new Variant(targetPoseDebug(2, 3));
1057 VirtualRobot::MathTools::eigen4f2quat(targetPoseDebug);
1058 datafields[
"target_qw"] =
new Variant(qtarget.w);
1059 datafields[
"target_qx"] =
new Variant(qtarget.x);
1060 datafields[
"target_qy"] =
new Variant(qtarget.y);
1061 datafields[
"target_qz"] =
new Variant(qtarget.z);
1065 datafields[
"current_x"] =
new Variant(currentPoseDebug(0, 3));
1066 datafields[
"current_y"] =
new Variant(currentPoseDebug(1, 3));
1067 datafields[
"current_z"] =
new Variant(currentPoseDebug(2, 3));
1071 VirtualRobot::MathTools::eigen4f2quat(currentPoseDebug);
1072 datafields[
"current_qw"] =
new Variant(qcurrent.w);
1073 datafields[
"current_qx"] =
new Variant(qcurrent.x);
1074 datafields[
"current_qy"] =
new Variant(qcurrent.y);
1075 datafields[
"current_qz"] =
new Variant(qcurrent.z);
1079 datafields[
"filteredforceInTool_x"] =
new Variant(filteredForce(0));
1080 datafields[
"filteredforceInTool_y"] =
new Variant(filteredForce(1));
1081 datafields[
"filteredforceInTool_z"] =
new Variant(filteredForce(2));
1084 datafields[
"filteredtorqueInTool_x"] =
new Variant(filteredTorque(0));
1085 datafields[
"filteredtorqueInTool_y"] =
new Variant(filteredTorque(1));
1086 datafields[
"filteredtorqueInTool_z"] =
new Variant(filteredTorque(2));
1090 datafields[
"filteredForceInRoot_x"] =
new Variant(filteredForceInRoot(0));
1091 datafields[
"filteredForceInRoot_y"] =
new Variant(filteredForceInRoot(1));
1092 datafields[
"filteredForceInRoot_z"] =
new Variant(filteredForceInRoot(2));
1095 datafields[
"rotationAxis_x"] =
new Variant(rotationAxis(0));
1096 datafields[
"rotationAxis_y"] =
new Variant(rotationAxis(1));
1097 datafields[
"rotationAxis_z"] =
new Variant(rotationAxis(2));
1100 datafields[
"reactForce_x"] =
new Variant(reactForce(0));
1101 datafields[
"reactForce_y"] =
new Variant(reactForce(1));
1102 datafields[
"reactForce_z"] =
new Variant(reactForce(2));
1105 datafields[
"targetVel_x"] =
new Variant(targetVel(0));
1106 datafields[
"targetVel_y"] =
new Variant(targetVel(1));
1107 datafields[
"targetVel_z"] =
new Variant(targetVel(2));
1108 datafields[
"targetVel_ro"] =
new Variant(targetVel(3));
1109 datafields[
"targetVel_pi"] =
new Variant(targetVel(4));
1110 datafields[
"targetVel_ya"] =
new Variant(targetVel(5));
1113 datafields[
"currentTwist_x"] =
new Variant(currentTwist(0));
1114 datafields[
"currentTwist_y"] =
new Variant(currentTwist(1));
1115 datafields[
"currentTwist_z"] =
new Variant(currentTwist(2));
1116 datafields[
"currentTwist_ro"] =
new Variant(currentTwist(3));
1117 datafields[
"currentTwist_pi"] =
new Variant(currentTwist(4));
1118 datafields[
"currentTwist_ya"] =
new Variant(currentTwist(5));
1122 datafields[
"adaptK_x"] =
new Variant(adaptK(0));
1123 datafields[
"adaptK_y"] =
new Variant(adaptK(1));
1124 datafields[
"adaptK_z"] =
new Variant(adaptK(2));
1127 datafields[
"adaptD_x"] =
new Variant(adaptD(0));
1128 datafields[
"adaptD_y"] =
new Variant(adaptD(1));
1129 datafields[
"adaptD_z"] =
new Variant(adaptD(2));
1138 datafields[
"loseContactForceIntegral"] =
1142 datafields[
"estimatedFriction_x"] =
new Variant(estFri(0));
1143 datafields[
"estimatedFriction_y"] =
new Variant(estFri(1));
1146 datafields[
"frictionInToolXY_x"] =
new Variant(frictionInToolXY(0));
1147 datafields[
"frictionInToolXY_y"] =
new Variant(frictionInToolXY(1));
1150 datafields[
"velPInTool_x"] =
new Variant(velPInTool(0));
1151 datafields[
"velPInTool_y"] =
new Variant(velPInTool(1));
1152 datafields[
"velPInTool_z"] =
new Variant(velPInTool(2));
1188 datafieldName =
"PeriodicDMP";
1189 debugObs->setDebugChannel(datafieldName, datafields);
1194 Eigen::Vector3f handPosition = globalPose.block<3, 1>(0, 3);
1197 debugDrawer->setArrowVisu(
"Force",
1201 DrawColor{0, 0, 1, 1},
1202 10 * forceDir.norm(),
1207 debugDrawer->setArrowVisu(
"Tool",
1211 DrawColor{1, 0, 0, 1},
1214 debugDrawer->setPoseVisu(
"target",
"targetPose",
new Pose(globalPose));
1221 dmpCtrl->pauseController();
1227 dmpCtrl->resumeController();