NJointBimanualCartesianAdmittanceController.cpp
Go to the documentation of this file.
1 #include <SimoxUtility/math/pose/pose.h>
2 #include <SimoxUtility/math/pose/is_homogeneous_transform.h>
3 #include <SimoxUtility/math/isfinite.h>
4 
6 
8 
10 {
12 
13  NJointBimanualCartesianAdmittanceController::NJointBimanualCartesianAdmittanceController(const RobotUnitPtr& robUnit, const armarx::NJointControllerConfigPtr& config, const VirtualRobot::RobotPtr& robot)
14  {
15  ARMARX_INFO << "Preparing ... bimanual ";
17  auto cfgPtr = NJointBimanualCartesianAdmittanceControllerConfigPtr::dynamicCast(config);
18  ARMARX_CHECK_NOT_NULL(cfgPtr);
19  //init rtData
20  {
21  auto initRtData = [&](auto & data, const auto & rnsName, const auto & ftName, const auto & ftRefFrame)
22  {
23  data.rns = rtGetRobot()->getRobotNodeSet(rnsName);
24  ARMARX_CHECK_NOT_NULL(data.rns) << "No robot node set " << rnsName;
25  data.tcp = data.rns->getTCP();
26  ARMARX_CHECK_NOT_NULL(data.tcp) << "No TCP in robot node set " << rnsName;
27  data.frameFTSensor = rtGetRobot()->getSensor(ftName)->getRobotNode();
28  ARMARX_CHECK_NOT_NULL(data.frameFTSensor) << "No ref frame for ft sensor in robot ";
29 
30  for (size_t i = 0; i < data.rns->getSize(); ++i)
31  {
32  std::string jointName = data.rns->getNode(i)->getName();
33  data.jointNames.push_back(jointName);
34  ControlTargetBase* ct = useControlTarget(jointName, ControlModes::Torque1DoF);
35  const SensorValueBase* sv = useSensorValue(jointName);
36  ARMARX_CHECK_NOT_NULL(ct) << "No control target available for " << jointName;
37  ARMARX_CHECK_NOT_NULL(sv) << "No sensor value available for " << jointName;
38  data.targets.push_back(ct->asA<ControlTarget1DoFActuatorTorque>());
39  const SensorValue1DoFActuatorVelocity* velocitySensor = sv->asA<SensorValue1DoFActuatorVelocity>();
40  const SensorValue1DoFActuatorPosition* positionSensor = sv->asA<SensorValue1DoFActuatorPosition>();
41  ARMARX_CHECK_NOT_NULL(velocitySensor) << "No velocitySensor available for " << jointName;
42  ARMARX_CHECK_NOT_NULL(positionSensor) << "No positionSensor available for " << jointName;
43  data.velocitySensors.push_back(velocitySensor);
44  data.positionSensors.push_back(positionSensor);
45  }
46  const auto ftDev = robUnit->getSensorDevice(ftName);
47  ARMARX_CHECK_NOT_NULL(ftDev) << "No sensor device available for " << ftName;
48  const SensorValueBase* svlf = ftDev->getSensorValue();
49  ARMARX_CHECK_NOT_NULL(svlf) << "No sensor value available for " << ftName;
50  data.forceTorque = svlf->asA<SensorValueForceTorque>();
51  ARMARX_CHECK_NOT_NULL(data.forceTorque) << "Sensor value for " << ftName << " is not of type SensorValueForceTorque";
52  data.IK.reset(new VirtualRobot::DifferentialIK(
53  data.rns,
54  data.rns->getRobot()->getRootNode(),
55  VirtualRobot::JacobiProvider::eSVDDamped));
56  };
57 
58  initRtData(rt.left, cfgPtr->kinematicChainLeft, cfgPtr->ftSensorLeft, cfgPtr->ftSensorLeftFrame);
59  initRtData(rt.right, cfgPtr->kinematicChainRight, cfgPtr->ftSensorRight, cfgPtr->ftSensorRightFrame);
60  }
61 
62  //init cfg + check it
63  {
64  setConfig(cfgPtr);
65  cfgBuf.reinitAllBuffers(cfgBuf.getWriteBuffer());
66  }
67 
68 
69  // {
70  // rt2ControlData initSensorData;
71  // initSensorData.deltaT = 0;
72  // initSensorData.currentTime = 0;
73  // initSensorData.currentPose = boxInitialPose;
74  // initSensorData.currentTwist.setZero();
75  // rt2ControlBuffer.reinitAllBuffers(initSensorData);
76  // }
77 
78 
79  // {
80  // ControlInterfaceData initInterfaceData;
81  // initInterfaceData.currentLeftPose = rt.left.tcp->getPoseInRootFrame();
82  // initInterfaceData.currentRightPose = rt.right.tcp->getPoseInRootFrame();
83  // controlInterfaceBuffer.reinitAllBuffers(initInterfaceData);
84  // }
85 
86  //////////////////////////////TODO
87  // leftInitialPose = rt.left.tcp->getPoseInRootFrame();
88  // rightInitialPose = rt.right.rns->getPoseInRootFrame();
89  // leftInitialPose.block<3, 1>(0, 3) = 0.001 * leftInitialPose.block<3, 1>(0, 3);
90  // rightInitialPose.block<3, 1>(0, 3) = 0.001 * rightInitialPose.block<3, 1>(0, 3);
91 
92  // // leftInitialPose = boxInitialPose;
93  // // leftInitialPose(0, 3) -= cfg->boxWidth * 0.5;
94  // // rightInitialPose = boxInitialPose;
95  // // rightInitialPose(0, 3) += cfg->boxWidth * 0.5;
96  //////////////////////////////TODO
97  // forcePIDControllers.resize(12);
98  // for (size_t i = 0; i < 6; i++)
99  // {
100  // forcePIDControllers.at(i).reset(new PIDController(cfg->forceP[i], cfg->forceI[i], cfg->forceD[i], cfg->forcePIDLimits[i]));
101  // forcePIDControllers.at(i + 6).reset(new PIDController(cfg->forceP[i], cfg->forceI[i], cfg->forceD[i], cfg->forcePIDLimits[i]));
102  // forcePIDControllers.at(i)->reset();
103  // forcePIDControllers.at(i + 6)->reset();
104  // }
105  //////////////////////////////TODO
106  // filter
107  // filterCoeff = cfg->filterCoeff;
108  // ARMARX_IMPORTANT << "filter coeff.: " << filterCoeff;
109  // filteredOldValue.setZero(12);
110 
111  // static compensation
112  rt.left.sensorFrame2TcpFrame.setZero();
113  rt.right.sensorFrame2TcpFrame.setZero();
114  // NJointBimanualObjLevelControlData initData;
115  // initData.boxPose = boxInitialPose;
116  // initData.boxTwist.setZero(6);
117  // reinitTripleBuffer(initData);
118 
119  // ARMARX_INFO << "left initial pose: \n" << leftInitialPose << "\n right initial pose: \n" << rightInitialPose;
120 
121  // ARMARX_IMPORTANT << "targetwrench is: " << cfg->targetWrench;
122  ARMARX_IMPORTANT << "finished construction!";
123 
124  // targetWrench.setZero(cfg->targetWrench.size());
125  // for (size_t i = 0; i < cfg->targetWrench.size(); ++i)
126  // {
127  // targetWrench(i) = cfg->targetWrench[i];
128  // }
129  }
130 
131 
133  {
134  // NJointBimanualObjLevelControlData initData;
135  // initData.boxPose = boxInitPose;
136  // initData.boxTwist.resize(6);
137  // reinitTripleBuffer(initData);
138 
139  rt.virtualAcc.setZero();
140  rt.virtualVel.setZero();
141  rt.virtualPose.setZero();
142  rt.filteredOldValue.setZero();
143  // rt.ftOffset.setZero();
144  rt.firstLoop = true;
145  rt.ftcalibrationTimer = 0;
146 
147 
148 
149  const Eigen::Matrix4f leftPose = simox::math::scaled_position(rt.left.tcp->getPoseInRootFrame(), 0.001);
150  const Eigen::Matrix4f rightPose = simox::math::scaled_position(rt.right.tcp->getPoseInRootFrame(), 0.001);
151 
152  rt.virtualPose.block<3, 1>(0, 3) = 0.5 * (leftPose.block<3, 1>(0, 3) + rightPose.block<3, 1>(0, 3));
153  rt.virtualPose.block<3, 3>(0, 0) = leftPose.block<3, 3>(0, 0);
154 
155  const Eigen::Matrix4f leftSensorFrame = simox::math::scaled_position(
156  rt.left.frameFTSensor->getPoseInRootFrame(), 0.001);
157  const Eigen::Matrix4f rightSensorFrame = simox::math::scaled_position(
158  rt.right.frameFTSensor->getPoseInRootFrame(), 0.001);
159 
160  rt.left.sensorFrame2TcpFrame.block<3, 3>(0, 0) = leftPose.block<3, 3>(0, 0).transpose() * leftSensorFrame.block<3, 3>(0, 0);
161  rt.right.sensorFrame2TcpFrame.block<3, 3>(0, 0) = rightPose.block<3, 3>(0, 0).transpose() * rightSensorFrame.block<3, 3>(0, 0);
162 
163  // ARMARX_INFO << "modified left pose:\n " << leftPose;
164  // ARMARX_INFO << "modified right pose:\n " << rightPose;
165  }
166 
167  std::string NJointBimanualCartesianAdmittanceController::getClassName(const Ice::Current&) const
168  {
169  return "NJointBimanualCartesianAdmittanceController";
170  }
171 
172  // void NJointBimanualCartesianAdmittanceController::controllerRun()
173  // {
174  // if (!rt2ControlBuffer.updateReadBuffer() || !dmpStarted)
175  // {
176  // return;
177  // }
178 
179  // double deltaT = rt2ControlBuffer.getReadBuffer().deltaT;
180  // Eigen::Matrix4f currentPose = rt2ControlBuffer.getReadBuffer().currentPose;
181  // Eigen::VectorXf currentTwist = rt2ControlBuffer.getReadBuffer().currentTwist;
182  // //ARMARX_IMPORTANT << "canVal: " << objectDMP->canVal;
183 
184  // if (objectDMP->canVal < 1e-8)
185  // {
186  // finished = true;
187  // dmpStarted = false;
188  // }
189 
190  // objectDMP->flow(deltaT, currentPose, currentTwist);
191 
192  // LockGuardType guard {controlDataMutex};
193  // getWriterControlStruct().boxPose = objectDMP->getTargetPoseMat();
194  // getWriterControlStruct().boxTwist = objectDMP->getTargetVelocity();
195  // writeControlStruct();
196  // }
197 
198 
199 
200 
202  {
203 
204  const Eigen::Matrix4f currentLeftPose = simox::math::scaled_position(rt.left.tcp->getPoseInRootFrame(), 0.001);
205  const Eigen::Matrix4f currentRightPose = simox::math::scaled_position(rt.right.tcp->getPoseInRootFrame(), 0.001);
206  const Eigen::Matrix4f currentBoxPose = [&]
207  {
209  pose.block<3, 1>(0, 3) = 0.5 * (currentLeftPose.block<3, 1>(0, 3) + currentRightPose.block<3, 1>(0, 3));
210  pose.block<3, 3>(0, 0) = currentLeftPose.block<3, 3>(0, 0);
211  return pose;
212  }();
213  // {
214  // controlInterfaceBuffer.getWriteBuffer().currentLeftPose = currentLeftPose;
215  // controlInterfaceBuffer.getWriteBuffer().currentRightPose = currentRightPose;
216  // controlInterfaceBuffer.commitWrite();
217  // }
218  const double deltaT = timeSinceLastIteration.toSecondsDouble();
219 
220  ARMARX_ON_SCOPE_EXIT{rt.firstLoop = false;};
221 
222  rt.ftcalibrationTimer += deltaT;
223 
224  // -------------------------------------------- config ---------------------------------------------
225 
226  if (cfgBuf.updateReadBuffer())
227  {
228  auto& cfg = cfgBuf._getNonConstReadBuffer();
229  const Eigen::Vector3f tmpL = rt.left.sensorFrame2TcpFrame.block<3, 3>(0, 0) * cfg.CoMVecLeft;
230  const Eigen::Vector3f tmpR = rt.right.sensorFrame2TcpFrame.block<3, 3>(0, 0) * cfg.CoMVecRight;
231  cfg.CoMVecLeft = tmpL;
232  cfg.CoMVecRight = tmpR;
233  }
234  if (rt.firstLoop)
235  {
236  auto& trg = targBuf._getNonConstReadBuffer();
237  trg.pose = currentBoxPose;
238  trg.vel.setZero();
239  }
240  auto& dbgOut = debugOutputData.getWriteBuffer();
241  const auto& targ = targBuf.getWriteBuffer();
242  const auto& cfg = cfgBuf.getReadBuffer();
243 
244  if (rt.ftcalibrationTimer < cfg.ftCalibrationTime)
245  {
246  // rt.ftOffset.block<3, 1>(0, 0) = 0.5 * rt.ftOffset.block<3, 1>(0, 0) + 0.5 * rt.right.forceTorque->force;
247  // rt.ftOffset.block<3, 1>(3, 0) = 0.5 * rt.ftOffset.block<3, 1>(3, 0) + 0.5 * rt.right.forceTorque->torque;
248  // rt.ftOffset.block<3, 1>(6, 0) = 0.5 * rt.ftOffset.block<3, 1>(6, 0) + 0.5 * rt.left.forceTorque->force;
249  // rt.ftOffset.block<3, 1>(9, 0) = 0.5 * rt.ftOffset.block<3, 1>(9, 0) + 0.5 * rt.left.forceTorque->torque;
250  // cfg.KmAdmittance.setZero();
251  }
252 
253  const Eigen::Vector6f KmAdmittance =
254  (rt.ftcalibrationTimer < cfg.ftCalibrationTime) ?
255  Eigen::Vector6f::Zero() :
256  cfg.KmAdmittance;
257 
258  // -------------------------------------------- target wrench ---------------------------------------------
259  const Eigen::Vector12f deltaPoseForWrenchControl = cfg.targetWrench.array() / cfg.KpImpedance.array();
260 
261  // ------------------------------------------- current tcp pose -------------------------------------------
262 
263 
264  // --------------------------------------------- grasp matrix ---------------------------------------------
265  const auto skew = [](auto & vec)
266  {
267  Eigen::Matrix3f mat = Eigen::MatrixXf::Zero(3, 3);
268  mat(1, 2) = -vec(0);
269  mat(0, 2) = vec(1);
270  mat(0, 1) = -vec(2);
271  mat(2, 1) = vec(0);
272  mat(2, 0) = -vec(1);
273  mat(1, 0) = vec(2);
274  return mat;
275  };
276  const Eigen::Vector3f objCom2TCPLeft{-cfg.boxWidth * 0.5f, 0.f, 0.f};
277  const Eigen::Vector3f objCom2TCPRight{+cfg.boxWidth * 0.5f, 0.f, 0.f};
278 
279  Eigen::Matrix_6_12_f graspMatrix;
280  graspMatrix.setZero();
281  graspMatrix.block<3, 3>(0, 0) = Eigen::MatrixXf::Identity(3, 3);
282  graspMatrix.block<3, 3>(0, 6) = Eigen::MatrixXf::Identity(3, 3);
283 
284  const Eigen::Vector3f rLeft = rt.virtualPose.block<3, 3>(0, 0) * objCom2TCPLeft;
285  const Eigen::Vector3f rRight = rt.virtualPose.block<3, 3>(0, 0) * objCom2TCPRight;
286 
287  graspMatrix.block<3, 3>(3, 0) = skew(rLeft);
288  graspMatrix.block<3, 3>(3, 6) = skew(rRight);
289 
290  // // projection of grasp matrix
291  // Eigen::MatrixXf pinvG = rt.left.IK->computePseudoInverseJacobianMatrix(graspMatrix, 0);
292  // Eigen::MatrixXf G_range = pinvG * graspMatrix;
293  // Eigen::MatrixXf PG = Eigen::MatrixXf::Identity(12, 12) - G_range;
294  float lambda = 1;
295  const Eigen::MatrixXf pinvGraspMatrixT = rt.left.IK->computePseudoInverseJacobianMatrix(graspMatrix.transpose(), lambda);
296 
297  // ---------------------------------------------- object pose ----------------------------------------------
298  Eigen::Matrix4f boxCurrentPose = currentRightPose;
299  boxCurrentPose.block<3, 1>(0, 3) = 0.5 * (currentLeftPose.block<3, 1>(0, 3) + currentRightPose.block<3, 1>(0, 3));
300  Eigen::Vector6f boxCurrentTwist = Eigen::Vector6f::Zero();
301 
302  // -------------------------------------- get Jacobian matrix and qpos -------------------------------------
303  const Eigen::MatrixXf I = Eigen::MatrixXf::Identity(rt.left.targets.size(), rt.left.targets.size());
304  // Jacobian matrices
305  Eigen::MatrixXf jacobiL = rt.left.IK->getJacobianMatrix(rt.left.tcp, VirtualRobot::IKSolver::CartesianSelection::All);
306  Eigen::MatrixXf jacobiR = rt.right.IK->getJacobianMatrix(rt.right.tcp, VirtualRobot::IKSolver::CartesianSelection::All);
307  jacobiL.block<3, 8>(0, 0) = 0.001 * jacobiL.block<3, 8>(0, 0);
308  jacobiR.block<3, 8>(0, 0) = 0.001 * jacobiR.block<3, 8>(0, 0);
309 
310  // qpos, qvel
311  Eigen::VectorXf leftqpos(rt.left.positionSensors.size());
312  Eigen::VectorXf leftqvel(rt.left.velocitySensors.size());
313  for (size_t i = 0; i < rt.left.velocitySensors.size(); ++i)
314  {
315  leftqpos(i) = rt.left.positionSensors[i]->position;
316  leftqvel(i) = rt.left.velocitySensors[i]->velocity;
317  }
318 
319  Eigen::VectorXf rightqpos(rt.right.positionSensors.size());
320  Eigen::VectorXf rightqvel(rt.right.velocitySensors.size());
321  for (size_t i = 0; i < rt.right.velocitySensors.size(); ++i)
322  {
323  rightqpos(i) = rt.right.positionSensors[i]->position;
324  rightqvel(i) = rt.right.velocitySensors[i]->velocity;
325  }
326 
327  // -------------------------------------- compute TCP and object velocity -------------------------------------
328  const Eigen::Vector6f currentLeftTwist = jacobiL * leftqvel;
329  const Eigen::Vector6f currentRightTwist = jacobiR * rightqvel;
330 
331  Eigen::Vector12f currentTwist;
332  currentTwist << currentLeftTwist, currentRightTwist;
333  boxCurrentTwist = pinvGraspMatrixT * currentTwist;
334 
335  // rt2ControlBuffer.getWriteBuffer().currentPose = boxCurrentPose;
336  // rt2ControlBuffer.getWriteBuffer().currentTwist = boxCurrentTwist;
337  // rt2ControlBuffer.getWriteBuffer().deltaT = deltaT;
338  // rt2ControlBuffer.getWriteBuffer().currentTime += deltaT;
339  // rt2ControlBuffer.commitWrite();
340 
341  // --------------------------------------------- get ft sensor ---------------------------------------------
342  // static compensation
343  const Eigen::Vector3f gravity{0.0, 0.0, -9.8};
344  const Eigen::Vector3f localGravityLeft = currentLeftPose.block<3, 3>(0, 0).transpose() * gravity;
345  const Eigen::Vector3f localForceVecLeft = cfg.massLeft * localGravityLeft;
346  const Eigen::Vector3f localTorqueVecLeft = cfg.CoMVecLeft.cross(localForceVecLeft);
347 
348  const Eigen::Vector3f localGravityRight = currentRightPose.block<3, 3>(0, 0).transpose() * gravity;
349  const Eigen::Vector3f localForceVecRight = cfg.massRight * localGravityRight;
350  const Eigen::Vector3f localTorqueVecRight = cfg.CoMVecRight.cross(localForceVecRight);
351 
352  // mapping of measured wrenches
353  Eigen::Vector12f wrenchesMeasured;
354  wrenchesMeasured << rt.right.forceTorque->force - cfg.forceOffsetLeft,
355  rt.right.forceTorque->torque - cfg.torqueOffsetLeft,
356  rt.left.forceTorque->force - cfg.forceOffsetRight,
357  rt.left.forceTorque->torque - cfg.torqueOffsetRight;
358  for (size_t i = 0; i < 12; i++)
359  {
360  wrenchesMeasured(i) = (1 - cfg.filterCoeff) * wrenchesMeasured(i) + cfg.filterCoeff * rt.filteredOldValue(i);
361  }
362  rt.filteredOldValue = wrenchesMeasured;
363  wrenchesMeasured.block<3, 1>(0, 0) = rt.left.sensorFrame2TcpFrame.block<3, 3>(0, 0) * wrenchesMeasured.block<3, 1>(0, 0) - localForceVecLeft;
364  wrenchesMeasured.block<3, 1>(3, 0) = rt.left.sensorFrame2TcpFrame.block<3, 3>(0, 0) * wrenchesMeasured.block<3, 1>(3, 0) - localTorqueVecLeft;
365  wrenchesMeasured.block<3, 1>(6, 0) = rt.right.sensorFrame2TcpFrame.block<3, 3>(0, 0) * wrenchesMeasured.block<3, 1>(6, 0) - localForceVecRight;
366  wrenchesMeasured.block<3, 1>(9, 0) = rt.right.sensorFrame2TcpFrame.block<3, 3>(0, 0) * wrenchesMeasured.block<3, 1>(9, 0) - localTorqueVecRight;
367  // if (wrenchesMeasured.norm() < cfg->forceThreshold)
368  // {
369  // wrenchesMeasured.setZero();
370  // }
371 
372  Eigen::Vector12f wrenchesMeasuredInRoot;
373  wrenchesMeasuredInRoot.block<3, 1>(0, 0) = currentLeftPose.block<3, 3>(0, 0) * wrenchesMeasured.block<3, 1>(0, 0);
374  wrenchesMeasuredInRoot.block<3, 1>(3, 0) = currentLeftPose.block<3, 3>(0, 0) * wrenchesMeasured.block<3, 1>(3, 0);
375  wrenchesMeasuredInRoot.block<3, 1>(6, 0) = currentRightPose.block<3, 3>(0, 0) * wrenchesMeasured.block<3, 1>(6, 0);
376  wrenchesMeasuredInRoot.block<3, 1>(9, 0) = currentRightPose.block<3, 3>(0, 0) * wrenchesMeasured.block<3, 1>(9, 0);
377 
378  // map to object
379  Eigen::Vector6f objFTValue = graspMatrix * wrenchesMeasuredInRoot;
380  for (size_t i = 0; i < 6; i++)
381  {
382  if (fabs(objFTValue(i)) < cfg.forceThreshold(i))
383  {
384  objFTValue(i) = 0;
385  }
386  else
387  {
388  objFTValue(i) -= cfg.forceThreshold(i) * objFTValue(i) / fabs(objFTValue(i));
389  }
390  }
391 
392  // --------------------------------------------- get MP target ---------------------------------------------
393  const Eigen::Matrix4f boxPose = targ.pose;
394  const Eigen::Vector6f boxTwist = targ.vel;
395  // --------------------------------------------- obj admittance control ---------------------------------------------
396  // admittance
397  Eigen::Vector6f objPoseError;
398  objPoseError.head(3) = rt.virtualPose.block<3, 1>(0, 3) - boxPose.block<3, 1>(0, 3);
399  const Eigen::Matrix3f objDiffMat = rt.virtualPose.block<3, 3>(0, 0) * boxPose.block<3, 3>(0, 0).transpose();
400  objPoseError.tail(3) = VirtualRobot::MathTools::eigen3f2rpy(objDiffMat);
401 
402 
403  Eigen::Vector6f objAcc = Eigen::Vector6f::Zero();
404  Eigen::Vector6f objVel = Eigen::Vector6f::Zero();
405  for (size_t i = 0; i < 6; i++)
406  {
407  objAcc(i) = KmAdmittance(i) * objFTValue(i)
408  - cfg.KpAdmittance(i) * objPoseError(i)
409  - cfg.KdAdmittance(i) * rt.virtualVel(i);
410  }
411  objVel = rt.virtualVel + 0.5 * deltaT * (objAcc + rt.virtualAcc);
412  const Eigen::Vector6f deltaObjPose = 0.5 * deltaT * (objVel + rt.virtualVel);
413  rt.virtualAcc = objAcc;
414  rt.virtualVel = objVel;
415  rt.virtualPose.block<3, 1>(0, 3) += deltaObjPose.head(3);
416  rt.virtualPose.block<3, 3>(0, 0) = VirtualRobot::MathTools::rpy2eigen3f(
417  deltaObjPose(3),
418  deltaObjPose(4),
419  deltaObjPose(5)) * rt.virtualPose.block<3, 3>(0, 0);
420 
421  // --------------------------------------------- convert to tcp pose ---------------------------------------------
422  Eigen::Matrix4f tcpTargetPoseLeft = rt.virtualPose;
423  Eigen::Matrix4f tcpTargetPoseRight = rt.virtualPose;
424  tcpTargetPoseLeft.block<3, 1>(0, 3) += rt.virtualPose.block<3, 3>(0, 0) * (objCom2TCPLeft - deltaPoseForWrenchControl.block<3, 1>(0, 0));
425  tcpTargetPoseRight.block<3, 1>(0, 3) += rt.virtualPose.block<3, 3>(0, 0) * (objCom2TCPRight - deltaPoseForWrenchControl.block<3, 1>(6, 0));
426 
427  // --------------------------------------------- Impedance control ---------------------------------------------
428  Eigen::Vector12f poseError;
429  Eigen::Matrix3f diffMat = tcpTargetPoseLeft.block<3, 3>(0, 0) * currentLeftPose.block<3, 3>(0, 0).transpose();
430  poseError.block<3, 1>(0, 0) = tcpTargetPoseLeft.block<3, 1>(0, 3) - currentLeftPose.block<3, 1>(0, 3);
431  poseError.block<3, 1>(3, 0) = VirtualRobot::MathTools::eigen3f2rpy(diffMat);
432 
433  diffMat = tcpTargetPoseRight.block<3, 3>(0, 0) * currentRightPose.block<3, 3>(0, 0).transpose();
434  poseError.block<3, 1>(6, 0) = tcpTargetPoseRight.block<3, 1>(0, 3) - currentRightPose.block<3, 1>(0, 3);
435  poseError.block<3, 1>(9, 0) = VirtualRobot::MathTools::eigen3f2rpy(diffMat);
436 
437  Eigen::Vector12f forceImpedance;
438  for (size_t i = 0; i < 12; i++)
439  {
440  forceImpedance(i) = cfg.KpImpedance(i) * poseError(i) - cfg.KdImpedance(i) * currentTwist(i);
441  // forceImpedance(i + 6) = KpImpedance(i) * poseError(i + 6) - KdImpedance(i) * currentTwist(i + 6);
442  }
443 
444  // --------------------------------------------- Nullspace control ---------------------------------------------
445  const Eigen::VectorXf leftNullspaceTorque = cfg.knull * (cfg.desiredJointValuesLeft - leftqpos) - cfg.dnull * leftqvel;
446  const Eigen::VectorXf rightNullspaceTorque = cfg.knull * (cfg.desiredJointValuesRight - rightqpos) - cfg.dnull * rightqvel;
447 
448  // --------------------------------------------- Set Torque Control Command ---------------------------------------------
449  // float lambda = 1;
450 
451  // torque limit
452  const auto setTargets = [&](auto & rtarm, const auto & jacobi, const auto & nullspaceTorque, int forceImpOffset)
453  {
454  const Eigen::MatrixXf jtpinv = rtarm.IK->computePseudoInverseJacobianMatrix(jacobi.transpose(), lambda);
455  const Eigen::VectorXf desiredJointTorques = jacobi.transpose() * forceImpedance.block<6, 1>(forceImpOffset, 0) +
456  (I - jacobi.transpose() * jtpinv) * nullspaceTorque;
457  for (size_t i = 0; i < rtarm.targets.size(); ++i)
458  {
459  float desiredTorque = desiredJointTorques(i);
460  if (isnan(desiredTorque))
461  {
462  desiredTorque = 0;
463  }
464  desiredTorque = (desiredTorque > cfg.torqueLimit) ? cfg.torqueLimit : desiredTorque;
465  desiredTorque = (desiredTorque < -cfg.torqueLimit) ? -cfg.torqueLimit : desiredTorque;
466  dbgOut.desired_torques[rtarm.jointNames[i]] = desiredJointTorques(i);
467  rtarm.targets.at(i)->torque = desiredTorque;
468  }
469  };
470  setTargets(rt.left, jacobiL, leftNullspaceTorque, 0);
471  setTargets(rt.right, jacobiR, rightNullspaceTorque, 6);
472  {
473  const Eigen::MatrixXf jtpinvL = rt.left.IK->computePseudoInverseJacobianMatrix(jacobiL.transpose(), lambda);
474  const Eigen::VectorXf leftJointDesiredTorques = jacobiL.transpose() * forceImpedance.head(6) + (I - jacobiL.transpose() * jtpinvL) * leftNullspaceTorque;
475  for (size_t i = 0; i < rt.left.targets.size(); ++i)
476  {
477  float desiredTorque = leftJointDesiredTorques(i);
478  if (isnan(desiredTorque))
479  {
480  desiredTorque = 0;
481  }
482  desiredTorque = (desiredTorque > cfg.torqueLimit) ? cfg.torqueLimit : desiredTorque;
483  desiredTorque = (desiredTorque < -cfg.torqueLimit) ? -cfg.torqueLimit : desiredTorque;
484  dbgOut.desired_torques[rt.left.jointNames[i]] = leftJointDesiredTorques(i);
485  rt.left.targets.at(i)->torque = desiredTorque;
486  }
487  }
488 
489  {
490  const Eigen::MatrixXf jtpinvR = rt.right.IK->computePseudoInverseJacobianMatrix(jacobiR.transpose(), lambda);
491  const Eigen::VectorXf rightJointDesiredTorques = jacobiR.transpose() * forceImpedance.tail(6) + (I - jacobiR.transpose() * jtpinvR) * rightNullspaceTorque;
492  for (size_t i = 0; i < rt.right.targets.size(); ++i)
493  {
494  float desiredTorque = rightJointDesiredTorques(i);
495  if (isnan(desiredTorque))
496  {
497  desiredTorque = 0;
498  }
499  desiredTorque = (desiredTorque > cfg.torqueLimit) ? cfg.torqueLimit : desiredTorque;
500  desiredTorque = (desiredTorque < - cfg.torqueLimit) ? - cfg.torqueLimit : desiredTorque;
501  dbgOut.desired_torques[rt.right.jointNames[i]] = rightJointDesiredTorques(i);
502  rt.right.targets.at(i)->torque = desiredTorque;
503  }
504  }
505 
506  // --------------------------------------------- debug output ---------------------------------------------
507  dbgOut.currentBoxPose = currentBoxPose;
508  dbgOut.forceImpedance = forceImpedance;
509  dbgOut.poseError = poseError;
510  // dbgOut.wrenchesConstrained = wrenchesConstrained;
511  dbgOut.wrenchesMeasuredInRoot = wrenchesMeasuredInRoot;
512  // dbgOut.wrenchDMP = wrenchDMP;
513  // dbgOut.computedBoxWrench = computedBoxWrench;
514 
515  dbgOut.virtualPose_x = rt.virtualPose(0, 3);
516  dbgOut.virtualPose_y = rt.virtualPose(1, 3);
517  dbgOut.virtualPose_z = rt.virtualPose(2, 3);
518 
519  dbgOut.objPose_x = boxCurrentPose(0, 3);
520  dbgOut.objPose_y = boxCurrentPose(1, 3);
521  dbgOut.objPose_z = boxCurrentPose(2, 3);
522 
523  dbgOut.objForce_x = objFTValue(0);
524  dbgOut.objForce_y = objFTValue(1);
525  dbgOut.objForce_z = objFTValue(2);
526  dbgOut.objTorque_x = objFTValue(3);
527  dbgOut.objTorque_y = objFTValue(4);
528  dbgOut.objTorque_z = objFTValue(5);
529 
530  dbgOut.objVel_x = objVel(0);
531  dbgOut.objVel_y = objVel(1);
532  dbgOut.objVel_z = objVel(2);
533  dbgOut.objVel_rx = objVel(3);
534  dbgOut.objVel_ry = objVel(4);
535  dbgOut.objVel_rz = objVel(5);
536 
537  dbgOut.deltaPose_x = deltaObjPose(0);
538  dbgOut.deltaPose_y = deltaObjPose(1);
539  dbgOut.deltaPose_z = deltaObjPose(2);
540  dbgOut.deltaPose_rx = deltaObjPose(3);
541  dbgOut.deltaPose_ry = deltaObjPose(4);
542  dbgOut.deltaPose_rz = deltaObjPose(5);
543 
544  dbgOut.modifiedPoseRight_x = tcpTargetPoseRight(0, 3);
545  dbgOut.modifiedPoseRight_y = tcpTargetPoseRight(1, 3);
546  dbgOut.modifiedPoseRight_z = tcpTargetPoseRight(2, 3);
547 
548  dbgOut.currentPoseLeft_x = currentLeftPose(0, 3);
549  dbgOut.currentPoseLeft_y = currentLeftPose(1, 3);
550  dbgOut.currentPoseLeft_z = currentLeftPose(2, 3);
551 
552 
553 
554  dbgOut.modifiedPoseLeft_x = tcpTargetPoseLeft(0, 3);
555  dbgOut.modifiedPoseLeft_y = tcpTargetPoseLeft(1, 3);
556  dbgOut.modifiedPoseLeft_z = tcpTargetPoseLeft(2, 3);
557 
558  dbgOut.currentPoseRight_x = currentRightPose(0, 3);
559  dbgOut.currentPoseRight_y = currentRightPose(1, 3);
560  dbgOut.currentPoseRight_z = currentRightPose(2, 3);
561 
562 
563  dbgOut.dmpBoxPose_x = boxPose(0, 3);
564  dbgOut.dmpBoxPose_y = boxPose(1, 3);
565  dbgOut.dmpBoxPose_z = boxPose(2, 3);
566 
567  dbgOut.dmpTwist_x = boxTwist(0);
568  dbgOut.dmpTwist_y = boxTwist(1);
569  dbgOut.dmpTwist_z = boxTwist(2);
570  dbgOut.rx = rRight(0);
571  dbgOut.ry = rRight(1);
572  dbgOut.rz = rRight(2);
573 
574  // dbgOut.modifiedTwist_lx = twistDMP(0);
575  // dbgOut.modifiedTwist_ly = twistDMP(1);
576  // dbgOut.modifiedTwist_lz = twistDMP(2);
577  // dbgOut.modifiedTwist_rx = twistDMP(6);
578  // dbgOut.modifiedTwist_ry = twistDMP(7);
579  // dbgOut.modifiedTwist_rz = twistDMP(8);
580 
581  // dbgOut.forcePID = forcePIDInRootForDebug;
582 
583  debugOutputData.commitWrite();
584 
585  }
586 
588  {
589  std::lock_guard guard{debugOutputDataReadMutex};
590  const auto& buf = debugOutputData.getUpToDateReadBuffer();
591  StringVariantBaseMap datafields;
592 
593  for (const auto& [name, val] : buf.desired_torques)
594  {
595  datafields[name] = new Variant(val);
596  }
597 
598  const auto& reportElements = [&](const auto & vec, const std::string & pre)
599  {
600  for (int i = 0; i < vec.rows(); ++i)
601  {
602  datafields[pre + std::to_string(i)] = new Variant(vec(i));
603  }
604  };
605  reportElements(buf.forceImpedance, "forceImpedance_");
606  reportElements(buf.forcePID, "forcePID_");
607  reportElements(buf.poseError, "poseError_");
608  reportElements(buf.wrenchesConstrained, "wrenchesConstrained_");
609  reportElements(buf.wrenchesMeasuredInRoot, "wrenchesMeasuredInRoot_");
610  reportElements(buf.wrenchesConstrained, "wrenchesConstrained_");
611  reportElements(buf.wrenchesConstrained, "wrenchesConstrained_");
612 
613  datafields["virtualPose_x"] = new Variant(buf.virtualPose_x);
614  datafields["virtualPose_y"] = new Variant(buf.virtualPose_y);
615  datafields["virtualPose_z"] = new Variant(buf.virtualPose_z);
616 
617  datafields["objPose_x"] = new Variant(buf.objPose_x);
618  datafields["objPose_y"] = new Variant(buf.objPose_y);
619  datafields["objPose_z"] = new Variant(buf.objPose_z);
620 
621  datafields["objForce_x"] = new Variant(buf.objForce_x);
622  datafields["objForce_y"] = new Variant(buf.objForce_y);
623  datafields["objForce_z"] = new Variant(buf.objForce_z);
624  datafields["objTorque_x"] = new Variant(buf.objTorque_x);
625  datafields["objTorque_y"] = new Variant(buf.objTorque_y);
626  datafields["objTorque_z"] = new Variant(buf.objTorque_z);
627 
628  datafields["objVel_x"] = new Variant(buf.objVel_x);
629  datafields["objVel_y"] = new Variant(buf.objVel_y);
630  datafields["objVel_z"] = new Variant(buf.objVel_z);
631  datafields["objVel_rx"] = new Variant(buf.objVel_rx);
632  datafields["objVel_ry"] = new Variant(buf.objVel_ry);
633  datafields["objVel_rz"] = new Variant(buf.objVel_rz);
634 
635  datafields["deltaPose_x"] = new Variant(buf.deltaPose_x);
636  datafields["deltaPose_y"] = new Variant(buf.deltaPose_y);
637  datafields["deltaPose_z"] = new Variant(buf.deltaPose_z);
638  datafields["deltaPose_rx"] = new Variant(buf.deltaPose_rx);
639  datafields["deltaPose_ry"] = new Variant(buf.deltaPose_ry);
640  datafields["deltaPose_rz"] = new Variant(buf.deltaPose_rz);
641 
642  datafields["modifiedPoseRight_x"] = new Variant(buf.modifiedPoseRight_x);
643  datafields["modifiedPoseRight_y"] = new Variant(buf.modifiedPoseRight_y);
644  datafields["modifiedPoseRight_z"] = new Variant(buf.modifiedPoseRight_z);
645  datafields["currentPoseLeft_x"] = new Variant(buf.currentPoseLeft_x);
646  datafields["currentPoseLeft_y"] = new Variant(buf.currentPoseLeft_y);
647  datafields["currentPoseLeft_z"] = new Variant(buf.currentPoseLeft_z);
648 
649 
650  datafields["modifiedPoseLeft_x"] = new Variant(buf.modifiedPoseLeft_x);
651  datafields["modifiedPoseLeft_y"] = new Variant(buf.modifiedPoseLeft_y);
652  datafields["modifiedPoseLeft_z"] = new Variant(buf.modifiedPoseLeft_z);
653 
654  datafields["currentPoseRight_x"] = new Variant(buf.currentPoseRight_x);
655  datafields["currentPoseRight_y"] = new Variant(buf.currentPoseRight_y);
656  datafields["currentPoseRight_z"] = new Variant(buf.currentPoseRight_z);
657  datafields["dmpBoxPose_x"] = new Variant(buf.dmpBoxPose_x);
658  datafields["dmpBoxPose_y"] = new Variant(buf.dmpBoxPose_y);
659  datafields["dmpBoxPose_z"] = new Variant(buf.dmpBoxPose_z);
660  datafields["dmpTwist_x"] = new Variant(buf.dmpTwist_x);
661  datafields["dmpTwist_y"] = new Variant(buf.dmpTwist_y);
662  datafields["dmpTwist_z"] = new Variant(buf.dmpTwist_z);
663 
664  datafields["modifiedTwist_lx"] = new Variant(buf.modifiedTwist_lx);
665  datafields["modifiedTwist_ly"] = new Variant(buf.modifiedTwist_ly);
666  datafields["modifiedTwist_lz"] = new Variant(buf.modifiedTwist_lz);
667  datafields["modifiedTwist_rx"] = new Variant(buf.modifiedTwist_rx);
668  datafields["modifiedTwist_ry"] = new Variant(buf.modifiedTwist_ry);
669  datafields["modifiedTwist_rz"] = new Variant(buf.modifiedTwist_rz);
670 
671  datafields["rx"] = new Variant(buf.rx);
672  datafields["ry"] = new Variant(buf.ry);
673  datafields["rz"] = new Variant(buf.rz);
674 
675 
676  debugObs->setDebugChannel("BimanualForceController", datafields);
677  }
678 
680  {
681  std::lock_guard guard{debugOutputDataReadMutex};
682  return debugOutputData.getUpToDateReadBuffer().currentBoxPose;
683  }
684 
686  {
687  ARMARX_CHECK_EXPRESSION(simox::math::is_homogeneous_transform(pose));
688  std::lock_guard guard{targBufWriteMutex};
689  targBuf.getWriteBuffer().pose = pose;
690  targBuf.commitWrite();
691  }
692 
694  {
696  std::lock_guard{cfgBufWriteMutex};
697  cfgBuf.getWriteBuffer().boxWidth = w;
698  cfgBuf.commitWrite();
699  }
701  const Eigen::Vector3f& velXYZ,
702  const Eigen::Vector3f& velRPY,
703  const Ice::Current&)
704  {
707  std::lock_guard guard{targBufWriteMutex};
708  targBuf.getWriteBuffer().vel.head<3>() = velXYZ;
709  targBuf.getWriteBuffer().vel.tail<3>() = velRPY;
710  targBuf.commitWrite();
711 
712  }
714  const Eigen::Matrix4f& pose,
715  const Eigen::Vector3f& velXYZ,
716  const Eigen::Vector3f& velRPY, const Ice::Current&)
717  {
718  ARMARX_CHECK_EXPRESSION(simox::math::is_homogeneous_transform(pose));
721  std::lock_guard guard{targBufWriteMutex};
722  targBuf.getWriteBuffer().pose = pose;
723  targBuf.getWriteBuffer().vel.head<3>() = velXYZ;
724  targBuf.getWriteBuffer().vel.tail<3>() = velRPY;
725  targBuf.commitWrite();
726  }
728  {
729  ARMARX_CHECK_EXPRESSION(simox::math::is_homogeneous_transform(pose));
730  std::lock_guard guard{targBufWriteMutex};
731  const Eigen::Matrix4f tmp = pose * targBuf.getWriteBuffer().pose;
732  targBuf.getWriteBuffer().pose = tmp;
733  targBuf.commitWrite();
734  }
735  void NJointBimanualCartesianAdmittanceController::moveBoxPosition(const Eigen::Vector3f& pos, const Ice::Current&)
736  {
738  std::lock_guard guard{targBufWriteMutex};
739  targBuf.getWriteBuffer().pose.topRightCorner<3, 1>() += pos;
740  targBuf.commitWrite();
741  }
742 
743  void NJointBimanualCartesianAdmittanceController::setConfig(const NJointBimanualCartesianAdmittanceControllerConfigPtr& ptr, const Ice::Current&)
744  {
746  ARMARX_CHECK_EQUAL(ptr->nullspace.desiredJointValuesLeft.size(), rt.left.targets.size());
747  ARMARX_CHECK_EQUAL(ptr->nullspace.desiredJointValuesRight.size(), rt.right.targets.size());
748  std::lock_guard{cfgBufWriteMutex};
749  updateConfig(*ptr);
750  cfgBuf.commitWrite();
751  }
752  void NJointBimanualCartesianAdmittanceController::setDesiredJointValuesLeft(const Ice::FloatSeq& vals, const Ice::Current&)
753  {
754  std::lock_guard{cfgBufWriteMutex};
756  cfgBuf.commitWrite();
757  }
758  void NJointBimanualCartesianAdmittanceController::setDesiredJointValuesRight(const Ice::FloatSeq& vals, const Ice::Current&)
759  {
760  std::lock_guard{cfgBufWriteMutex};
762  cfgBuf.commitWrite();
763  }
765  {
766  std::lock_guard{cfgBufWriteMutex};
767  updateNullspaceConfig(nullspace);
768  cfgBuf.commitWrite();
769  }
771  {
772  std::lock_guard{cfgBufWriteMutex};
773  updateAdmittanceConfig(admittanceObject);
774  cfgBuf.commitWrite();
775  }
777  {
778  std::lock_guard{cfgBufWriteMutex};
779  updateForceConfig(left, right);
780  cfgBuf.commitWrite();
781  }
783  {
784  std::lock_guard{cfgBufWriteMutex};
785  updateImpedanceConfig(left, right);
786  cfgBuf.commitWrite();
787  }
788 
790  {
791  std::lock_guard{cfgBufWriteMutex};
792  auto& buf = cfgBuf.getWriteBuffer();
797  buf.torqueLimit = cfg.torqueLimit;
798  buf.filterCoeff = cfg.filterCoeff;
799  buf.ftCalibrationTime = cfg.ftCalibrationTime;
800  buf.boxWidth = cfg.box.width;
801  }
803  {
804  std::lock_guard{cfgBufWriteMutex};
805  auto& buf = cfgBuf.getWriteBuffer();
806  ARMARX_CHECK_EQUAL(vals.size(), rt.left.targets.size());
807  buf.desiredJointValuesLeft = Eigen::Map<const Eigen::VectorXf>(
808  vals.data(), vals.size());
809  }
811  {
812  std::lock_guard{cfgBufWriteMutex};
813  auto& buf = cfgBuf.getWriteBuffer();
814  ARMARX_CHECK_EQUAL(vals.size(), rt.right.targets.size());
815  buf.desiredJointValuesRight = Eigen::Map<const Eigen::VectorXf>(
816  vals.data(), vals.size());
817  }
819  {
820  std::lock_guard{cfgBufWriteMutex};
821  auto& cfg = cfgBuf.getWriteBuffer();
824  cfg.knull = nullspace.k;
825  cfg.dnull = nullspace.d;
826  }
828  {
829  std::lock_guard{cfgBufWriteMutex};
830  auto& cfg = cfgBuf.getWriteBuffer();
831  cfg.KmAdmittance.block<3, 1>(0, 0) = admittanceObject.KmXYZ;
832  cfg.KmAdmittance.block<3, 1>(3, 0) = admittanceObject.KmRPY;
833 
834  cfg.KpAdmittance.block<3, 1>(0, 0) = admittanceObject.KpXYZ;
835  cfg.KpAdmittance.block<3, 1>(3, 0) = admittanceObject.KpRPY;
836 
837  cfg.KdAdmittance.block<3, 1>(0, 0) = admittanceObject.KdXYZ;
838  cfg.KdAdmittance.block<3, 1>(3, 0) = admittanceObject.KdRPY;
839  }
841  {
842  std::lock_guard{cfgBufWriteMutex};
843  auto& cfg = cfgBuf.getWriteBuffer();
844  //left
845  cfg.massLeft = forceLeft.mass;
846  cfg.CoMVecLeft = forceLeft.com;
847  cfg.forceOffsetLeft = forceLeft.offsetForce;
848  cfg.torqueOffsetLeft = forceLeft.offsetTorque;
849  cfg.targetWrench.block<3, 1>(0, 0) = forceLeft.wrenchXYZ;
850  cfg.targetWrench.block<3, 1>(3, 0) = forceLeft.wrenchRPY;
851  cfg.forceThreshold.block<3, 1>(0, 0) = forceLeft.forceThreshold;
852  //right
853  cfg.massRight = forceRight.mass;
854  cfg.CoMVecRight = forceRight.com;
855  cfg.forceOffsetRight = forceRight.offsetForce;
856  cfg.torqueOffsetRight = forceRight.offsetTorque;
857  cfg.targetWrench.block<3, 1>(6, 0) = forceRight.wrenchXYZ;
858  cfg.targetWrench.block<3, 1>(9, 0) = forceRight.wrenchRPY;
859  cfg.forceThreshold.block<3, 1>(3, 0) = forceRight.forceThreshold;
860  }
862  const detail::NJBmanCartAdmCtrl::Impedance& impedanceRight)
863  {
864  std::lock_guard{cfgBufWriteMutex};
865  auto& cfg = cfgBuf.getWriteBuffer();
866  cfg.KpImpedance.block<3, 1>(0, 0) = impedanceLeft.KpXYZ;
867  cfg.KpImpedance.block<3, 1>(3, 0) = impedanceLeft.KpRPY;
868  cfg.KpImpedance.block<3, 1>(6, 0) = impedanceRight.KpXYZ;
869  cfg.KpImpedance.block<3, 1>(9, 0) = impedanceRight.KpRPY;
870 
871  cfg.KdImpedance.block<3, 1>(0, 0) = impedanceLeft.KdXYZ;
872  cfg.KdImpedance.block<3, 1>(3, 0) = impedanceLeft.KdRPY;
873  cfg.KdImpedance.block<3, 1>(6, 0) = impedanceRight.KdXYZ;
874  cfg.KdImpedance.block<3, 1>(9, 0) = impedanceRight.KdRPY;
875  }
876 }
armarx::control::deprecated_njoint_mp_controller::bimanual::NJointBimanualCartesianAdmittanceController::getClassName
std::string getClassName(const Ice::Current &) const override
Definition: NJointBimanualCartesianAdmittanceController.cpp:167
armarx::detail::NJBmanCartAdmCtrl::Admittance::KmRPY
Eigen::Vector3f KmRPY
Definition: CartesianAdmittanceControllerInterface.ice:65
armarx::ControlTargetBase::asA
const T * asA() const
Definition: ControlTargetBase.h:76
armarx::Variant
The Variant class is described here: Variants.
Definition: Variant.h:224
armarx::detail::NJBmanCartAdmCtrl::Nullspace
Definition: CartesianAdmittanceControllerInterface.ice:44
armarx::control::deprecated_njoint_mp_controller::bimanual::NJointBimanualCartesianAdmittanceController::rtPreActivateController
void rtPreActivateController()
This function is called before the controller is activated.
Definition: NJointBimanualCartesianAdmittanceController.cpp:132
armarx::detail::NJBmanCartAdmCtrl::Impedance::KpRPY
Eigen::Vector3f KpRPY
Definition: CartesianAdmittanceControllerInterface.ice:54
armarx::detail::NJBmanCartAdmCtrl::Admittance
Definition: CartesianAdmittanceControllerInterface.ice:58
armarx::TripleBuffer::getWriteBuffer
T & getWriteBuffer()
Definition: TripleBuffer.h:90
armarx::NJointControllerRegistration
Definition: NJointControllerRegistry.h:74
armarx::NJointControllerBase::useSynchronizedRtRobot
const VirtualRobot::RobotPtr & useSynchronizedRtRobot(bool updateCollisionModel=false)
Requests a VirtualRobot for use in rtRun *.
Definition: NJointController.cpp:293
armarx::control::deprecated_njoint_mp_controller::bimanual::NJointBimanualCartesianAdmittanceController::setImpedanceConfig
void setImpedanceConfig(const detail::NJBmanCartAdmCtrl::Impedance &left, const detail::NJBmanCartAdmCtrl::Impedance &right, const Ice::Current &=Ice::emptyCurrent) override
Definition: NJointBimanualCartesianAdmittanceController.cpp:782
armarx::StringVariantBaseMap
std::map< std::string, VariantBasePtr > StringVariantBaseMap
Definition: ManagedIceObject.h:111
ARMARX_IMPORTANT
#define ARMARX_IMPORTANT
Definition: Logging.h:183
armarx::SensorValueBase::asA
const T * asA() const
Definition: SensorValueBase.h:82
armarx::SensorValueBase
The SensorValueBase class.
Definition: SensorValueBase.h:40
armarx::NJointBimanualCartesianAdmittanceControllerConfig::ftCalibrationTime
double ftCalibrationTime
Definition: CartesianAdmittanceControllerInterface.ice:95
armarx::ControlTargetBase
Brief description of class JointControlTargetBase.
Definition: ControlTargetBase.h:47
armarx::NJointBimanualCartesianAdmittanceControllerConfig
Definition: CartesianAdmittanceControllerInterface.ice:83
armarx::TripleBuffer::commitWrite
void commitWrite()
Definition: TripleBuffer.h:146
armarx::detail::NJBmanCartAdmCtrl::Force::offsetTorque
Eigen::Vector3f offsetTorque
Definition: CartesianAdmittanceControllerInterface.ice:76
armarx::WriteBufferedTripleBuffer::commitWrite
void commitWrite()
Definition: TripleBuffer.h:326
armarx::detail::NJBmanCartAdmCtrl::Admittance::KdXYZ
Eigen::Vector3f KdXYZ
Definition: CartesianAdmittanceControllerInterface.ice:62
armarx::NJointBimanualCartesianAdmittanceControllerConfig::nullspace
detail::NJBmanCartAdmCtrl::Nullspace nullspace
Definition: CartesianAdmittanceControllerInterface.ice:86
armarx::detail::NJBmanCartAdmCtrl::Force::mass
float mass
Definition: CartesianAdmittanceControllerInterface.ice:73
armarx::NJointControllerBase::useControlTarget
ControlTargetBase * useControlTarget(const std::string &deviceName, const std::string &controlMode)
Declares to calculate the ControlTarget for the given ControlDevice in the given ControlMode when rtR...
Definition: NJointController.cpp:410
ARMARX_CHECK_NOT_NULL
#define ARMARX_CHECK_NOT_NULL(ptr)
This macro evaluates whether ptr is not null and if it turns out to be false it will throw an Express...
Definition: ExpressionException.h:206
armarx::NJointBimanualCartesianAdmittanceControllerInterface::getBoxPose
Eigen::Matrix4f getBoxPose()
armarx::WriteBufferedTripleBuffer::updateReadBuffer
bool updateReadBuffer() const
Swaps in the hidden buffer if it contains new data.
Definition: TripleBuffer.h:321
armarx::control::deprecated_njoint_mp_controller::bimanual::NJointBimanualCartesianAdmittanceController::updateDesiredJointValuesLeft
void updateDesiredJointValuesLeft(const Ice::FloatSeq &cfg)
Definition: NJointBimanualCartesianAdmittanceController.cpp:802
armarx::control::deprecated_njoint_mp_controller::bimanual::NJointBimanualCartesianAdmittanceController::updateConfig
void updateConfig(const NJointBimanualCartesianAdmittanceControllerConfig &cfg)
Definition: NJointBimanualCartesianAdmittanceController.cpp:789
armarx::detail::NJBmanCartAdmCtrl::Force
Definition: CartesianAdmittanceControllerInterface.ice:67
ARMARX_ON_SCOPE_EXIT
#define ARMARX_ON_SCOPE_EXIT
Executes given code when the enclosing scope is left.
Definition: OnScopeExit.h:112
armarx::control::deprecated_njoint_mp_controller::bimanual::NJointBimanualCartesianAdmittanceController::setBoxPose
void setBoxPose(const Eigen::Matrix4f &pose, const Ice::Current &=Ice::emptyCurrent) override
Definition: NJointBimanualCartesianAdmittanceController.cpp:685
armarx::NJointBimanualCartesianAdmittanceControllerConfig::filterCoeff
float filterCoeff
Definition: CartesianAdmittanceControllerInterface.ice:93
armarx::NJointBimanualCartesianAdmittanceControllerConfig::admittanceObject
detail::NJBmanCartAdmCtrl::Admittance admittanceObject
Definition: CartesianAdmittanceControllerInterface.ice:89
armarx::control::deprecated_njoint_mp_controller::bimanual::NJointBimanualCartesianAdmittanceController::moveBoxPose
void moveBoxPose(const Eigen::Matrix4f &pose, const Ice::Current &=Ice::emptyCurrent) override
Definition: NJointBimanualCartesianAdmittanceController.cpp:727
armarx::control::deprecated_njoint_mp_controller::bimanual::NJointBimanualCartesianAdmittanceController::setDesiredJointValuesRight
void setDesiredJointValuesRight(const Ice::FloatSeq &vals, const Ice::Current &=Ice::emptyCurrent) override
Definition: NJointBimanualCartesianAdmittanceController.cpp:758
armarx::detail::NJBmanCartAdmCtrl::Force::wrenchRPY
Eigen::Vector3f wrenchRPY
Definition: CartesianAdmittanceControllerInterface.ice:70
armarx::detail::NJBmanCartAdmCtrl::Force::com
Eigen::Vector3f com
Definition: CartesianAdmittanceControllerInterface.ice:74
armarx::control::deprecated_njoint_mp_controller::bimanual::NJointBimanualCartesianAdmittanceController::setForceConfig
void setForceConfig(const detail::NJBmanCartAdmCtrl::Force &left, const detail::NJBmanCartAdmCtrl::Force &right, const Ice::Current &=Ice::emptyCurrent) override
Definition: NJointBimanualCartesianAdmittanceController.cpp:776
armarx::NJointControllerBase::rtGetRobot
const VirtualRobot::RobotPtr & rtGetRobot()
TODO make protected and use attorneys.
Definition: NJointControllerBase.h:845
armarx::detail::NJBmanCartAdmCtrl::Force::wrenchXYZ
Eigen::Vector3f wrenchXYZ
Definition: CartesianAdmittanceControllerInterface.ice:69
std::isfinite
bool isfinite(const std::vector< T, Ts... > &v)
Definition: algorithm.h:327
armarx::detail::ControlThreadOutputBufferEntry
Definition: ControlThreadOutputBuffer.h:177
armarx::NJointBimanualCartesianAdmittanceControllerConfig::box
detail::NJBmanCartAdmCtrl::Box box
Definition: CartesianAdmittanceControllerInterface.ice:85
armarx::detail::NJBmanCartAdmCtrl::Impedance::KdRPY
Eigen::Vector3f KdRPY
Definition: CartesianAdmittanceControllerInterface.ice:56
GfxTL::Identity
void Identity(MatrixXX< N, N, T > *a)
Definition: MatrixXX.h:523
armarx::detail::NJBmanCartAdmCtrl::Nullspace::desiredJointValuesLeft
Ice::FloatSeq desiredJointValuesLeft
Definition: CartesianAdmittanceControllerInterface.ice:46
armarx::detail::NJBmanCartAdmCtrl::Box::width
float width
Definition: CartesianAdmittanceControllerInterface.ice:41
armarx::control::deprecated_njoint_mp_controller::bimanual::NJointBimanualCartesianAdmittanceController::updateAdmittanceConfig
void updateAdmittanceConfig(const detail::NJBmanCartAdmCtrl::Admittance admittanceObject)
Definition: NJointBimanualCartesianAdmittanceController.cpp:827
armarx::detail::NJBmanCartAdmCtrl::Nullspace::k
float k
Definition: CartesianAdmittanceControllerInterface.ice:48
armarx::WriteBufferedTripleBuffer::_getNonConstReadBuffer
T & _getNonConstReadBuffer()
Definition: TripleBuffer.h:302
armarx::detail::NJBmanCartAdmCtrl::Impedance::KpXYZ
Eigen::Vector3f KpXYZ
Definition: CartesianAdmittanceControllerInterface.ice:53
data
uint8_t data[1]
Definition: EtherCATFrame.h:68
armarx::control::deprecated_njoint_mp_controller::bimanual::NJointBimanualCartesianAdmittanceController::setNullspaceConfig
void setNullspaceConfig(const detail::NJBmanCartAdmCtrl::Nullspace &nullspace, const Ice::Current &=Ice::emptyCurrent) override
Definition: NJointBimanualCartesianAdmittanceController.cpp:764
armarx::control::deprecated_njoint_mp_controller::bimanual::NJointBimanualCartesianAdmittanceController::updateForceConfig
void updateForceConfig(const detail::NJBmanCartAdmCtrl::Force &left, const detail::NJBmanCartAdmCtrl::Force &right)
Definition: NJointBimanualCartesianAdmittanceController.cpp:840
armarx::detail::NJBmanCartAdmCtrl::Admittance::KpXYZ
Eigen::Vector3f KpXYZ
Definition: CartesianAdmittanceControllerInterface.ice:60
armarx::control::deprecated_njoint_mp_controller::bimanual::NJointBimanualCartesianAdmittanceController::NJointBimanualCartesianAdmittanceController
NJointBimanualCartesianAdmittanceController(const RobotUnitPtr &, const NJointControllerConfigPtr &config, const VirtualRobot::RobotPtr &)
Definition: NJointBimanualCartesianAdmittanceController.cpp:13
armarx::control::deprecated_njoint_mp_controller::bimanual::NJointBimanualCartesianAdmittanceController::rtRun
void rtRun(const IceUtil::Time &sensorValuesTimestamp, const IceUtil::Time &timeSinceLastIteration) override
TODO make protected and use attorneys.
Definition: NJointBimanualCartesianAdmittanceController.cpp:201
armarx::control::deprecated_njoint_mp_controller::bimanual::NJointBimanualCartesianAdmittanceController::moveBoxPosition
void moveBoxPosition(const Eigen::Vector3f &pos, const Ice::Current &=Ice::emptyCurrent) override
Definition: NJointBimanualCartesianAdmittanceController.cpp:735
armarx::detail::NJBmanCartAdmCtrl::Force::forceThreshold
Eigen::Vector3f forceThreshold
Definition: CartesianAdmittanceControllerInterface.ice:78
armarx::control::deprecated_njoint_mp_controller::bimanual::NJointBimanualCartesianAdmittanceController::updateImpedanceConfig
void updateImpedanceConfig(const detail::NJBmanCartAdmCtrl::Impedance &left, const detail::NJBmanCartAdmCtrl::Impedance &right)
Definition: NJointBimanualCartesianAdmittanceController.cpp:861
armarx::control::deprecated_njoint_mp_controller::bimanual::NJointBimanualCartesianAdmittanceController::setBoxWidth
void setBoxWidth(float w, const Ice::Current &=Ice::emptyCurrent) override
Definition: NJointBimanualCartesianAdmittanceController.cpp:693
armarx::WriteBufferedTripleBuffer::getWriteBuffer
T & getWriteBuffer()
Definition: TripleBuffer.h:280
armarx::control::deprecated_njoint_mp_controller::bimanual::NJointBimanualCartesianAdmittanceController::onPublish
virtual void onPublish(const SensorAndControl &, const DebugDrawerInterfacePrx &, const DebugObserverInterfacePrx &)
Definition: NJointBimanualCartesianAdmittanceController.cpp:587
armarx::detail::NJBmanCartAdmCtrl::Impedance
Definition: CartesianAdmittanceControllerInterface.ice:51
ARMARX_CHECK_GREATER_EQUAL
#define ARMARX_CHECK_GREATER_EQUAL(lhs, rhs)
This macro evaluates whether lhs is greater or equal (>=) rhs and if it turns out to be false it will...
Definition: ExpressionException.h:123
armarx::NJointBimanualCartesianAdmittanceControllerConfig::impedanceRight
detail::NJBmanCartAdmCtrl::Impedance impedanceRight
Definition: CartesianAdmittanceControllerInterface.ice:88
armarx::armem::Time
armarx::core::time::DateTime Time
Definition: forward_declarations.h:13
armarx::to_string
const std::string & to_string(const std::string &s)
Definition: StringHelpers.h:40
armarx::detail::NJBmanCartAdmCtrl::Force::offsetForce
Eigen::Vector3f offsetForce
Definition: CartesianAdmittanceControllerInterface.ice:75
armarx::NJointBimanualCartesianAdmittanceControllerConfig::forceLeft
detail::NJBmanCartAdmCtrl::Force forceLeft
Definition: CartesianAdmittanceControllerInterface.ice:90
armarx::control::deprecated_njoint_mp_controller::bimanual::NJointBimanualCartesianAdmittanceController::updateDesiredJointValuesRight
void updateDesiredJointValuesRight(const Ice::FloatSeq &cfg)
Definition: NJointBimanualCartesianAdmittanceController.cpp:810
CycleUtil.h
armarx::control::deprecated_njoint_mp_controller::bimanual::NJointBimanualCartesianAdmittanceController::setConfig
void setConfig(const NJointBimanualCartesianAdmittanceControllerConfigPtr &ptr, const Ice::Current &=Ice::emptyCurrent) override
Definition: NJointBimanualCartesianAdmittanceController.cpp:743
armarx::WriteBufferedTripleBuffer::reinitAllBuffers
void reinitAllBuffers(const T &init)
Definition: TripleBuffer.h:332
armarx::detail::NJBmanCartAdmCtrl::Admittance::KmXYZ
Eigen::Vector3f KmXYZ
Definition: CartesianAdmittanceControllerInterface.ice:64
GfxTL::Matrix3f
MatrixXX< 3, 3, float > Matrix3f
Definition: MatrixXX.h:600
GfxTL::Matrix4f
MatrixXX< 4, 4, float > Matrix4f
Definition: MatrixXX.h:601
ARMARX_CHECK_EXPRESSION
#define ARMARX_CHECK_EXPRESSION(expression)
This macro evaluates the expression and if it turns out to be false it will throw an ExpressionExcept...
Definition: ExpressionException.h:73
ARMARX_INFO
#define ARMARX_INFO
Definition: Logging.h:174
NJointBimanualCartesianAdmittanceController.h
armarx::control::deprecated_njoint_mp_controller::bimanual::NJointBimanualCartesianAdmittanceController::setBoxVelocity
void setBoxVelocity(const Eigen::Vector3f &velXYZ, const Eigen::Vector3f &velRPY, const Ice::Current &=Ice::emptyCurrent) override
Definition: NJointBimanualCartesianAdmittanceController.cpp:700
IceInternal::ProxyHandle<::IceProxy::armarx::DebugDrawerInterface >
armarx::control::deprecated_njoint_mp_controller::bimanual::NJointBimanualCartesianAdmittanceController::setBoxPoseAndVelocity
void setBoxPoseAndVelocity(const Eigen::Matrix4f &pose, const Eigen::Vector3f &velXYZ, const Eigen::Vector3f &velRPY, const Ice::Current &=Ice::emptyCurrent) override
Definition: NJointBimanualCartesianAdmittanceController.cpp:713
armarx::control::deprecated_njoint_mp_controller::bimanual::registrationControllerNJointBimanualCartesianAdmittanceController
NJointControllerRegistration< NJointBimanualCartesianAdmittanceController > registrationControllerNJointBimanualCartesianAdmittanceController("NJointBimanualCartesianAdmittanceController")
armarx::NJointBimanualCartesianAdmittanceControllerConfig::forceRight
detail::NJBmanCartAdmCtrl::Force forceRight
Definition: CartesianAdmittanceControllerInterface.ice:91
Eigen::Matrix< float, 6, 1 >
armarx::WriteBufferedTripleBuffer::getReadBuffer
const T & getReadBuffer() const
Definition: TripleBuffer.h:291
armarx::NJointBimanualCartesianAdmittanceControllerConfig::torqueLimit
float torqueLimit
Definition: CartesianAdmittanceControllerInterface.ice:94
armarx::TripleBuffer::getUpToDateReadBuffer
const T & getUpToDateReadBuffer() const
Definition: TripleBuffer.h:108
ARMARX_CHECK_EQUAL
#define ARMARX_CHECK_EQUAL(lhs, rhs)
This macro evaluates whether lhs is equal (==) rhs and if it turns out to be false it will throw an E...
Definition: ExpressionException.h:130
armarx::SensorValueForceTorque
Definition: SensorValueForceTorque.h:31
armarx::control::deprecated_njoint_mp_controller::bimanual::NJointBimanualCartesianAdmittanceController::setDesiredJointValuesLeft
void setDesiredJointValuesLeft(const Ice::FloatSeq &vals, const Ice::Current &=Ice::emptyCurrent) override
Definition: NJointBimanualCartesianAdmittanceController.cpp:752
armarx::transpose
std::vector< std::vector< T > > transpose(const std::vector< std::vector< T >> &src, Thrower thrower)
Definition: SimoxCSpace.cpp:706
armarx::detail::NJBmanCartAdmCtrl::Admittance::KdRPY
Eigen::Vector3f KdRPY
Definition: CartesianAdmittanceControllerInterface.ice:63
armarx::NJointBimanualCartesianAdmittanceControllerConfig::impedanceLeft
detail::NJBmanCartAdmCtrl::Impedance impedanceLeft
Definition: CartesianAdmittanceControllerInterface.ice:87
armarx::control::deprecated_njoint_mp_controller::bimanual::NJointBimanualCartesianAdmittanceController::updateNullspaceConfig
void updateNullspaceConfig(const detail::NJBmanCartAdmCtrl::Nullspace &nullspace)
Definition: NJointBimanualCartesianAdmittanceController.cpp:818
armarx::detail::NJBmanCartAdmCtrl::Admittance::KpRPY
Eigen::Vector3f KpRPY
Definition: CartesianAdmittanceControllerInterface.ice:61
armarx::detail::NJBmanCartAdmCtrl::Impedance::KdXYZ
Eigen::Vector3f KdXYZ
Definition: CartesianAdmittanceControllerInterface.ice:55
armarx::control::deprecated_njoint_mp_controller::bimanual::NJointBimanualCartesianAdmittanceController::setAdmittanceConfig
void setAdmittanceConfig(const detail::NJBmanCartAdmCtrl::Admittance &admittanceObject, const Ice::Current &=Ice::emptyCurrent) override
Definition: NJointBimanualCartesianAdmittanceController.cpp:770
armarx::NJointControllerBase::useSensorValue
const SensorValueBase * useSensorValue(const std::string &sensorDeviceName) const
Get a const ptr to the given SensorDevice's SensorValue.
Definition: NJointController.cpp:383
VirtualRobot::RobotPtr
std::shared_ptr< class Robot > RobotPtr
Definition: Bus.h:18
armarx::control::deprecated_njoint_mp_controller::bimanual
Definition: NJointBimanualCartesianAdmittanceController.cpp:9
armarx::detail::NJBmanCartAdmCtrl::Nullspace::desiredJointValuesRight
Ice::FloatSeq desiredJointValuesRight
Definition: CartesianAdmittanceControllerInterface.ice:47
armarx::detail::NJBmanCartAdmCtrl::Nullspace::d
float d
Definition: CartesianAdmittanceControllerInterface.ice:49