36 controllerStopRequested =
false;
37 controllerRunFinished =
false;
38 runTask(
"DSJointCarryControllerTask", [&]
42 while (
getState() == eManagedIceObjectStarted && !controllerStopRequested)
49 c.waitForCycleDuration();
51 controllerRunFinished =
true;
61 controllerStopRequested =
true;
62 while (!controllerRunFinished)
72 cfg = DSJointCarryControllerConfigPtr::dynamicCast(config);
75 VirtualRobot::RobotNodeSetPtr left_ns =
rtGetRobot()->getRobotNodeSet(
"LeftArm");
76 VirtualRobot::RobotNodeSetPtr right_ns =
rtGetRobot()->getRobotNodeSet(
"RightArm");
78 left_jointNames.clear();
79 right_jointNames.clear();
85 for (
size_t i = 0; i < left_ns->getSize(); ++i)
87 std::string jointName = left_ns->getNode(i)->getName();
88 left_jointNames.push_back(jointName);
93 auto casted_ct = ct->
asA<ControlTarget1DoFActuatorTorque>();
95 left_torque_targets.push_back(casted_ct);
97 const SensorValue1DoFActuatorTorque* torqueSensor = sv->
asA<SensorValue1DoFActuatorTorque>();
98 const SensorValue1DoFActuatorVelocity* velocitySensor = sv->
asA<SensorValue1DoFActuatorVelocity>();
99 const SensorValue1DoFGravityTorque* gravityTorqueSensor = sv->
asA<SensorValue1DoFGravityTorque>();
100 const SensorValue1DoFActuatorPosition* positionSensor = sv->
asA<SensorValue1DoFActuatorPosition>();
105 if (!gravityTorqueSensor)
107 ARMARX_WARNING <<
"No Gravity Torque sensor available for " << jointName;
110 left_torqueSensors.push_back(torqueSensor);
111 left_gravityTorqueSensors.push_back(gravityTorqueSensor);
112 left_velocitySensors.push_back(velocitySensor);
113 left_positionSensors.push_back(positionSensor);
117 for (
size_t i = 0; i < right_ns->getSize(); ++i)
119 std::string jointName = right_ns->getNode(i)->getName();
120 right_jointNames.push_back(jointName);
125 auto casted_ct = ct->
asA<ControlTarget1DoFActuatorTorque>();
127 right_torque_targets.push_back(casted_ct);
129 const SensorValue1DoFActuatorTorque* torqueSensor = sv->
asA<SensorValue1DoFActuatorTorque>();
130 const SensorValue1DoFActuatorVelocity* velocitySensor = sv->
asA<SensorValue1DoFActuatorVelocity>();
131 const SensorValue1DoFGravityTorque* gravityTorqueSensor = sv->
asA<SensorValue1DoFGravityTorque>();
132 const SensorValue1DoFActuatorPosition* positionSensor = sv->
asA<SensorValue1DoFActuatorPosition>();
137 if (!gravityTorqueSensor)
139 ARMARX_WARNING <<
"No Gravity Torque sensor available for " << jointName;
142 right_torqueSensors.push_back(torqueSensor);
143 right_gravityTorqueSensors.push_back(gravityTorqueSensor);
144 right_velocitySensors.push_back(velocitySensor);
145 right_positionSensors.push_back(positionSensor);
154 ARMARX_INFO <<
"Initialized " << left_torque_targets.size() <<
" targets for the left arm";
155 ARMARX_INFO <<
"Initialized " << right_torque_targets.size() <<
" targets for the right arm";
157 left_arm_tcp = left_ns->getTCP();
158 right_arm_tcp = right_ns->getTCP();
160 left_sensor_frame = left_ns->getRobot()->getRobotNode(
"ArmL_FT");
161 right_sensor_frame = right_ns->getRobot()->getRobotNode(
"ArmR_FT");
163 left_ik.reset(
new VirtualRobot::DifferentialIK(left_ns,
rtGetRobot()->getRootNode(), VirtualRobot::JacobiProvider::eSVDDamped));
164 right_ik.reset(
new VirtualRobot::DifferentialIK(right_ns,
rtGetRobot()->getRootNode(), VirtualRobot::JacobiProvider::eSVDDamped));
168 DSJointCarryControllerSensorData initSensorData;
169 initSensorData.left_tcpPose = left_arm_tcp->getPoseInRootFrame();
170 initSensorData.right_tcpPose = right_arm_tcp->getPoseInRootFrame();
171 initSensorData.left_force.setZero();
172 initSensorData.right_force.setZero();
173 initSensorData.currentTime = 0;
176 std::vector<float> left_desiredQuaternionVec = cfg->left_desiredQuaternion;
179 std::vector<float> right_desiredQuaternionVec = cfg->right_desiredQuaternion;
182 left_desiredQuaternion.w() = left_desiredQuaternionVec.at(0);
183 left_desiredQuaternion.x() = left_desiredQuaternionVec.at(1);
184 left_desiredQuaternion.y() = left_desiredQuaternionVec.at(2);
185 left_desiredQuaternion.z() = left_desiredQuaternionVec.at(3);
186 right_desiredQuaternion.w() = right_desiredQuaternionVec.at(0);
187 right_desiredQuaternion.x() = right_desiredQuaternionVec.at(1);
188 right_desiredQuaternion.y() = right_desiredQuaternionVec.at(2);
189 right_desiredQuaternion.z() = right_desiredQuaternionVec.at(3);
193 left_jointVelocity_filtered.resize(left_torque_targets.size());
194 left_jointVelocity_filtered.setZero();
195 right_jointVelocity_filtered.resize(left_torque_targets.size());
196 right_jointVelocity_filtered.setZero();
200 for (
size_t i = 0; i < 3; ++i)
210 Ctrl2InterfaceData initCtrl2InterfaceData;
211 initCtrl2InterfaceData.guardZVel = 0;
214 Interface2CtrlData initInterface2CtrlData;
215 initInterface2CtrlData.guardToHandInMeter.setZero();
216 initInterface2CtrlData.guardToHandInMeter[1] = cfg->guardLength / 2;
217 initInterface2CtrlData.guardOriInRobotBase.setIdentity();
218 initInterface2CtrlData.desiredGuardOriInRobotBase.w() = cfg->defaultGuardOri[0];
219 initInterface2CtrlData.desiredGuardOriInRobotBase.x() = cfg->defaultGuardOri[1];
220 initInterface2CtrlData.desiredGuardOriInRobotBase.y() = cfg->defaultGuardOri[2];
221 initInterface2CtrlData.desiredGuardOriInRobotBase.z() = cfg->defaultGuardOri[3];
222 initInterface2CtrlData.guardRotationStiffness << cfg->defaultRotationStiffness[0], cfg->defaultRotationStiffness[1], cfg->defaultRotationStiffness[2];
223 initInterface2CtrlData.guardObsAvoidVel.setZero();
227 left_desiredTorques_filtered.resize(left_torque_targets.size());
228 left_desiredTorques_filtered.setZero();
229 right_desiredTorques_filtered.resize(right_torque_targets.size());
230 right_desiredTorques_filtered.setZero();
233 left_currentTCPLinearVelocity_filtered.setZero();
234 right_currentTCPLinearVelocity_filtered.setZero();
236 left_currentTCPAngularVelocity_filtered.setZero();
237 right_currentTCPAngularVelocity_filtered.setZero();
239 left_tcpDesiredTorque_filtered.setZero();
240 right_tcpDesiredTorque_filtered.setZero();
245 filterTimeConstant = cfg->filterTimeConstant;
246 posiKp = cfg->posiKp;
248 Damping = cfg->posiDamping;
249 torqueLimit = cfg->torqueLimit;
250 null_torqueLimit = cfg->NullTorqueLimit;
252 oriDamping = cfg->oriDamping;
255 left_qnullspace.resize(cfg->leftarm_qnullspaceVec.size());
256 right_qnullspace.resize(cfg->rightarm_qnullspaceVec.size());
257 for (
size_t i = 0; i < cfg->leftarm_qnullspaceVec.size(); ++i)
259 left_qnullspace(i) = cfg->leftarm_qnullspaceVec[i];
260 right_qnullspace(i) = cfg->rightarm_qnullspaceVec[i];
262 nullspaceKp = cfg->nullspaceKp;
263 nullspaceDamping = cfg->nullspaceDamping;
267 if (cfg->gmmParamsFile ==
"")
269 ARMARX_ERROR <<
"gmm params file cannot be empty string ...";
287 Eigen::Vector3f left_currentTCPPositionInMeter;
288 Eigen::Vector3f right_currentTCPPositionInMeter;
289 left_currentTCPPositionInMeter << left_currentTCPPose(0, 3), left_currentTCPPose(1, 3), left_currentTCPPose(2, 3);
290 right_currentTCPPositionInMeter << right_currentTCPPose(0, 3), right_currentTCPPose(1, 3), right_currentTCPPose(2, 3);
291 left_currentTCPPositionInMeter = 0.001 * left_currentTCPPositionInMeter;
292 right_currentTCPPositionInMeter = 0.001 * right_currentTCPPositionInMeter;
297 Eigen::Vector3f guardToHandInMeter = interface2CtrlData.
getReadBuffer().guardToHandInMeter;
298 Eigen::Vector3f guardRotationStiffness = interface2CtrlData.
getReadBuffer().guardRotationStiffness;
299 Eigen::Vector3f guardModulatedVel = interface2CtrlData.
getReadBuffer().guardObsAvoidVel;
301 Eigen::Vector3f left_to_right = right_currentTCPPositionInMeter - left_currentTCPPositionInMeter;
302 left_to_right.normalize();
304 Eigen::Vector3f guard_currentPosition;
305 guard_currentPosition = (left_currentTCPPositionInMeter + right_currentTCPPositionInMeter) / 2 + guardToHandInMeter;
306 gmmMotionGenerator->updateDesiredVelocity(guard_currentPosition, cfg->positionErrorTolerance);
307 Eigen::Vector3f guardDesiredLinearVelocity = gmmMotionGenerator->guard_desiredVelocity;
310 ctrl2InterfaceData.
getWriteBuffer().guardZVel = guardDesiredLinearVelocity[2];
313 guardDesiredLinearVelocity[2] = guardDesiredLinearVelocity[2] + guardModulatedVel[2];
316 if (guard_desiredOrientation.coeffs().dot(guard_currentOrientation.coeffs()) < 0.0)
318 guard_currentOrientation.coeffs() << - guard_currentOrientation.coeffs();
320 Eigen::Quaternionf errorOri = guard_currentOrientation * guard_desiredOrientation.inverse();
321 Eigen::AngleAxisf err_axang(errorOri);
322 Eigen::Vector3f guard_angular_error = err_axang.axis() * err_axang.angle();
323 Eigen::Vector3f guard_desired_angular_vel = -1 * guardRotationStiffness.cwiseProduct(guard_angular_error);
326 Eigen::Vector3f guard_to_left = left_currentTCPPositionInMeter - guard_currentPosition;
327 Eigen::Vector3f leftOriGenLinearVelocity = guard_desired_angular_vel.cross(guard_to_left);
328 leftOriGenLinearVelocity -= leftOriGenLinearVelocity.dot(left_to_right) * left_to_right;
329 Eigen::Vector3f leftDesiredLinearVelocity = leftOriGenLinearVelocity + guardDesiredLinearVelocity;
331 if (leftDesiredLinearVelocity.norm() > cfg->handVelLimit)
333 leftDesiredLinearVelocity = cfg->handVelLimit * leftDesiredLinearVelocity / leftDesiredLinearVelocity.norm();
336 Eigen::Vector3f guard_to_right = right_currentTCPPositionInMeter - guard_currentPosition;
337 Eigen::Vector3f rightOriGenLinearVelocity = guard_desired_angular_vel.cross(guard_to_right);
338 rightOriGenLinearVelocity -= rightOriGenLinearVelocity.dot(left_to_right) * left_to_right;
339 Eigen::Vector3f rightDesiredLinearVelocity = rightOriGenLinearVelocity + guardDesiredLinearVelocity;
341 if (rightDesiredLinearVelocity.norm() > cfg->handVelLimit)
343 rightDesiredLinearVelocity = cfg->handVelLimit * rightDesiredLinearVelocity / rightDesiredLinearVelocity.norm();
347 Eigen::Matrix3f left_currentRotMat = left_currentTCPPose.block<3, 3>(0, 0);
348 Eigen::Matrix3f right_currentRotMat = right_currentTCPPose.block<3, 3>(0, 0);
349 Eigen::Matrix3f left_desiredRotMat = left_desiredQuaternion.normalized().toRotationMatrix();
350 Eigen::Matrix3f right_desiredRotMat = right_desiredQuaternion.normalized().toRotationMatrix();
351 Eigen::Matrix3f left_orientationError = left_currentRotMat * left_desiredRotMat.inverse();
352 Eigen::Matrix3f right_orientationError = right_currentRotMat * right_desiredRotMat.inverse();
355 Eigen::AngleAxisf left_angleAxis(left_diffQuaternion);
356 Eigen::AngleAxisf right_angleAxis(right_diffQuaternion);
357 Eigen::Vector3f left_tcpDesiredAngularError = left_angleAxis.angle() * left_angleAxis.axis();
358 Eigen::Vector3f right_tcpDesiredAngularError = right_angleAxis.angle() * right_angleAxis.axis();
368 debugCtrlDataInfo.
getWriteBuffer().leftDesiredLinearVelocity = leftDesiredLinearVelocity;
369 debugCtrlDataInfo.
getWriteBuffer().rightDesiredLinearVelocity = rightDesiredLinearVelocity;
377 double deltaT = timeSinceLastIteration.toSecondsDouble();
379 Eigen::Matrix4f leftSensorFrame = left_sensor_frame->getPoseInRootFrame();
380 Eigen::Matrix4f rightSensorFrame = right_sensor_frame->getPoseInRootFrame();
381 Eigen::Vector3f left_forceInRoot = leftSensorFrame.block<3, 3>(0, 0) * (leftForceTorque->
force);
382 Eigen::Vector3f right_forceInRoot = rightSensorFrame.block<3, 3>(0, 0) * (rightForceTorque->
force);
383 left_forceInRoot(2) = left_forceInRoot(2);
384 right_forceInRoot(2) = right_forceInRoot(2);
385 Eigen::Matrix4f left_currentTCPPose = left_arm_tcp->getPoseInRootFrame();
386 Eigen::Matrix4f right_currentTCPPose = right_arm_tcp->getPoseInRootFrame();
389 Eigen::MatrixXf left_jacobi = left_ik->getJacobianMatrix(left_arm_tcp, VirtualRobot::IKSolver::CartesianSelection::All);
390 Eigen::MatrixXf right_jacobi = right_ik->getJacobianMatrix(right_arm_tcp, VirtualRobot::IKSolver::CartesianSelection::All);
392 Eigen::VectorXf left_qpos;
393 Eigen::VectorXf left_qvel;
395 Eigen::VectorXf right_qpos;
396 Eigen::VectorXf right_qvel;
398 left_qpos.resize(left_positionSensors.size());
399 left_qvel.resize(left_velocitySensors.size());
401 right_qpos.resize(right_positionSensors.size());
402 right_qvel.resize(right_velocitySensors.size());
404 int jointDim = left_positionSensors.size();
406 for (
size_t i = 0; i < left_velocitySensors.size(); ++i)
408 left_qpos(i) = left_positionSensors[i]->position;
409 left_qvel(i) = left_velocitySensors[i]->velocity;
411 right_qpos(i) = right_positionSensors[i]->position;
412 right_qvel(i) = right_velocitySensors[i]->velocity;
415 Eigen::VectorXf left_tcptwist = left_jacobi * left_qvel;
416 Eigen::VectorXf right_tcptwist = right_jacobi * right_qvel;
418 Eigen::Vector3f left_currentTCPLinearVelocity;
419 Eigen::Vector3f right_currentTCPLinearVelocity;
420 Eigen::Vector3f left_currentTCPAngularVelocity;
421 Eigen::Vector3f right_currentTCPAngularVelocity;
422 left_currentTCPLinearVelocity << 0.001 * left_tcptwist(0), 0.001 * left_tcptwist(1), 0.001 * left_tcptwist(2);
423 right_currentTCPLinearVelocity << 0.001 * right_tcptwist(0), 0.001 * right_tcptwist(1), 0.001 * right_tcptwist(2);
424 left_currentTCPAngularVelocity << left_tcptwist(3), left_tcptwist(4), left_tcptwist(5);
425 right_currentTCPAngularVelocity << right_tcptwist(3), right_tcptwist(4), right_tcptwist(5);
426 double filterFactor = deltaT / (filterTimeConstant + deltaT);
427 left_currentTCPLinearVelocity_filtered = (1 - filterFactor) * left_currentTCPLinearVelocity_filtered + filterFactor * left_currentTCPLinearVelocity;
428 right_currentTCPLinearVelocity_filtered = (1 - filterFactor) * right_currentTCPLinearVelocity_filtered + filterFactor * right_currentTCPLinearVelocity;
429 left_currentTCPAngularVelocity_filtered = (1 - filterFactor) * left_currentTCPAngularVelocity_filtered + left_currentTCPAngularVelocity;
430 right_currentTCPAngularVelocity_filtered = (1 - filterFactor) * right_currentTCPAngularVelocity_filtered + right_currentTCPAngularVelocity;
431 left_jointVelocity_filtered = (1 - filterFactor) * left_jointVelocity_filtered + filterFactor * left_qvel;
432 right_jointVelocity_filtered = (1 - filterFactor) * right_jointVelocity_filtered + filterFactor * right_qvel;
434 controllerSensorData.
getWriteBuffer().left_tcpPose = left_currentTCPPose;
435 controllerSensorData.
getWriteBuffer().right_tcpPose = right_currentTCPPose;
436 controllerSensorData.
getWriteBuffer().left_force = left_forceInRoot;
437 controllerSensorData.
getWriteBuffer().right_force = right_forceInRoot;
442 Eigen::Vector3f leftDesiredLinearVelocity =
rtGetControlStruct().leftDesiredLinearVelocity;
443 Eigen::Vector3f rightDesiredLinearVelocity =
rtGetControlStruct().rightDesiredLinearVelocity;
444 Eigen::Vector3f left_tcpDesiredAngularError =
rtGetControlStruct().leftDesiredAngularError;
445 Eigen::Vector3f right_tcpDesiredAngularError =
rtGetControlStruct().rightDesiredAngularError;
448 Eigen::Vector3f left_DS_force = -(left_currentTCPLinearVelocity_filtered - leftDesiredLinearVelocity);
449 Eigen::Vector3f right_DS_force = -(right_currentTCPLinearVelocity_filtered - rightDesiredLinearVelocity);
450 for (
int i = 0; i < 3; ++i)
452 left_DS_force(i) = left_DS_force(i) * Damping[i];
453 right_DS_force(i) = right_DS_force(i) * Damping[i];
454 left_DS_force(i) = deadzone(left_DS_force(i), 0.1, 100);
455 right_DS_force(i) = deadzone(right_DS_force(i), 0.1, 100);
458 Eigen::Vector3f left_tcpDesiredTorque = - oriKp * left_tcpDesiredAngularError - oriDamping * left_currentTCPAngularVelocity_filtered;
459 Eigen::Vector3f right_tcpDesiredTorque = - oriKp * right_tcpDesiredAngularError - oriDamping * right_currentTCPAngularVelocity_filtered;
461 left_tcpDesiredTorque_filtered = (1 - filterFactor) * left_tcpDesiredTorque_filtered + filterFactor * left_tcpDesiredTorque;
462 right_tcpDesiredTorque_filtered = (1 - filterFactor) * right_tcpDesiredTorque_filtered + filterFactor * right_tcpDesiredTorque;
468 left_tcpDesiredWrench << 0.001 * left_DS_force, left_tcpDesiredTorque_filtered;
469 right_tcpDesiredWrench << 0.001 * right_DS_force, right_tcpDesiredTorque_filtered;
478 Eigen::MatrixXf left_jtpinv = left_ik->computePseudoInverseJacobianMatrix(left_jacobi.transpose(), lambda);
479 Eigen::MatrixXf right_jtpinv = right_ik->computePseudoInverseJacobianMatrix(right_jacobi.transpose(), lambda);
480 Eigen::VectorXf left_nullqerror = left_qpos - left_qnullspace;
481 Eigen::VectorXf right_nullqerror = right_qpos - right_qnullspace;
483 for (
int i = 0; i < left_nullqerror.size(); ++i)
485 if (fabs(left_nullqerror(i)) < 0.09)
487 left_nullqerror(i) = 0;
490 if (fabs(right_nullqerror(i)) < 0.09)
492 right_nullqerror(i) = 0;
496 Eigen::VectorXf left_nullspaceTorque = - nullspaceKp * left_nullqerror - nullspaceDamping * left_jointVelocity_filtered;
497 Eigen::VectorXf right_nullspaceTorque = - nullspaceKp * right_nullqerror - nullspaceDamping * right_jointVelocity_filtered;
498 Eigen::VectorXf left_projectedNullTorque = (I - left_jacobi.transpose() * left_jtpinv) * left_nullspaceTorque;
499 Eigen::VectorXf right_projectedNullTorque = (I - right_jacobi.transpose() * right_jtpinv) * right_nullspaceTorque;
500 float left_nulltorque_norm = left_projectedNullTorque.norm();
501 float right_nulltorque_norm = right_projectedNullTorque.norm();
502 if (left_nulltorque_norm > null_torqueLimit)
504 left_projectedNullTorque = (null_torqueLimit / left_nulltorque_norm) * left_projectedNullTorque;
506 if (right_nulltorque_norm > null_torqueLimit)
508 right_projectedNullTorque = (null_torqueLimit / right_nulltorque_norm) * right_projectedNullTorque;
511 Eigen::VectorXf left_jointDesiredTorques = left_jacobi.transpose() * left_tcpDesiredWrench + left_projectedNullTorque;
512 Eigen::VectorXf right_jointDesiredTorques = right_jacobi.transpose() * right_tcpDesiredWrench + right_projectedNullTorque;
513 for (
size_t i = 0; i < left_torque_targets.size(); ++i)
515 float desiredTorque = smooth_startup * left_jointDesiredTorques(i);
516 desiredTorque = deadzone(desiredTorque, cfg->desiredTorqueDisturbance, torqueLimit);
517 left_desiredTorques_filtered(i) = (1 - cfg->TorqueFilterConstant) * left_desiredTorques_filtered(i) + cfg->TorqueFilterConstant * desiredTorque;
519 std::string
names = left_jointNames[i] +
"_desiredTorques";
524 if (fabs(left_desiredTorques_filtered(i)) > torqueLimit)
526 left_torque_targets.at(i)->torque = 0;
530 left_torque_targets.at(i)->torque = left_desiredTorques_filtered(i);
534 for (
size_t i = 0; i < right_torque_targets.size(); ++i)
536 float desiredTorque = smooth_startup * right_jointDesiredTorques(i);
537 desiredTorque = deadzone(desiredTorque, cfg->desiredTorqueDisturbance, torqueLimit);
538 right_desiredTorques_filtered(i) = (1 - cfg->TorqueFilterConstant) * right_desiredTorques_filtered(i) + cfg->TorqueFilterConstant * desiredTorque;
540 std::string
names = right_jointNames[i] +
"_desiredTorques";
545 if (fabs(right_desiredTorques_filtered(i)) > torqueLimit)
547 right_torque_targets.at(i)->torque = 0;
551 right_torque_targets.at(i)->torque = right_desiredTorques_filtered(i);
555 smooth_startup = smooth_startup + 0.001 * (1.1 - smooth_startup);
556 smooth_startup = (smooth_startup > 1) ? 1 : smooth_startup;
557 smooth_startup = (smooth_startup < 0) ? 0 : smooth_startup;
565 guardOri.w() = guardOrientationInRobotBase[0];
566 guardOri.x() = guardOrientationInRobotBase[1];
567 guardOri.y() = guardOrientationInRobotBase[2];
568 guardOri.z() = guardOrientationInRobotBase[3];
571 interface2CtrlData.
getWriteBuffer().guardOriInRobotBase = guardOri;
577 Eigen::Vector3f guardPosi;
578 guardPosi << guardPositionToHandInMeter[0], guardPositionToHandInMeter[1], guardPositionToHandInMeter[2];
581 interface2CtrlData.
getWriteBuffer().guardToHandInMeter = guardPosi;
588 guardOri.w() = desiredOrientationInRobotBase[0];
589 guardOri.x() = desiredOrientationInRobotBase[1];
590 guardOri.y() = desiredOrientationInRobotBase[2];
591 guardOri.z() = desiredOrientationInRobotBase[3];
594 interface2CtrlData.
getWriteBuffer().desiredGuardOriInRobotBase = guardOri;
600 Eigen::Vector3f rotStiffness;
601 rotStiffness << rotationStiffness[0], rotStiffness[1], rotStiffness[2];
604 interface2CtrlData.
getWriteBuffer().guardRotationStiffness = rotStiffness;
611 interface2CtrlData.
getWriteBuffer().guardObsAvoidVel(0) = guardObsAvoidVel[0];
612 interface2CtrlData.
getWriteBuffer().guardObsAvoidVel(1) = guardObsAvoidVel[1];
613 interface2CtrlData.
getWriteBuffer().guardObsAvoidVel(2) = guardObsAvoidVel[2];
624 float DSJointCarryController::deadzone(
float input,
float disturbance,
float threshold)
645 double cosHalfTheta = q0.w() * q1.w() + q0.x() * q1.x() + q0.y() * q1.y() + q0.z() * q1.z();
649 if (cosHalfTheta < 0)
658 if (fabs(cosHalfTheta) >= 1.0)
663 double halfTheta = acos(cosHalfTheta);
664 double sinHalfTheta =
sqrt(1.0 - cosHalfTheta * cosHalfTheta);
668 if (fabs(sinHalfTheta) < 0.001)
670 result.w() = (1 - t) * q0.w() + t * q1x.w();
671 result.x() = (1 - t) * q0.x() + t * q1x.x();
672 result.y() = (1 - t) * q0.y() + t * q1x.y();
673 result.z() = (1 - t) * q0.z() + t * q1x.z();
678 double ratioA = sin((1 - t) * halfTheta) / sinHalfTheta;
679 double ratioB = sin(t * halfTheta) / sinHalfTheta;
681 result.w() = ratioA * q0.w() + ratioB * q1x.w();
682 result.x() = ratioA * q0.x() + ratioB * q1x.x();
683 result.y() = ratioA * q0.y() + ratioB * q1x.y();
684 result.z() = ratioA * q0.z() + ratioB * q1x.z();
697 datafields[pair.first] =
new Variant(pair.second);
707 debugObs->setDebugChannel(
"DSJointCarry", datafields);