12 ARMARX_INFO <<
"Initializing Bimanual Object Level Controller";
15 cfg = NJointBimanualObjLevelControllerConfigPtr::dynamicCast(config);
19 leftRNS =
rtGetRobot()->getRobotNodeSet(
"LeftArm");
21 for (
size_t i = 0; i < leftRNS->getSize(); ++i)
23 std::string jointName = leftRNS->getNode(i)->getName();
24 leftJointNames.push_back(jointName);
27 leftTargets.push_back(ct->
asA<ControlTarget1DoFActuatorTorque>());
28 const SensorValue1DoFActuatorVelocity* velocitySensor = sv->
asA<SensorValue1DoFActuatorVelocity>();
29 const SensorValue1DoFActuatorPosition* positionSensor = sv->
asA<SensorValue1DoFActuatorPosition>();
41 leftVelocitySensors.push_back(velocitySensor);
42 leftPositionSensors.push_back(positionSensor);
46 rightRNS =
rtGetRobot()->getRobotNodeSet(
"RightArm");
48 for (
size_t i = 0; i < rightRNS->getSize(); ++i)
50 std::string jointName = rightRNS->getNode(i)->getName();
51 rightJointNames.push_back(jointName);
54 rightTargets.push_back(ct->
asA<ControlTarget1DoFActuatorTorque>());
56 const SensorValue1DoFActuatorVelocity* velocitySensor = sv->
asA<SensorValue1DoFActuatorVelocity>();
57 const SensorValue1DoFActuatorPosition* positionSensor = sv->
asA<SensorValue1DoFActuatorPosition>();
68 rightVelocitySensors.push_back(velocitySensor);
69 rightPositionSensors.push_back(positionSensor);
75 const SensorValueBase* svlf = robUnit->getSensorDevice(
"FT L")->getSensorValue();
78 const SensorValueBase* svrf = robUnit->getSensorDevice(
"FT R")->getSensorValue();
81 leftIK.reset(
new VirtualRobot::DifferentialIK(leftRNS, leftRNS->getRobot()->getRootNode(), VirtualRobot::JacobiProvider::eSVDDamped));
82 rightIK.reset(
new VirtualRobot::DifferentialIK(rightRNS, rightRNS->getRobot()->getRootNode(), VirtualRobot::JacobiProvider::eSVDDamped));
88 taskSpaceDMPConfig.
DMPMode = cfg->dmpMode;
89 taskSpaceDMPConfig.
DMPStyle = cfg->dmpType;
106 tcpLeft = leftRNS->getTCP();
107 tcpRight = rightRNS->getTCP();
110 KpImpedance.setZero(cfg->KpImpedance.size());
113 for (
int i = 0; i < KpImpedance.size(); ++i)
115 KpImpedance(i) = cfg->KpImpedance.at(i);
118 KdImpedance.setZero(cfg->KdImpedance.size());
121 for (
int i = 0; i < KdImpedance.size(); ++i)
123 KdImpedance(i) = cfg->KdImpedance.at(i);
126 KpAdmittance.setZero(cfg->KpAdmittance.size());
129 for (
int i = 0; i < KpAdmittance.size(); ++i)
131 KpAdmittance(i) = cfg->KpAdmittance.at(i);
134 KdAdmittance.setZero(cfg->KdAdmittance.size());
137 for (
int i = 0; i < KdAdmittance.size(); ++i)
139 KdAdmittance(i) = cfg->KdAdmittance.at(i);
142 KmAdmittance.setZero(cfg->KmAdmittance.size());
145 for (
int i = 0; i < KmAdmittance.size(); ++i)
147 KmAdmittance(i) = cfg->KmAdmittance.at(i);
151 Inferface2rtData initInt2rtData;
152 initInt2rtData.KpImpedance = KpImpedance;
153 initInt2rtData.KdImpedance = KdImpedance;
154 initInt2rtData.KmAdmittance = KmAdmittance;
155 initInt2rtData.KpAdmittance = KpAdmittance;
156 initInt2rtData.KdAdmittance = KdAdmittance;
159 leftDesiredJointValues.resize(leftTargets.size());
162 for (
size_t i = 0; i < leftTargets.size(); ++i)
164 leftDesiredJointValues(i) = cfg->leftDesiredJointValues.at(i);
167 rightDesiredJointValues.resize(rightTargets.size());
170 for (
size_t i = 0; i < rightTargets.size(); ++i)
172 rightDesiredJointValues(i) = cfg->rightDesiredJointValues.at(i);
175 KmPID.resize(cfg->KmPID.size());
178 for (
int i = 0; i < KmPID.size(); ++i)
180 KmPID(i) = cfg->KmPID.at(i);
183 virtualAcc.setZero(6);
184 virtualVel.setZero(6);
189 boxInitialPose = VirtualRobot::MathTools::quat2eigen4f(cfg->boxInitialPose[4], cfg->boxInitialPose[5], cfg->boxInitialPose[6], cfg->boxInitialPose[3]);
190 for (
int i = 0; i < 3; ++i)
192 boxInitialPose(i, 3) = cfg->boxInitialPose[i];
195 rt2ControlData initSensorData;
196 initSensorData.deltaT = 0;
197 initSensorData.currentTime = 0;
198 initSensorData.currentPose = boxInitialPose;
199 initSensorData.currentTwist.setZero();
203 ControlInterfaceData initInterfaceData;
204 initInterfaceData.currentLeftPose = tcpLeft->getPoseInRootFrame();
205 initInterfaceData.currentRightPose = tcpRight->getPoseInRootFrame();
206 initInterfaceData.currentObjPose = boxInitialPose;
207 initInterfaceData.currentObjForce.setZero();
208 initInterfaceData.currentObjVel.setZero();
212 leftInitialPose = tcpLeft->getPoseInRootFrame();
213 rightInitialPose = tcpRight->getPoseInRootFrame();
214 leftInitialPose.block<3, 1>(0, 3) = 0.001 * leftInitialPose.block<3, 1>(0, 3);
215 rightInitialPose.block<3, 1>(0, 3) = 0.001 * rightInitialPose.block<3, 1>(0, 3);
222 forcePIDControllers.resize(12);
223 for (
size_t i = 0; i < 6; i++)
225 forcePIDControllers.at(i).reset(
new PIDController(cfg->forceP[i], cfg->forceI[i], cfg->forceD[i], cfg->forcePIDLimits[i]));
226 forcePIDControllers.at(i + 6).reset(
new PIDController(cfg->forceP[i], cfg->forceI[i], cfg->forceD[i], cfg->forcePIDLimits[i]));
227 forcePIDControllers.at(i)->reset();
228 forcePIDControllers.at(i + 6)->reset();
232 filterCoeff = cfg->filterCoeff;
234 filteredOldValue.setZero(12);
237 massLeft = cfg->massLeft;
238 CoMVecLeft << cfg->CoMVecLeft[0], cfg->CoMVecLeft[1], cfg->CoMVecLeft[2];
239 forceOffsetLeft << cfg->forceOffsetLeft[0], cfg->forceOffsetLeft[1], cfg->forceOffsetLeft[2];
240 torqueOffsetLeft << cfg->torqueOffsetLeft[0], cfg->torqueOffsetLeft[1], cfg->torqueOffsetLeft[2];
242 massRight = cfg->massRight;
243 CoMVecRight << cfg->CoMVecRight[0], cfg->CoMVecRight[1], cfg->CoMVecRight[2];
244 forceOffsetRight << cfg->forceOffsetRight[0], cfg->forceOffsetRight[1], cfg->forceOffsetRight[2];
245 torqueOffsetRight << cfg->torqueOffsetRight[0], cfg->torqueOffsetRight[1], cfg->torqueOffsetRight[2];
247 sensorFrame2TcpFrameLeft.setZero();
248 sensorFrame2TcpFrameRight.setZero();
251 initData.
boxPose = boxInitialPose;
256 ARMARX_INFO <<
"left initial pose: \n" << leftInitialPose <<
"\n right initial pose: \n" << rightInitialPose;
264 ftcalibrationTimer = 0;
265 ftOffset.setZero(12);
267 targetWrench.setZero(cfg->targetWrench.size());
268 for (
size_t i = 0; i < cfg->targetWrench.size(); ++i)
270 targetWrench(i) = cfg->targetWrench[i];
275 objCom2TCPLeftInObjFrame.setZero();
276 objCom2TCPRightInObjFrame.setZero();
282 objectDMP->setWeights(weights);
287 DMP::DVec2d res = objectDMP->getWeights();
289 for (
size_t i = 0; i < res.size(); ++i)
291 std::vector<double> cvec;
292 for (
size_t j = 0; j < res[i].size(); ++j)
294 cvec.push_back(res[i][j]);
296 resvec.push_back(cvec);
304 objectDMP->setRotWeights(weights);
309 DMP::DVec2d res = objectDMP->getRotWeights();
311 for (
size_t i = 0; i < res.size(); ++i)
313 std::vector<double> cvec;
314 for (
size_t j = 0; j < res[i].size(); ++j)
316 cvec.push_back(res[i][j]);
318 resvec.push_back(cvec);
329 leftPose.block<3, 1>(0, 3) = leftPose.block<3, 1>(0, 3) * 0.001;
330 rightPose.block<3, 1>(0, 3) = rightPose.block<3, 1>(0, 3) * 0.001;
331 boxInitPose.block<3, 1>(0, 3) = 0.5 * (leftPose.block<3, 1>(0, 3) + rightPose.block<3, 1>(0, 3));
332 boxInitPose.block<3, 3>(0, 0) = leftPose.block<3, 3>(0, 0);
335 initData.
boxPose = boxInitPose;
342 return "NJointBimanualObjLevelController";
354 Eigen::VectorXf currentTwist = rt2ControlBuffer.
getReadBuffer().currentTwist;
357 if (objectDMP->canVal < 1e-8)
363 objectDMP->flow(deltaT, currentPose, currentTwist);
379 controlInterfaceBuffer.
getWriteBuffer().currentLeftPose = currentLeftPose;
380 controlInterfaceBuffer.
getWriteBuffer().currentRightPose = currentRightPose;
381 double deltaT = timeSinceLastIteration.toSecondsDouble();
383 ftcalibrationTimer += deltaT;
390 leftPose.block<3, 1>(0, 3) = leftPose.block<3, 1>(0, 3) * 0.001;
391 rightPose.block<3, 1>(0, 3) = rightPose.block<3, 1>(0, 3) * 0.001;
393 virtualPose.block<3, 1>(0, 3) = 0.5 * (leftPose.block<3, 1>(0, 3) + rightPose.block<3, 1>(0, 3));
394 virtualPose.block<3, 3>(0, 0) = leftPose.block<3, 3>(0, 0);
395 fixedLeftRightRotOffset = virtualPose.block<3, 3>(0, 0).
transpose() * rightPose.block<3, 3>(0, 0);
397 Eigen::Vector3f objCom2TCPLeftInGlobal = leftPose.block<3, 1>(0, 3) - virtualPose.block<3, 1>(0, 3);
398 Eigen::Vector3f objCom2TCPRightInGlobal = rightPose.block<3, 1>(0, 3) - virtualPose.block<3, 1>(0, 3);
402 objCom2TCPLeftInObjFrame = virtualPose.block<3, 3>(0, 0).
transpose() * objCom2TCPLeftInGlobal;
403 objCom2TCPRightInObjFrame = virtualPose.block<3, 3>(0, 0).
transpose() * objCom2TCPRightInGlobal;
408 leftSensorFrame.block<3, 1>(0, 3) = leftSensorFrame.block<3, 1>(0, 3) * 0.001;
409 rightSensorFrame.block<3, 1>(0, 3) = rightSensorFrame.block<3, 1>(0, 3) * 0.001;
411 sensorFrame2TcpFrameLeft.block<3, 3>(0, 0) = leftPose.block<3, 3>(0, 0).transpose() * leftSensorFrame.block<3, 3>(0, 0);
412 sensorFrame2TcpFrameRight.block<3, 3>(0, 0) = rightPose.block<3, 3>(0, 0).transpose() * rightSensorFrame.block<3, 3>(0, 0);
413 CoMVecLeft = sensorFrame2TcpFrameLeft.block<3, 3>(0, 0) * CoMVecLeft;
414 CoMVecRight = sensorFrame2TcpFrameRight.block<3, 3>(0, 0) * CoMVecRight;
416 ARMARX_INFO <<
"modified left pose:\n " << leftPose;
417 ARMARX_INFO <<
"modified right pose:\n " << rightPose;
427 if (ftcalibrationTimer < cfg->ftCalibrationTime)
429 ftOffset.block<3, 1>(0, 0) = 0.5 * ftOffset.block<3, 1>(0, 0) + 0.5 * leftForceTorque->
force;
430 ftOffset.block<3, 1>(3, 0) = 0.5 * ftOffset.block<3, 1>(3, 0) + 0.5 * leftForceTorque->
torque;
431 ftOffset.block<3, 1>(6, 0) = 0.5 * ftOffset.block<3, 1>(6, 0) + 0.5 * rightForceTorque->
force;
432 ftOffset.block<3, 1>(9, 0) = 0.5 * ftOffset.block<3, 1>(9, 0) + 0.5 * rightForceTorque->
torque;
434 for (
int i = 0; i < KmAdmittance.size(); ++i)
441 for (
int i = 0; i < KmAdmittance.size(); ++i)
443 KmAdmittance(i) = cfg->KmAdmittance.at(i);
448 Eigen::VectorXf deltaPoseForWrenchControl;
449 deltaPoseForWrenchControl.setZero(12);
450 for (
size_t i = 0; i < 12; ++i)
452 if (KpImpedance(i) == 0)
454 deltaPoseForWrenchControl(i) = 0;
458 deltaPoseForWrenchControl(i) = targetWrench(i) / KpImpedance(i);
459 if (deltaPoseForWrenchControl(i) > 0.1)
461 deltaPoseForWrenchControl(i) = 0.1;
463 else if (deltaPoseForWrenchControl(i) < -0.1)
465 deltaPoseForWrenchControl(i) = -0.1;
473 currentLeftPose.block<3, 1>(0, 3) = 0.001 * currentLeftPose.block<3, 1>(0, 3);
474 currentRightPose.block<3, 1>(0, 3) = 0.001 * currentRightPose.block<3, 1>(0, 3);
478 Eigen::MatrixXf graspMatrix;
479 graspMatrix.setZero(6, 12);
485 Eigen::Vector3f rvec = virtualPose.block<3, 3>(0, 0) * objCom2TCPLeftInObjFrame;
486 graspMatrix.block<3, 3>(3, 0) =
skew(rvec);
488 rvec = virtualPose.block<3, 3>(0, 0) * objCom2TCPRightInObjFrame;
489 graspMatrix.block<3, 3>(3, 6) =
skew(rvec);
496 Eigen::MatrixXf pinvGraspMatrixT = leftIK->computePseudoInverseJacobianMatrix(graspMatrix.transpose(), lambda);
500 boxCurrentPose.block<3, 1>(0, 3) = 0.5 * (currentLeftPose.block<3, 1>(0, 3) + currentRightPose.block<3, 1>(0, 3));
501 Eigen::VectorXf boxCurrentTwist;
502 boxCurrentTwist.setZero(6);
507 Eigen::MatrixXf jacobiL = leftIK->getJacobianMatrix(tcpLeft, VirtualRobot::IKSolver::CartesianSelection::All);
508 Eigen::MatrixXf jacobiR = rightIK->getJacobianMatrix(tcpRight, VirtualRobot::IKSolver::CartesianSelection::All);
509 jacobiL.block<3, 8>(0, 0) = 0.001 * jacobiL.block<3, 8>(0, 0);
510 jacobiR.block<3, 8>(0, 0) = 0.001 * jacobiR.block<3, 8>(0, 0);
513 Eigen::VectorXf leftqpos;
514 Eigen::VectorXf leftqvel;
515 leftqpos.resize(leftPositionSensors.size());
516 leftqvel.resize(leftVelocitySensors.size());
517 for (
size_t i = 0; i < leftVelocitySensors.size(); ++i)
519 leftqpos(i) = leftPositionSensors[i]->position;
520 leftqvel(i) = leftVelocitySensors[i]->velocity;
523 Eigen::VectorXf rightqpos;
524 Eigen::VectorXf rightqvel;
525 rightqpos.resize(rightPositionSensors.size());
526 rightqvel.resize(rightVelocitySensors.size());
528 for (
size_t i = 0; i < rightVelocitySensors.size(); ++i)
530 rightqpos(i) = rightPositionSensors[i]->position;
531 rightqvel(i) = rightVelocitySensors[i]->velocity;
535 Eigen::VectorXf currentLeftTwist = jacobiL * leftqvel;
536 Eigen::VectorXf currentRightTwist = jacobiR * rightqvel;
538 Eigen::VectorXf currentTwist(12);
539 currentTwist << currentLeftTwist, currentRightTwist;
540 boxCurrentTwist = pinvGraspMatrixT * currentTwist;
552 Eigen::Vector3f gravity;
553 gravity << 0.0, 0.0, -9.8;
554 Eigen::Vector3f localGravityLeft = currentLeftPose.block<3, 3>(0, 0).
transpose() * gravity;
555 Eigen::Vector3f localForceVecLeft = massLeft * localGravityLeft;
556 Eigen::Vector3f localTorqueVecLeft = CoMVecLeft.cross(localForceVecLeft);
558 Eigen::Vector3f localGravityRight = currentRightPose.block<3, 3>(0, 0).
transpose() * gravity;
559 Eigen::Vector3f localForceVecRight = massRight * localGravityRight;
560 Eigen::Vector3f localTorqueVecRight = CoMVecRight.cross(localForceVecRight);
563 Eigen::VectorXf wrenchesMeasured(12);
564 wrenchesMeasured << leftForceTorque->
force - forceOffsetLeft, leftForceTorque->
torque - torqueOffsetLeft, rightForceTorque->
force - forceOffsetRight, rightForceTorque->
torque - torqueOffsetRight;
565 for (
size_t i = 0; i < 12; i++)
567 wrenchesMeasured(i) = (1 - filterCoeff) * wrenchesMeasured(i) + filterCoeff * filteredOldValue(i);
569 filteredOldValue = wrenchesMeasured;
570 wrenchesMeasured.block<3, 1>(0, 0) = sensorFrame2TcpFrameLeft.block<3, 3>(0, 0) * wrenchesMeasured.block<3, 1>(0, 0) - localForceVecLeft;
571 wrenchesMeasured.block<3, 1>(3, 0) = sensorFrame2TcpFrameLeft.block<3, 3>(0, 0) * wrenchesMeasured.block<3, 1>(3, 0) - localTorqueVecLeft;
572 wrenchesMeasured.block<3, 1>(6, 0) = sensorFrame2TcpFrameRight.block<3, 3>(0, 0) * wrenchesMeasured.block<3, 1>(6, 0) - localForceVecRight;
573 wrenchesMeasured.block<3, 1>(9, 0) = sensorFrame2TcpFrameRight.block<3, 3>(0, 0) * wrenchesMeasured.block<3, 1>(9, 0) - localTorqueVecRight;
579 Eigen::VectorXf wrenchesMeasuredInRoot(12);
580 wrenchesMeasuredInRoot.block<3, 1>(0, 0) = currentLeftPose.block<3, 3>(0, 0) * wrenchesMeasured.block<3, 1>(0, 0);
581 wrenchesMeasuredInRoot.block<3, 1>(3, 0) = currentLeftPose.block<3, 3>(0, 0) * wrenchesMeasured.block<3, 1>(3, 0);
582 wrenchesMeasuredInRoot.block<3, 1>(6, 0) = currentRightPose.block<3, 3>(0, 0) * wrenchesMeasured.block<3, 1>(6, 0);
583 wrenchesMeasuredInRoot.block<3, 1>(9, 0) = currentRightPose.block<3, 3>(0, 0) * wrenchesMeasured.block<3, 1>(9, 0);
587 Eigen::VectorXf objFTValue = graspMatrix * wrenchesMeasuredInRoot;
588 for (
size_t i = 0; i < 6; i++)
590 if (fabs(objFTValue(i)) < cfg->forceThreshold.at(i))
596 objFTValue(i) -= cfg->forceThreshold.at(i) * objFTValue(i) / fabs(objFTValue(i));
601 controlInterfaceBuffer.
getWriteBuffer().currentObjPose = boxCurrentPose;
602 controlInterfaceBuffer.
getWriteBuffer().currentObjVel = boxCurrentTwist.head(3);
603 controlInterfaceBuffer.
getWriteBuffer().currentObjForce = objFTValue.head(3);
614 Eigen::VectorXf objPoseError(6);
615 objPoseError.head(3) = virtualPose.block<3, 1>(0, 3) - boxPose.block<3, 1>(0, 3);
616 Eigen::Matrix3f objDiffMat = virtualPose.block<3, 3>(0, 0) * boxPose.block<3, 3>(0, 0).transpose();
617 objPoseError.tail(3) = VirtualRobot::MathTools::eigen3f2rpy(objDiffMat);
620 Eigen::VectorXf objAcc;
621 Eigen::VectorXf objVel;
624 for (
size_t i = 0; i < 6; i++)
627 objAcc(i) = KmAdmittance(i) * objFTValue(i) - KpAdmittance(i) * objPoseError(i) - KdAdmittance(i) * virtualVel(i);
629 objVel = virtualVel + 0.5 * deltaT * (objAcc + virtualAcc);
630 Eigen::VectorXf deltaObjPose = 0.5 * deltaT * (objVel + virtualVel);
633 virtualPose.block<3, 1>(0, 3) += deltaObjPose.head(3);
634 virtualPose.block<3, 3>(0, 0) = VirtualRobot::MathTools::rpy2eigen3f(deltaObjPose(3), deltaObjPose(4), deltaObjPose(5)) * virtualPose.block<3, 3>(0, 0);
640 tcpTargetPoseRight.block<3, 3>(0, 0) = virtualPose.block<3, 3>(0, 0) * fixedLeftRightRotOffset;
642 tcpTargetPoseLeft.block<3, 1>(0, 3) += virtualPose.block<3, 3>(0, 0) * (objCom2TCPLeftInObjFrame - deltaPoseForWrenchControl.block<3, 1>(0, 0));
643 tcpTargetPoseRight.block<3, 1>(0, 3) += virtualPose.block<3, 3>(0, 0) * (objCom2TCPRightInObjFrame - deltaPoseForWrenchControl.block<3, 1>(6, 0));
646 Eigen::VectorXf poseError(12);
647 Eigen::Matrix3f diffMat = tcpTargetPoseLeft.block<3, 3>(0, 0) * currentLeftPose.block<3, 3>(0, 0).transpose();
648 poseError.block<3, 1>(0, 0) = tcpTargetPoseLeft.block<3, 1>(0, 3) - currentLeftPose.block<3, 1>(0, 3);
649 poseError.block<3, 1>(3, 0) = VirtualRobot::MathTools::eigen3f2rpy(diffMat);
651 diffMat = tcpTargetPoseRight.block<3, 3>(0, 0) * currentRightPose.block<3, 3>(0, 0).transpose();
652 poseError.block<3, 1>(6, 0) = tcpTargetPoseRight.block<3, 1>(0, 3) - currentRightPose.block<3, 1>(0, 3);
653 poseError.block<3, 1>(9, 0) = VirtualRobot::MathTools::eigen3f2rpy(diffMat);
655 Eigen::VectorXf forceImpedance(12);
656 for (
size_t i = 0; i < 12; i++)
658 forceImpedance(i) = KpImpedance(i) * poseError(i) - KdImpedance(i) * currentTwist(i);
663 Eigen::VectorXf leftNullspaceTorque = cfg->knull * (leftDesiredJointValues - leftqpos) - cfg->dnull * leftqvel;
664 Eigen::VectorXf rightNullspaceTorque = cfg->knull * (rightDesiredJointValues - rightqpos) - cfg->dnull * rightqvel;
668 Eigen::MatrixXf jtpinvL = leftIK->computePseudoInverseJacobianMatrix(jacobiL.transpose(), lambda);
669 Eigen::MatrixXf jtpinvR = rightIK->computePseudoInverseJacobianMatrix(jacobiR.transpose(), lambda);
670 Eigen::VectorXf leftJointDesiredTorques = jacobiL.transpose() * forceImpedance.head(6) + (I - jacobiL.transpose() * jtpinvL) * leftNullspaceTorque;
671 Eigen::VectorXf rightJointDesiredTorques = jacobiR.transpose() * forceImpedance.tail(6) + (I - jacobiR.transpose() * jtpinvR) * rightNullspaceTorque;
674 for (
size_t i = 0; i < leftTargets.size(); ++i)
676 float desiredTorque = leftJointDesiredTorques(i);
677 if (isnan(desiredTorque))
681 desiredTorque = (desiredTorque > cfg->torqueLimit) ? cfg->torqueLimit : desiredTorque;
682 desiredTorque = (desiredTorque < -cfg->torqueLimit) ? -cfg->torqueLimit : desiredTorque;
683 debugOutputData.
getWriteBuffer().desired_torques[leftJointNames[i]] = leftJointDesiredTorques(i);
684 leftTargets.at(i)->torque = desiredTorque;
687 for (
size_t i = 0; i < rightTargets.size(); ++i)
689 float desiredTorque = rightJointDesiredTorques(i);
690 if (isnan(desiredTorque))
694 desiredTorque = (desiredTorque > cfg->torqueLimit) ? cfg->torqueLimit : desiredTorque;
695 desiredTorque = (desiredTorque < - cfg->torqueLimit) ? - cfg->torqueLimit : desiredTorque;
696 debugOutputData.
getWriteBuffer().desired_torques[rightJointNames[i]] = rightJointDesiredTorques(i);
697 rightTargets.at(i)->torque = desiredTorque;
704 debugOutputData.
getWriteBuffer().wrenchesMeasuredInRoot = wrenchesMeasuredInRoot;
708 debugOutputData.
getWriteBuffer().virtualPose_x = virtualPose(0, 3);
709 debugOutputData.
getWriteBuffer().virtualPose_y = virtualPose(1, 3);
710 debugOutputData.
getWriteBuffer().virtualPose_z = virtualPose(2, 3);
712 debugOutputData.
getWriteBuffer().objPose_x = boxCurrentPose(0, 3);
713 debugOutputData.
getWriteBuffer().objPose_y = boxCurrentPose(1, 3);
714 debugOutputData.
getWriteBuffer().objPose_z = boxCurrentPose(2, 3);
737 debugOutputData.
getWriteBuffer().modifiedPoseRight_x = tcpTargetPoseRight(0, 3);
738 debugOutputData.
getWriteBuffer().modifiedPoseRight_y = tcpTargetPoseRight(1, 3);
739 debugOutputData.
getWriteBuffer().modifiedPoseRight_z = tcpTargetPoseRight(2, 3);
741 debugOutputData.
getWriteBuffer().currentPoseLeft_x = currentLeftPose(0, 3);
742 debugOutputData.
getWriteBuffer().currentPoseLeft_y = currentLeftPose(1, 3);
743 debugOutputData.
getWriteBuffer().currentPoseLeft_z = currentLeftPose(2, 3);
752 debugOutputData.
getWriteBuffer().modifiedPoseLeft_x = tcpTargetPoseLeft(0, 3);
753 debugOutputData.
getWriteBuffer().modifiedPoseLeft_y = tcpTargetPoseLeft(1, 3);
754 debugOutputData.
getWriteBuffer().modifiedPoseLeft_z = tcpTargetPoseLeft(2, 3);
756 debugOutputData.
getWriteBuffer().currentPoseRight_x = currentRightPose(0, 3);
757 debugOutputData.
getWriteBuffer().currentPoseRight_y = currentRightPose(1, 3);
758 debugOutputData.
getWriteBuffer().currentPoseRight_z = currentRightPose(2, 3);
793 objectDMP->learnDMPFromFiles(fileNames);
800 objectDMP->setGoalPoseVec(goals);
816 Eigen::Vector3f boxPosi = (leftPose.block<3, 1>(0, 3) + rightPose.block<3, 1>(0, 3)) / 2;
820 std::vector<double> boxInitialPose;
821 for (
size_t i = 0; i < 3; ++i)
823 boxInitialPose.push_back(boxPosi(i) * 0.001);
825 boxInitialPose.push_back(boxOri.w);
826 boxInitialPose.push_back(boxOri.x);
827 boxInitialPose.push_back(boxOri.y);
828 boxInitialPose.push_back(boxOri.z);
830 objectDMP->prepareExecution(boxInitialPose, goals);
831 objectDMP->canVal = timeDuration;
832 objectDMP->config.motionTimeDuration = timeDuration;
846 objectDMP->prepareExecution(starts, goals);
847 objectDMP->canVal = timeDuration;
848 objectDMP->config.motionTimeDuration = timeDuration;
860 objectDMP->setViaPose(u, viapoint);
865 objectDMP->removeAllViaPoints();
871 Eigen::VectorXf setpoint;
872 setpoint.setZero(
value.size());
875 for (
size_t i = 0; i <
value.size(); ++i)
877 setpoint(i) =
value.at(i);
888 Eigen::VectorXf setpoint;
889 setpoint.setZero(
value.size());
892 for (
size_t i = 0; i <
value.size(); ++i)
894 setpoint(i) =
value.at(i);
904 Eigen::VectorXf setpoint;
905 setpoint.setZero(
value.size());
908 for (
size_t i = 0; i <
value.size(); ++i)
910 setpoint(i) =
value.at(i);
920 Eigen::VectorXf setpoint;
921 setpoint.setZero(
value.size());
924 for (
size_t i = 0; i <
value.size(); ++i)
926 setpoint(i) =
value.at(i);
937 std::vector<float> tvelvec = {tvel(0), tvel(1), tvel(2)};
944 std::vector<float> fvelvec = {fvel(0), fvel(1), fvel(2)};
950 Eigen::VectorXf setpoint;
951 setpoint.setZero(
value.size());
954 for (
size_t i = 0; i <
value.size(); ++i)
956 setpoint(i) =
value.at(i);
972 datafields[pair.first] =
new Variant(pair.second);
976 for (
int i = 0; i < forceImpedance.rows(); ++i)
978 std::stringstream ss;
980 std::string data_name =
"forceImpedance_" + ss.str();
981 datafields[data_name] =
new Variant(forceImpedance(i));
985 for (
int i = 0; i < forcePID.rows(); ++i)
987 std::stringstream ss;
989 std::string data_name =
"forcePID_" + ss.str();
990 datafields[data_name] =
new Variant(forcePID(i));
995 for (
int i = 0; i < poseError.rows(); ++i)
997 std::stringstream ss;
999 std::string data_name =
"poseError_" + ss.str();
1000 datafields[data_name] =
new Variant(poseError(i));
1004 for (
int i = 0; i < wrenchesConstrained.rows(); ++i)
1006 std::stringstream ss;
1008 std::string data_name =
"wrenchesConstrained_" + ss.str();
1009 datafields[data_name] =
new Variant(wrenchesConstrained(i));
1012 Eigen::VectorXf wrenchesMeasuredInRoot = debugOutputData.
getUpToDateReadBuffer().wrenchesMeasuredInRoot;
1013 for (
int i = 0; i < wrenchesMeasuredInRoot.rows(); ++i)
1015 std::stringstream ss;
1017 std::string data_name =
"wrenchesMeasuredInRoot_" + ss.str();
1018 datafields[data_name] =
new Variant(wrenchesMeasuredInRoot(i));
1112 debugObs->setDebugChannel(
"BimanualForceController", datafields);
1120 runTask(
"NJointBimanualObjLevelController", [&]
1124 while (
getState() == eManagedIceObjectStarted)
1130 c.waitForCycleDuration();