14 cfg = NJointBimanualForceControllerConfigPtr::dynamicCast(config);
18 leftRNS =
rtGetRobot()->getRobotNodeSet(
"LeftArm");
20 for (
size_t i = 0; i < leftRNS->getSize(); ++i)
22 std::string jointName = leftRNS->getNode(i)->getName();
23 leftJointNames.push_back(jointName);
26 leftTargets.push_back(ct->
asA<ControlTarget1DoFActuatorTorque>());
27 const SensorValue1DoFActuatorVelocity* velocitySensor = sv->
asA<SensorValue1DoFActuatorVelocity>();
28 const SensorValue1DoFActuatorPosition* positionSensor = sv->
asA<SensorValue1DoFActuatorPosition>();
40 leftVelocitySensors.push_back(velocitySensor);
41 leftPositionSensors.push_back(positionSensor);
45 rightRNS =
rtGetRobot()->getRobotNodeSet(
"RightArm");
47 for (
size_t i = 0; i < rightRNS->getSize(); ++i)
49 std::string jointName = rightRNS->getNode(i)->getName();
50 rightJointNames.push_back(jointName);
53 rightTargets.push_back(ct->
asA<ControlTarget1DoFActuatorTorque>());
55 const SensorValue1DoFActuatorVelocity* velocitySensor = sv->
asA<SensorValue1DoFActuatorVelocity>();
56 const SensorValue1DoFActuatorPosition* positionSensor = sv->
asA<SensorValue1DoFActuatorPosition>();
67 rightVelocitySensors.push_back(velocitySensor);
68 rightPositionSensors.push_back(positionSensor);
74 const SensorValueBase* svlf = robUnit->getSensorDevice(
"FT L")->getSensorValue();
77 const SensorValueBase* svrf = robUnit->getSensorDevice(
"FT R")->getSensorValue();
80 leftIK.reset(
new VirtualRobot::DifferentialIK(leftRNS, leftRNS->getRobot()->getRootNode(), VirtualRobot::JacobiProvider::eSVDDamped));
81 rightIK.reset(
new VirtualRobot::DifferentialIK(rightRNS, rightRNS->getRobot()->getRootNode(), VirtualRobot::JacobiProvider::eSVDDamped));
87 taskSpaceDMPConfig.
DMPMode = cfg->dmpMode;
88 taskSpaceDMPConfig.
DMPStyle = cfg->dmpType;
105 tcpLeft = leftRNS->getTCP();
106 tcpRight = rightRNS->getTCP();
108 KpImpedance.resize(cfg->KpImpedance.size());
111 for (
int i = 0; i < KpImpedance.size(); ++i)
113 KpImpedance(i) = cfg->KpImpedance.at(i);
116 KdImpedance.resize(cfg->KdImpedance.size());
119 for (
int i = 0; i < KdImpedance.size(); ++i)
121 KdImpedance(i) = cfg->KdImpedance.at(i);
124 KpAdmittance.resize(cfg->KpAdmittance.size());
127 for (
int i = 0; i < KpAdmittance.size(); ++i)
129 KpAdmittance(i) = cfg->KpAdmittance.at(i);
132 KdAdmittance.resize(cfg->KdAdmittance.size());
135 for (
int i = 0; i < KdAdmittance.size(); ++i)
137 KdAdmittance(i) = cfg->KdAdmittance.at(i);
140 KmAdmittance.resize(cfg->KmAdmittance.size());
143 for (
int i = 0; i < KmAdmittance.size(); ++i)
145 KmAdmittance(i) = cfg->KmAdmittance.at(i);
148 leftDesiredJointValues.resize(leftTargets.size());
151 for (
size_t i = 0; i < leftTargets.size(); ++i)
153 leftDesiredJointValues(i) = cfg->leftDesiredJointValues.at(i);
156 rightDesiredJointValues.resize(rightTargets.size());
159 for (
size_t i = 0; i < rightTargets.size(); ++i)
161 rightDesiredJointValues(i) = cfg->rightDesiredJointValues.at(i);
164 KmPID.resize(cfg->KmPID.size());
167 for (
int i = 0; i < KmPID.size(); ++i)
169 KmPID(i) = cfg->KmPID.at(i);
174 modifiedAcc.setZero(12);
175 modifiedTwist.setZero(12);
179 boxInitialPose = VirtualRobot::MathTools::quat2eigen4f(cfg->boxInitialPose[4], cfg->boxInitialPose[5], cfg->boxInitialPose[6], cfg->boxInitialPose[3]);
180 for (
int i = 0; i < 3; ++i)
182 boxInitialPose(i, 3) = cfg->boxInitialPose[i];
185 NJointBimanualForceControllerSensorData initSensorData;
186 initSensorData.deltaT = 0;
187 initSensorData.currentTime = 0;
188 initSensorData.currentPose = boxInitialPose;
189 initSensorData.currentTwist.setZero();
193 NJointBimanualForceControllerInterfaceData initInterfaceData;
194 initInterfaceData.currentLeftPose = tcpLeft->getPoseInRootFrame();
195 initInterfaceData.currentRightPose = tcpRight->getPoseInRootFrame();
198 leftInitialPose = boxInitialPose;
199 leftInitialPose(0, 3) -= cfg->boxWidth;
200 rightInitialPose = boxInitialPose;
201 rightInitialPose(0, 3) += cfg->boxWidth;
203 forcePIDControllers.resize(12);
204 for (
size_t i = 0; i < 6; i++)
206 forcePIDControllers.at(i).reset(
new PIDController(cfg->forceP[i], cfg->forceI[i], cfg->forceD[i], cfg->forcePIDLimits[i]));
207 forcePIDControllers.at(i + 6).reset(
new PIDController(cfg->forceP[i], cfg->forceI[i], cfg->forceD[i], cfg->forcePIDLimits[i]));
208 forcePIDControllers.at(i)->reset();
209 forcePIDControllers.at(i + 6)->reset();
213 filterCoeff = cfg->filterCoeff;
215 filteredOldValue.setZero(12);
218 massLeft = cfg->massLeft;
219 CoMVecLeft << cfg->CoMVecLeft[0], cfg->CoMVecLeft[1], cfg->CoMVecLeft[2];
220 forceOffsetLeft << cfg->forceOffsetLeft[0], cfg->forceOffsetLeft[1], cfg->forceOffsetLeft[2];
221 torqueOffsetLeft << cfg->torqueOffsetLeft[0], cfg->torqueOffsetLeft[1], cfg->torqueOffsetLeft[2];
223 massRight = cfg->massRight;
224 CoMVecRight << cfg->CoMVecRight[0], cfg->CoMVecRight[1], cfg->CoMVecRight[2];
225 forceOffsetRight << cfg->forceOffsetRight[0], cfg->forceOffsetRight[1], cfg->forceOffsetRight[2];
226 torqueOffsetRight << cfg->torqueOffsetRight[0], cfg->torqueOffsetRight[1], cfg->torqueOffsetRight[2];
228 sensorFrame2TcpFrameLeft.setZero();
229 sensorFrame2TcpFrameRight.setZero();
232 initData.
boxPose = boxInitialPose;
237 ARMARX_INFO <<
"left initial pose: \n" << leftInitialPose <<
"\n right initial pose: \n" << rightInitialPose;
244 targetWrench.setZero(cfg->targetWrench.size());
245 for (
size_t i = 0; i < cfg->targetWrench.size(); ++i)
247 targetWrench(i) = cfg->targetWrench[i];
256 return "NJointBimanualForceController";
281 Eigen::VectorXf currentTwist = controllerSensorData.
getReadBuffer().currentTwist;
283 if (objectDMP->canVal < 1e-8)
288 objectDMP->flow(deltaT, currentPose, currentTwist);
303 modifiedLeftPose = tcpLeft->getPoseInRootFrame();
304 modifiedRightPose = tcpRight->getPoseInRootFrame();
305 modifiedLeftPose.block<3, 1>(0, 3) = modifiedLeftPose.block<3, 1>(0, 3) * 0.001;
306 modifiedRightPose.block<3, 1>(0, 3) = modifiedRightPose.block<3, 1>(0, 3) * 0.001;
310 leftSensorFrame.block<3, 1>(0, 3) = leftSensorFrame.block<3, 1>(0, 3) * 0.001;
311 rightSensorFrame.block<3, 1>(0, 3) = rightSensorFrame.block<3, 1>(0, 3) * 0.001;
313 sensorFrame2TcpFrameLeft.block<3, 3>(0, 0) = modifiedLeftPose.block<3, 3>(0, 0).transpose() * leftSensorFrame.block<3, 3>(0, 0);
314 sensorFrame2TcpFrameRight.block<3, 3>(0, 0) = modifiedRightPose.block<3, 3>(0, 0).transpose() * rightSensorFrame.block<3, 3>(0, 0);
315 CoMVecLeft = sensorFrame2TcpFrameLeft.block<3, 3>(0, 0) * CoMVecLeft;
316 CoMVecRight = sensorFrame2TcpFrameRight.block<3, 3>(0, 0) * CoMVecRight;
318 ARMARX_INFO <<
"modified left pose:\n " << modifiedLeftPose;
319 ARMARX_INFO <<
"modified right pose:\n " << modifiedRightPose;
321 double deltaT = timeSinceLastIteration.toSecondsDouble();
325 Eigen::Vector3f rToBoxCoM;
326 rToBoxCoM << cfg->boxWidth, 0, 0;
331 interfaceData.
getWriteBuffer().currentRightPose = currentRightPose;
334 Eigen::VectorXf currentTargetWrench = targetWrench;
335 if (fabs(currentLeftPose(0, 3) - currentRightPose(0, 3)) < 0.8 * 2 * cfg->boxWidth)
337 currentTargetWrench.setZero();
339 currentLeftPose.block<3, 1>(0, 3) = 0.001 * currentLeftPose.block<3, 1>(0, 3);
340 currentRightPose.block<3, 1>(0, 3) = 0.001 * currentRightPose.block<3, 1>(0, 3);
341 Eigen::MatrixXf graspMatrix;
342 graspMatrix.setZero(6, 12);
345 Eigen::Vector3f r = - currentLeftPose.block<3, 3>(0, 0) * rToBoxCoM;
346 graspMatrix(4, 2) = -r(0);
347 graspMatrix(3, 2) = r(1);
348 graspMatrix(3, 1) = -r(2);
349 graspMatrix(4, 0) = r(2);
350 graspMatrix(5, 0) = -r(1);
351 graspMatrix(5, 1) = r(0);
352 r = currentRightPose.block<3, 3>(0, 0) * rToBoxCoM;
353 graspMatrix(4, 8) = -r(0);
354 graspMatrix(3, 8) = r(1);
355 graspMatrix(3, 7) = -r(2);
356 graspMatrix(4, 6) = r(2);
357 graspMatrix(5, 6) = -r(1);
358 graspMatrix(5, 7) = r(0);
360 Eigen::MatrixXf pinvG = leftIK->computePseudoInverseJacobianMatrix(graspMatrix, 0);
361 Eigen::MatrixXf G_range = pinvG * graspMatrix;
366 boxCurrentPose.block<3, 1>(0, 3) = 0.5 * (currentLeftPose.block<3, 1>(0, 3) + currentRightPose.block<3, 1>(0, 3));
367 Eigen::VectorXf boxCurrentTwist;
368 boxCurrentTwist.setZero(6);
373 Eigen::MatrixXf jacobiL = leftIK->getJacobianMatrix(tcpLeft, VirtualRobot::IKSolver::CartesianSelection::All);
375 Eigen::VectorXf leftqpos;
376 Eigen::VectorXf leftqvel;
377 leftqpos.resize(leftPositionSensors.size());
378 leftqvel.resize(leftVelocitySensors.size());
379 for (
size_t i = 0; i < leftVelocitySensors.size(); ++i)
381 leftqpos(i) = leftPositionSensors[i]->position;
382 leftqvel(i) = leftVelocitySensors[i]->velocity;
385 Eigen::MatrixXf jacobiR = rightIK->getJacobianMatrix(tcpRight, VirtualRobot::IKSolver::CartesianSelection::All);
388 jacobiL.block<3, 8>(0, 0) = 0.001 * jacobiL.block<3, 8>(0, 0);
389 jacobiR.block<3, 8>(0, 0) = 0.001 * jacobiR.block<3, 8>(0, 0);
391 Eigen::VectorXf rightqpos;
392 Eigen::VectorXf rightqvel;
393 rightqpos.resize(rightPositionSensors.size());
394 rightqvel.resize(rightVelocitySensors.size());
396 for (
size_t i = 0; i < rightVelocitySensors.size(); ++i)
398 rightqpos(i) = rightPositionSensors[i]->position;
399 rightqvel(i) = rightVelocitySensors[i]->velocity;
403 Eigen::VectorXf currentLeftTwist = jacobiL * leftqvel;
404 Eigen::VectorXf currentRightTwist = jacobiR * rightqvel;
405 Eigen::VectorXf currentTwist(12);
406 currentTwist << currentLeftTwist, currentRightTwist;
407 Eigen::MatrixXf pinvGraspMatrixT = leftIK->computePseudoInverseJacobianMatrix(graspMatrix.transpose(), 0);
408 boxCurrentTwist = pinvGraspMatrixT * currentTwist;
413 controllerSensorData.
getWriteBuffer().currentPose = boxCurrentPose;
414 controllerSensorData.
getWriteBuffer().currentTwist = boxCurrentTwist;
425 Eigen::VectorXf leftJointControlWrench;
426 Eigen::VectorXf rightJointControlWrench;
439 Eigen::VectorXf twistDMP = graspMatrix.transpose() * boxTwist;
440 Eigen::VectorXf deltaInitialPose = deltaT * twistDMP;
441 leftInitialPose.block<3, 1>(0, 3) = leftInitialPose.block<3, 1>(0, 3) + deltaInitialPose.block<3, 1>(0, 0);
442 rightInitialPose.block<3, 1>(0, 3) = rightInitialPose.block<3, 1>(0, 3) + deltaInitialPose.block<3, 1>(6, 0);
443 leftInitialPose.block<3, 3>(0, 0) = VirtualRobot::MathTools::rpy2eigen3f(deltaInitialPose(3), deltaInitialPose(4), deltaInitialPose(5)) * leftInitialPose.block<3, 3>(0, 0);
444 rightInitialPose.block<3, 3>(0, 0) = VirtualRobot::MathTools::rpy2eigen3f(deltaInitialPose(9), deltaInitialPose(10), deltaInitialPose(11)) * rightInitialPose.block<3, 3>(0, 0);
449 Eigen::Vector3f gravity;
450 gravity << 0.0, 0.0, -9.8;
451 Eigen::Vector3f localGravityLeft = currentLeftPose.block<3, 3>(0, 0).
transpose() * gravity;
452 Eigen::Vector3f localForceVecLeft = massLeft * localGravityLeft;
453 Eigen::Vector3f localTorqueVecLeft = CoMVecLeft.cross(localForceVecLeft);
455 Eigen::Vector3f localGravityRight = currentRightPose.block<3, 3>(0, 0).
transpose() * gravity;
456 Eigen::Vector3f localForceVecRight = massRight * localGravityRight;
457 Eigen::Vector3f localTorqueVecRight = CoMVecRight.cross(localForceVecRight);
460 Eigen::VectorXf wrenchesMeasured(12);
461 wrenchesMeasured << leftForceTorque->
force - forceOffsetLeft, leftForceTorque->
torque - torqueOffsetLeft, rightForceTorque->
force - forceOffsetRight, rightForceTorque->
torque - torqueOffsetRight;
462 for (
size_t i = 0; i < 12; i++)
464 wrenchesMeasured(i) = (1 - filterCoeff) * wrenchesMeasured(i) + filterCoeff * filteredOldValue(i);
466 filteredOldValue = wrenchesMeasured;
467 wrenchesMeasured.block<3, 1>(0, 0) = sensorFrame2TcpFrameLeft.block<3, 3>(0, 0) * wrenchesMeasured.block<3, 1>(0, 0) - localForceVecLeft;
468 wrenchesMeasured.block<3, 1>(3, 0) = sensorFrame2TcpFrameLeft.block<3, 3>(0, 0) * wrenchesMeasured.block<3, 1>(3, 0) - localTorqueVecLeft;
469 wrenchesMeasured.block<3, 1>(6, 0) = sensorFrame2TcpFrameRight.block<3, 3>(0, 0) * wrenchesMeasured.block<3, 1>(6, 0) - localForceVecRight;
470 wrenchesMeasured.block<3, 1>(9, 0) = sensorFrame2TcpFrameRight.block<3, 3>(0, 0) * wrenchesMeasured.block<3, 1>(9, 0) - localTorqueVecRight;
471 if (wrenchesMeasured.norm() < cfg->forceThreshold)
473 wrenchesMeasured.setZero();
482 Eigen::VectorXf forcePID(12);
492 for (
size_t i = 0; i < 6; i++)
494 forcePID(i) = cfg->forceP[i] * (currentTargetWrench(i) - wrenchesMeasured(i));
495 forcePID(i + 6) = cfg->forceP[i] * (currentTargetWrench(i + 6) - wrenchesMeasured(i + 6));
497 Eigen::VectorXf forcePIDInRoot(12);
498 forcePIDInRoot.block<3, 1>(0, 0) = currentLeftPose.block<3, 3>(0, 0) * forcePID.block<3, 1>(0, 0);
499 forcePIDInRoot.block<3, 1>(3, 0) = currentLeftPose.block<3, 3>(0, 0) * forcePID.block<3, 1>(3, 0);
500 forcePIDInRoot.block<3, 1>(6, 0) = currentRightPose.block<3, 3>(0, 0) * forcePID.block<3, 1>(6, 0);
501 forcePIDInRoot.block<3, 1>(9, 0) = currentRightPose.block<3, 3>(0, 0) * forcePID.block<3, 1>(9, 0);
504 Eigen::VectorXf forcePIDInRootForDebug = forcePIDInRoot;
506 Eigen::VectorXf wrenchesMeasuredInRoot(12);
507 wrenchesMeasuredInRoot.block<3, 1>(0, 0) = currentLeftPose.block<3, 3>(0, 0) * wrenchesMeasured.block<3, 1>(0, 0);
508 wrenchesMeasuredInRoot.block<3, 1>(3, 0) = currentLeftPose.block<3, 3>(0, 0) * wrenchesMeasured.block<3, 1>(3, 0);
509 wrenchesMeasuredInRoot.block<3, 1>(6, 0) = currentRightPose.block<3, 3>(0, 0) * wrenchesMeasured.block<3, 1>(6, 0);
510 wrenchesMeasuredInRoot.block<3, 1>(9, 0) = currentRightPose.block<3, 3>(0, 0) * wrenchesMeasured.block<3, 1>(9, 0);
511 Eigen::VectorXf wrenchesConstrained = PG * wrenchesMeasuredInRoot;
518 Eigen::VectorXf poseError(12);
519 poseError.block<3, 1>(0, 0) = leftInitialPose.block<3, 1>(0, 3) - modifiedLeftPose.block<3, 1>(0, 3);
520 Eigen::Matrix3f diffMat = leftInitialPose.block<3, 3>(0, 0) * modifiedLeftPose.block<3, 3>(0, 0).transpose();
521 poseError.block<3, 1>(3, 0) = VirtualRobot::MathTools::eigen3f2rpy(diffMat);
522 poseError.block<3, 1>(6, 0) = rightInitialPose.block<3, 1>(0, 3) - modifiedRightPose.block<3, 1>(0, 3);
523 diffMat = rightInitialPose.block<3, 3>(0, 0) * modifiedRightPose.block<3, 3>(0, 0).transpose();
524 poseError.block<3, 1>(9, 0) = VirtualRobot::MathTools::eigen3f2rpy(diffMat);
527 Eigen::VectorXf twist;
530 for (
size_t i = 0; i < 6; i++)
534 acc(i) = KpAdmittance(i) * poseError(i) - KdAdmittance(i) * modifiedTwist(i) - KmAdmittance(i) * wrenchesConstrained(i) - KmPID(i) * forcePIDInRoot(i);
535 acc(i + 6) = KpAdmittance(i) * poseError(i + 6) - KdAdmittance(i) * modifiedTwist(i + 6) - KmAdmittance(i) * wrenchesConstrained(i + 6) - KmPID(i) * forcePIDInRoot(i + 6);
537 twist = modifiedTwist + 0.5 * deltaT * (acc + modifiedAcc);
538 Eigen::VectorXf deltaPose = 0.5 * deltaT * (twist + modifiedTwist);
540 modifiedTwist = twist;
542 modifiedLeftPose.block<3, 1>(0, 3) = modifiedLeftPose.block<3, 1>(0, 3) + deltaPose.block<3, 1>(0, 0);
543 modifiedRightPose.block<3, 1>(0, 3) = modifiedRightPose.block<3, 1>(0, 3) + deltaPose.block<3, 1>(6, 0);
544 modifiedLeftPose.block<3, 3>(0, 0) = VirtualRobot::MathTools::rpy2eigen3f(deltaPose(3), deltaPose(4), deltaPose(5)) * modifiedLeftPose.block<3, 3>(0, 0);
545 modifiedRightPose.block<3, 3>(0, 0) = VirtualRobot::MathTools::rpy2eigen3f(deltaPose(9), deltaPose(10), deltaPose(11)) * modifiedRightPose.block<3, 3>(0, 0);
558 diffMat = modifiedLeftPose.block<3, 3>(0, 0) * currentLeftPose.block<3, 3>(0, 0).transpose();
559 poseError.block<3, 1>(0, 0) = modifiedLeftPose.block<3, 1>(0, 3) - currentLeftPose.block<3, 1>(0, 3);
560 poseError.block<3, 1>(3, 0) = VirtualRobot::MathTools::eigen3f2rpy(diffMat);
562 diffMat = modifiedRightPose.block<3, 3>(0, 0) * currentRightPose.block<3, 3>(0, 0).transpose();
563 poseError.block<3, 1>(6, 0) = modifiedRightPose.block<3, 1>(0, 3) - currentRightPose.block<3, 1>(0, 3);
564 poseError.block<3, 1>(9, 0) = VirtualRobot::MathTools::eigen3f2rpy(diffMat);
566 Eigen::VectorXf forceImpedance(12);
567 for (
size_t i = 0; i < 6; i++)
569 forceImpedance(i) = KpImpedance(i) * poseError(i) - KdImpedance(i) * currentTwist(i);
570 forceImpedance(i + 6) = KpImpedance(i) * poseError(i + 6) - KdImpedance(i) * currentTwist(i + 6);
576 Eigen::VectorXf leftNullspaceTorque = cfg->knull * (leftDesiredJointValues - leftqpos) - cfg->dnull * leftqvel;
577 Eigen::VectorXf rightNullspaceTorque = cfg->knull * (rightDesiredJointValues - rightqpos) - cfg->dnull * rightqvel;
582 forcePIDInRoot.setZero();
583 leftJointControlWrench = forceImpedance.head(6) + forcePIDInRoot.head(6);
584 rightJointControlWrench = forceImpedance.tail(6) + forcePIDInRoot.tail(6);
585 Eigen::MatrixXf jtpinvL = leftIK->computePseudoInverseJacobianMatrix(jacobiL.transpose(), lambda);
586 Eigen::MatrixXf jtpinvR = rightIK->computePseudoInverseJacobianMatrix(jacobiR.transpose(), lambda);
587 Eigen::VectorXf leftJointDesiredTorques = jacobiL.transpose() * leftJointControlWrench + (I - jacobiL.transpose() * jtpinvL) * leftNullspaceTorque;
588 Eigen::VectorXf rightJointDesiredTorques = jacobiR.transpose() * rightJointControlWrench + (I - jacobiR.transpose() * jtpinvR) * rightNullspaceTorque;
593 for (
size_t i = 0; i < leftTargets.size(); ++i)
595 float desiredTorque = leftJointDesiredTorques(i);
597 if (isnan(desiredTorque))
602 desiredTorque = (desiredTorque > cfg->torqueLimit) ? cfg->torqueLimit : desiredTorque;
603 desiredTorque = (desiredTorque < -cfg->torqueLimit) ? -cfg->torqueLimit : desiredTorque;
605 debugOutputData.
getWriteBuffer().desired_torques[leftJointNames[i]] = leftJointDesiredTorques(i);
607 leftTargets.at(i)->torque = desiredTorque;
611 for (
size_t i = 0; i < rightTargets.size(); ++i)
613 float desiredTorque = rightJointDesiredTorques(i);
615 if (isnan(desiredTorque))
620 desiredTorque = (desiredTorque > cfg->torqueLimit) ? cfg->torqueLimit : desiredTorque;
621 desiredTorque = (desiredTorque < - cfg->torqueLimit) ? - cfg->torqueLimit : desiredTorque;
623 debugOutputData.
getWriteBuffer().desired_torques[rightJointNames[i]] = rightJointDesiredTorques(i);
625 rightTargets.at(i)->torque = desiredTorque;
633 debugOutputData.
getWriteBuffer().wrenchesConstrained = wrenchesConstrained;
634 debugOutputData.
getWriteBuffer().wrenchesMeasuredInRoot = wrenchesMeasuredInRoot;
638 debugOutputData.
getWriteBuffer().modifiedPoseRight_x = modifiedRightPose(0, 3);
639 debugOutputData.
getWriteBuffer().modifiedPoseRight_y = modifiedRightPose(1, 3);
640 debugOutputData.
getWriteBuffer().modifiedPoseRight_z = modifiedRightPose(2, 3);
642 debugOutputData.
getWriteBuffer().currentPoseLeft_x = currentLeftPose(0, 3);
643 debugOutputData.
getWriteBuffer().currentPoseLeft_y = currentLeftPose(1, 3);
644 debugOutputData.
getWriteBuffer().currentPoseLeft_z = currentLeftPose(2, 3);
648 debugOutputData.
getWriteBuffer().modifiedPoseLeft_x = modifiedLeftPose(0, 3);
649 debugOutputData.
getWriteBuffer().modifiedPoseLeft_y = modifiedLeftPose(1, 3);
650 debugOutputData.
getWriteBuffer().modifiedPoseLeft_z = modifiedLeftPose(2, 3);
652 debugOutputData.
getWriteBuffer().currentPoseRight_x = currentRightPose(0, 3);
653 debugOutputData.
getWriteBuffer().currentPoseRight_y = currentRightPose(1, 3);
654 debugOutputData.
getWriteBuffer().currentPoseRight_z = currentRightPose(2, 3);
675 debugOutputData.
getWriteBuffer().forcePID = forcePIDInRootForDebug;
683 objectDMP->learnDMPFromFiles(fileNames);
690 objectDMP->setGoalPoseVec(goals);
706 Eigen::Vector3f boxPosi = (leftPose.block<3, 1>(0, 3) + rightPose.block<3, 1>(0, 3)) / 2;
708 std::vector<double> boxInitialPose;
709 for (
size_t i = 0; i < 3; ++i)
711 boxInitialPose.push_back(boxPosi(i) * 0.001);
713 boxInitialPose.push_back(boxOri.w);
714 boxInitialPose.push_back(boxOri.x);
715 boxInitialPose.push_back(boxOri.y);
716 boxInitialPose.push_back(boxOri.z);
718 virtualtimer = cfg->timeDuration;
719 objectDMP->prepareExecution(boxInitialPose, goals);
729 objectDMP->setViaPose(u, viapoint);
740 datafields[pair.first] =
new Variant(pair.second);
744 for (
int i = 0; i < forceImpedance.rows(); ++i)
746 std::stringstream ss;
748 std::string data_name =
"forceImpedance_" + ss.str();
749 datafields[data_name] =
new Variant(forceImpedance(i));
753 for (
int i = 0; i < forcePID.rows(); ++i)
755 std::stringstream ss;
757 std::string data_name =
"forcePID_" + ss.str();
758 datafields[data_name] =
new Variant(forcePID(i));
763 for (
int i = 0; i < poseError.rows(); ++i)
765 std::stringstream ss;
767 std::string data_name =
"poseError_" + ss.str();
768 datafields[data_name] =
new Variant(poseError(i));
772 for (
int i = 0; i < wrenchesConstrained.rows(); ++i)
774 std::stringstream ss;
776 std::string data_name =
"wrenchesConstrained_" + ss.str();
777 datafields[data_name] =
new Variant(wrenchesConstrained(i));
780 Eigen::VectorXf wrenchesMeasuredInRoot = debugOutputData.
getUpToDateReadBuffer().wrenchesMeasuredInRoot;
781 for (
int i = 0; i < wrenchesMeasuredInRoot.rows(); ++i)
783 std::stringstream ss;
785 std::string data_name =
"wrenchesMeasuredInRoot_" + ss.str();
786 datafields[data_name] =
new Variant(wrenchesMeasuredInRoot(i));
843 debugObs->setDebugChannel(
"BimanualForceController", datafields);
849 runTask(
"NJointBimanualForceController", [&]
853 while (
getState() == eManagedIceObjectStarted)
859 c.waitForCycleDuration();