KeypointsAdmittanceController.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of ArmarX.
3  *
4  * ArmarX is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation.
7  *
8  * ArmarX is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * @package ...
17  * @author Jianfeng Gao ( jianfeng dot gao at kit dot edu )
18  * @date 2021
19  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20  * GNU General Public License
21  */
22 
25 #include <VirtualRobot/MathTools.h>
26 
28 
29 
31 {
32 NJointControllerRegistration<NJointKeypointsAdmittanceController> registrationControllerNJointKeypointsAdmittanceController("NJointKeypointsAdmittanceController");
33 
35  const RobotUnitPtr& robotUnit,
36  const NJointControllerConfigPtr& config,
38 {
39  ARMARX_INFO << "--------------------------------------- creating keypoints admittance controller ---------------------------------------";
40  ConfigPtrT cfg = ConfigPtrT::dynamicCast(config);
41 
43  ARMARX_CHECK_EXPRESSION(robotUnit);
44  ARMARX_CHECK_EXPRESSION(!cfg->nodeSetName.empty());
46  kinematicChainName = cfg->nodeSetName;
47 
48  VirtualRobot::RobotNodeSetPtr rns = rtGetRobot()->getRobotNodeSet(cfg->nodeSetName);
49  ARMARX_CHECK_EXPRESSION(rns) << cfg->nodeSetName;
50 
51  jointNames.clear();
52  for (size_t i = 0; i < rns->getSize(); ++i)
53  {
54  std::string jointName = rns->getNode(i)->getName();
55  jointNames.push_back(jointName);
56  ControlTargetBase* ct = useControlTarget(jointName, ControlModes::Torque1DoF);
58  const SensorValueBase* sv = useSensorValue(jointName);
60  auto casted_ct = ct->asA<ControlTarget1DoFActuatorTorque>();
61  ARMARX_CHECK_EXPRESSION(casted_ct);
62  targets.push_back(casted_ct);
63 
64  const SensorValue1DoFActuatorTorque* torqueSensor = sv->asA<SensorValue1DoFActuatorTorque>();
65  const SensorValue1DoFActuatorVelocity* velocitySensor = sv->asA<SensorValue1DoFActuatorVelocity>();
66  const SensorValue1DoFActuatorPosition* positionSensor = sv->asA<SensorValue1DoFActuatorPosition>();
67  if (!torqueSensor)
68  {
69  ARMARX_WARNING << "No Torque sensor available for " << jointName;
70  }
71  if (!velocitySensor)
72  {
73  ARMARX_WARNING << "No velocity sensor available for " << jointName;
74  }
75  if (!positionSensor)
76  {
77  ARMARX_WARNING << "No position sensor available for " << jointName;
78  }
79 
80  torqueSensors.push_back(torqueSensor);
81  velocitySensors.push_back(velocitySensor);
82  positionSensors.push_back(positionSensor);
83  };
84  configFileName = cfg->controlParamJsonFile;
85  controller.initialize(rns, configFileName);
86  ftsensor.initialize(rns, robotUnit, configFileName);
87 
88  common::FTSensor::FTBufferData ftData;
89  ftData.ftFilter = ftsensor.s.ftFilter;
90  ftData.deadZoneForce = ftsensor.s.deadZoneForce;
91  ftData.deadZoneTorque = ftsensor.s.deadZoneTorque;
92  ftData.timeLimit = ftsensor.s.timeLimit;
93  ftData.tcpMass = ftsensor.s.tcpMass;
94  ftData.tcpCoMInFTSensorFrame = ftsensor.s.tcpCoMInFTSensorFrame;
95  ftData.enableTCPGravityCompensation = ftsensor.s.enableTCPGravityCompensation;
96  ftData.forceBaseline = ftsensor.s.forceBaseline;
97  ftData.torqueBaseline = ftsensor.s.torqueBaseline;
99 
100  law::KeypointsAdmittanceController::Config configData;
101  configData.kpImpedance = controller.s.kpImpedance;
102  configData.kdImpedance = controller.s.kdImpedance;
103  configData.kpAdmittance = controller.s.kpAdmittance;
104  configData.kdAdmittance = controller.s.kdAdmittance;
105  configData.kmAdmittance = controller.s.kmAdmittance;
106 
107  configData.kpNullspace = controller.s.kpNullspace;
108  configData.kdNullspace = controller.s.kdNullspace;
109 
110  configData.currentForceTorque.setZero();
111  configData.desiredNullspaceJointAngles = controller.s.desiredNullspaceJointAngles;
112 
113  configData.torqueLimit = controller.s.torqueLimit;
114  configData.qvelFilter = controller.s.qvelFilter;
115 
116  configData.numPoints = controller.s.numPoints;
117  configData.keypointKp = controller.s.keypointKp;
118  configData.keypointKd = controller.s.keypointKd;
119 
120  configData.currentKeypointPosition = controller.s.currentKeypointPosition;
121  configData.desiredKeypointPosition = controller.s.currentKeypointPosition;
122  configData.desiredKeypointVelocity = controller.s.desiredKeypointVelocity;
123  configData.keypointPositionFilter = controller.s.keypointPositionFilter;
124  configData.keypointVelocityFilter = controller.s.keypointVelocityFilter;
125 
126  configData.isRigid = controller.s.isRigid;
127  configData.fixedTranslation = controller.s.fixedTranslation;
128  reinitTripleBuffer(configData);
129  ARMARX_INFO << "--------------------------------------- done ---------------------------------------";
130 }
131 
132 std::string NJointKeypointsAdmittanceController::getClassName(const Ice::Current &) const
133 {
134  return "NJointKeypointsAdmittanceController";
135 }
136 
138 {
139  return kinematicChainName;
140 }
141 
143 {
144  runTask("NJointTaskspaceAdmittanceAdditionalTask", [&]
145  {
146  CycleUtil c(1);
147  getObjectScheduler()->waitForObjectStateMinimum(eManagedIceObjectStarted);
148  ARMARX_IMPORTANT << "Create a new thread alone NJointKeypointsAdmittanceController";
149  while (getState() == eManagedIceObjectStarted)
150  {
151  if (isControllerActive() and rtReady.load())
152  {
153  additionalTask();
154  }
155  c.waitForCycleDuration();
156  }
157  });
158 }
159 
160 void NJointKeypointsAdmittanceController::rtRun(const IceUtil::Time& /*sensorValuesTimestamp*/, const IceUtil::Time& timeSinceLastIteration)
161 {
163  bool valid = controller.updateControlStatus(
165  timeSinceLastIteration,
169 
170  if (rtFirstRun.load())
171  {
172  rtFirstRun.store(false);
173  rtReady.store(false);
174  ftsensor.reset();
175  controller.firstRun();
176  }
177  else
178  {
179  ftsensor.compensateTCPGravity(ftSensorBuffer.getReadBuffer());
180  if (!rtReady.load())
181  {
182  if(ftsensor.calibrate(controller.s.deltaT))
183  {
184  rtReady.store(true);
185  }
186  }
187  else
188  {
189  if (valid)
190  {
191  controller.s.currentForceTorque = ftsensor.getFilteredForceTorque(ftSensorBuffer.getReadBuffer());
192  }
193  }
194  }
195 
196  controller.run(rtReady.load(), targets);
197 
198 
199  /// for debug output
200  {
201  controlStatusBuffer.getWriteBuffer().currentPose = controller.s.currentPose;
202  controlStatusBuffer.getWriteBuffer().currentTwist = controller.s.currentTwist * 1000.0f;
203  controlStatusBuffer.getWriteBuffer().deltaT = controller.s.deltaT;
204 
205  controlStatusBuffer.getWriteBuffer().kpImpedance = controller.s.kpImpedance;
206  controlStatusBuffer.getWriteBuffer().kdImpedance = controller.s.kdImpedance;
207  controlStatusBuffer.getWriteBuffer().forceImpedance = controller.s.forceImpedance;
208  controlStatusBuffer.getWriteBuffer().currentForceTorque = controller.s.currentForceTorque;
209  controlStatusBuffer.getWriteBuffer().pointTrackingForce = controller.s.pointTrackingForce;
210 
211  controlStatusBuffer.getWriteBuffer().virtualPose = controller.s.virtualPose;
212  controlStatusBuffer.getWriteBuffer().virtualVel = controller.s.virtualVel;
213  controlStatusBuffer.getWriteBuffer().virtualAcc = controller.s.virtualAcc;
214 
215  controlStatusBuffer.getWriteBuffer().desiredPose = controller.s.desiredPose;
216  controlStatusBuffer.getWriteBuffer().desiredVel = controller.s.desiredVel;
217  controlStatusBuffer.getWriteBuffer().desiredAcc = controller.s.desiredAcc;
218 
219  controlStatusBuffer.getWriteBuffer().desiredKeypointPosition = controller.s.desiredKeypointPosition;
220  controlStatusBuffer.getWriteBuffer().currentKeypointPosition = controller.s.currentKeypointPosition;
221  controlStatusBuffer.getWriteBuffer().currentKeypointVelocity = controller.s.currentKeypointVelocity;
222  controlStatusBuffer.getWriteBuffer().filteredKeypointPosition = controller.s.filteredKeypointPosition;
223 
224  controlStatusBuffer.getWriteBuffer().desiredJointTorques = controller.s.desiredJointTorques;
226  }
227 }
228 
230 {
231  StringVariantBaseMap datafields;
232  auto values = controlStatusBuffer.getUpToDateReadBuffer().desiredJointTorques;
233  for (int i = 0; i < values.size(); i++)
234  {
235  datafields["torque_"+std::to_string(i)] = new Variant(values(i));
236  }
237 
238  int dim = 3 * controlStatusBuffer.getUpToDateReadBuffer().numPoints;
239 
240  Eigen::Matrix4f virtualPose = controlStatusBuffer.getUpToDateReadBuffer().virtualPose;
241  Eigen::Vector3f rpy = VirtualRobot::MathTools::eigen4f2rpy(virtualPose);
242  datafields["virtualPose_x"] = new Variant(virtualPose(0, 3));
243  datafields["virtualPose_y"] = new Variant(virtualPose(1, 3));
244  datafields["virtualPose_z"] = new Variant(virtualPose(2, 3));
245  datafields["virtualPose_rx"] = new Variant(rpy(0));
246  datafields["virtualPose_ry"] = new Variant(rpy(1));
247  datafields["virtualPose_rz"] = new Variant(rpy(2));
248 
249  Eigen::Matrix4f desiredPose = controlStatusBuffer.getUpToDateReadBuffer().desiredPose;
250  Eigen::Vector3f rpyDesired = VirtualRobot::MathTools::eigen4f2rpy(desiredPose);
251  datafields["desiredPose_x"] = new Variant(desiredPose(0, 3));
252  datafields["desiredPose_y"] = new Variant(desiredPose(1, 3));
253  datafields["desiredPose_z"] = new Variant(desiredPose(2, 3));
254  datafields["desiredPose_rx"] = new Variant(rpyDesired(0));
255  datafields["desiredPose_ry"] = new Variant(rpyDesired(1));
256  datafields["desiredPose_rz"] = new Variant(rpyDesired(2));
257 
258  datafields["virtualVel_x"] = new Variant(controlStatusBuffer.getUpToDateReadBuffer().virtualVel(0));
259  datafields["virtualVel_y"] = new Variant(controlStatusBuffer.getUpToDateReadBuffer().virtualVel(1));
260  datafields["virtualVel_z"] = new Variant(controlStatusBuffer.getUpToDateReadBuffer().virtualVel(2));
261  datafields["virtualVel_rx"] = new Variant(controlStatusBuffer.getUpToDateReadBuffer().virtualVel(3));
262  datafields["virtualVel_ry"] = new Variant(controlStatusBuffer.getUpToDateReadBuffer().virtualVel(4));
263  datafields["virtualVel_rz"] = new Variant(controlStatusBuffer.getUpToDateReadBuffer().virtualVel(5));
264 
265  datafields["virtualAcc_x"] = new Variant(controlStatusBuffer.getUpToDateReadBuffer().virtualAcc(0));
266  datafields["virtualAcc_y"] = new Variant(controlStatusBuffer.getUpToDateReadBuffer().virtualAcc(1));
267  datafields["virtualAcc_z"] = new Variant(controlStatusBuffer.getUpToDateReadBuffer().virtualAcc(2));
268  datafields["virtualAcc_rx"] = new Variant(controlStatusBuffer.getUpToDateReadBuffer().virtualAcc(3));
269  datafields["virtualAcc_ry"] = new Variant(controlStatusBuffer.getUpToDateReadBuffer().virtualAcc(4));
270  datafields["virtualAcc_rz"] = new Variant(controlStatusBuffer.getUpToDateReadBuffer().virtualAcc(5));
271 
272  datafields["desiredTwist_x"] = new Variant(controlStatusBuffer.getUpToDateReadBuffer().desiredVel(0));
273  datafields["desiredTwist_y"] = new Variant(controlStatusBuffer.getUpToDateReadBuffer().desiredVel(1));
274  datafields["desiredTwist_z"] = new Variant(controlStatusBuffer.getUpToDateReadBuffer().desiredVel(2));
275  datafields["desiredTwist_rx"] = new Variant(controlStatusBuffer.getUpToDateReadBuffer().desiredVel(3));
276  datafields["desiredTwist_ry"] = new Variant(controlStatusBuffer.getUpToDateReadBuffer().desiredVel(4));
277  datafields["desiredTwist_rz"] = new Variant(controlStatusBuffer.getUpToDateReadBuffer().desiredVel(5));
278 
279  datafields["desiredAcc_x"] = new Variant(controlStatusBuffer.getUpToDateReadBuffer().desiredAcc(0));
280  datafields["desiredAcc_y"] = new Variant(controlStatusBuffer.getUpToDateReadBuffer().desiredAcc(1));
281  datafields["desiredAcc_z"] = new Variant(controlStatusBuffer.getUpToDateReadBuffer().desiredAcc(2));
282  datafields["desiredAcc_rx"] = new Variant(controlStatusBuffer.getUpToDateReadBuffer().desiredAcc(3));
283  datafields["desiredAcc_ry"] = new Variant(controlStatusBuffer.getUpToDateReadBuffer().desiredAcc(4));
284  datafields["desiredAcc_rz"] = new Variant(controlStatusBuffer.getUpToDateReadBuffer().desiredAcc(5));
285 
286  datafields["kpImpedance_x"] = new Variant(controlStatusBuffer.getUpToDateReadBuffer().kpImpedance(0));
287  datafields["kpImpedance_y"] = new Variant(controlStatusBuffer.getUpToDateReadBuffer().kpImpedance(1));
288  datafields["kpImpedance_z"] = new Variant(controlStatusBuffer.getUpToDateReadBuffer().kpImpedance(2));
289  datafields["kpImpedance_rx"] = new Variant(controlStatusBuffer.getUpToDateReadBuffer().kpImpedance(3));
290  datafields["kpImpedance_ry"] = new Variant(controlStatusBuffer.getUpToDateReadBuffer().kpImpedance(4));
291  datafields["kpImpedance_rz"] = new Variant(controlStatusBuffer.getUpToDateReadBuffer().kpImpedance(5));
292 
293  datafields["kdImpedance_x"] = new Variant(controlStatusBuffer.getUpToDateReadBuffer().kdImpedance(0));
294  datafields["kdImpedance_y"] = new Variant(controlStatusBuffer.getUpToDateReadBuffer().kdImpedance(1));
295  datafields["kdImpedance_z"] = new Variant(controlStatusBuffer.getUpToDateReadBuffer().kdImpedance(2));
296  datafields["kdImpedance_rx"] = new Variant(controlStatusBuffer.getUpToDateReadBuffer().kdImpedance(3));
297  datafields["kdImpedance_ry"] = new Variant(controlStatusBuffer.getUpToDateReadBuffer().kdImpedance(4));
298  datafields["kdImpedance_rz"] = new Variant(controlStatusBuffer.getUpToDateReadBuffer().kdImpedance(5));
299 
300  datafields["forceImpedance_x"] = new Variant(controlStatusBuffer.getUpToDateReadBuffer().forceImpedance(0));
301  datafields["forceImpedance_y"] = new Variant(controlStatusBuffer.getUpToDateReadBuffer().forceImpedance(1));
302  datafields["forceImpedance_z"] = new Variant(controlStatusBuffer.getUpToDateReadBuffer().forceImpedance(2));
303  datafields["forceImpedance_rx"] = new Variant(controlStatusBuffer.getUpToDateReadBuffer().forceImpedance(3));
304  datafields["forceImpedance_ry"] = new Variant(controlStatusBuffer.getUpToDateReadBuffer().forceImpedance(4));
305  datafields["forceImpedance_rz"] = new Variant(controlStatusBuffer.getUpToDateReadBuffer().forceImpedance(5));
306 
307  datafields["currentForceTorque_x"] = new Variant(controlStatusBuffer.getUpToDateReadBuffer().currentForceTorque(0));
308  datafields["currentForceTorque_y"] = new Variant(controlStatusBuffer.getUpToDateReadBuffer().currentForceTorque(1));
309  datafields["currentForceTorque_z"] = new Variant(controlStatusBuffer.getUpToDateReadBuffer().currentForceTorque(2));
310  datafields["currentForceTorque_rx"] = new Variant(controlStatusBuffer.getUpToDateReadBuffer().currentForceTorque(3));
311  datafields["currentForceTorque_ry"] = new Variant(controlStatusBuffer.getUpToDateReadBuffer().currentForceTorque(4));
312  datafields["currentForceTorque_rz"] = new Variant(controlStatusBuffer.getUpToDateReadBuffer().currentForceTorque(5));
313 
314  datafields["pointTrackingForce_x"] = new Variant(controlStatusBuffer.getUpToDateReadBuffer().pointTrackingForce(0));
315  datafields["pointTrackingForce_y"] = new Variant(controlStatusBuffer.getUpToDateReadBuffer().pointTrackingForce(1));
316  datafields["pointTrackingForce_z"] = new Variant(controlStatusBuffer.getUpToDateReadBuffer().pointTrackingForce(2));
317  datafields["pointTrackingForce_rx"] = new Variant(controlStatusBuffer.getUpToDateReadBuffer().pointTrackingForce(3));
318  datafields["pointTrackingForce_ry"] = new Variant(controlStatusBuffer.getUpToDateReadBuffer().pointTrackingForce(4));
319  datafields["pointTrackingForce_rz"] = new Variant(controlStatusBuffer.getUpToDateReadBuffer().pointTrackingForce(5));
320 
321  for (int i = 0; i < dim; i++)
322  {
323  datafields["desiredKeypointPosition_"+std::to_string(i)] = new Variant(controlStatusBuffer.getUpToDateReadBuffer().desiredKeypointPosition(i));
324  datafields["currentKeypointPosition_"+std::to_string(i)] = new Variant(controlStatusBuffer.getUpToDateReadBuffer().currentKeypointPosition(i));
325  datafields["currentKeypointVelocity_"+std::to_string(i)] = new Variant(controlStatusBuffer.getUpToDateReadBuffer().currentKeypointVelocity(i));
326  datafields["filteredKeypointPosition_"+std::to_string(i)] = new Variant(controlStatusBuffer.getUpToDateReadBuffer().filteredKeypointPosition(i));
327  }
328  debugObs->setDebugChannel("NJointKeypointsAdmittanceController", datafields);
329 }
330 
331 void NJointKeypointsAdmittanceController::reconfigureController(const std::string& filename, const Ice::Current &)
332 {
333  law::KeypointsAdmittanceController::Config config = controller.reconfigure(filename);
334  reinitTripleBuffer(config);
335 
336  common::FTSensor::FTBufferData ftConfig = ftsensor.reconfigure(filename);
338 }
339 
340 void NJointKeypointsAdmittanceController::setKeypointsParameters(const std::string& name, const Eigen::VectorXf& value, const Ice::Current &)
341 {
343  if (name == "target")
344  {
345  ARMARX_CHECK_EQUAL(value.size(), controller.s.numPoints);
346  getWriterControlStruct().desiredKeypointPosition = value;
347  }
348  else if (name == "current")
349  {
350  ARMARX_CHECK_EQUAL(value.size(), controller.s.numPoints);
351  getWriterControlStruct().currentKeypointPosition = value;
352  }
353  else if (name == "kp")
354  {
355  ARMARX_CHECK_EQUAL(value.size(), controller.s.numPoints);
356  getWriterControlStruct().keypointKp = value;
357  }
358  else if (name == "kd")
359  {
360  ARMARX_CHECK_EQUAL(value.size(), controller.s.numPoints);
361  getWriterControlStruct().keypointKd = value;
362  }
363  else if (name == "translation")
364  {
365  ARMARX_CHECK_EQUAL(value.size(), controller.s.numPoints);
366  getWriterControlStruct().fixedTranslation = value;
367  }
368 }
369 
370 void NJointKeypointsAdmittanceController::setControlParameters(const std::string& name, const Eigen::VectorXf& value, const Ice::Current &)
371 {
373  if (name == "impedance_stiffness")
374  {
375  ARMARX_CHECK_EQUAL(value.size(), 6);
376  getWriterControlStruct().kpImpedance = value;
377  }
378  else if (name == "impedance_damping")
379  {
380  ARMARX_CHECK_EQUAL(value.size(), 6);
381  getWriterControlStruct().kdImpedance = value;
382  }
383  else if (name == "admittance_stiffness")
384  {
385  ARMARX_CHECK_EQUAL(value.size(), 6);
386  getWriterControlStruct().kpAdmittance = value;
387  }
388  else if (name == "admittance_damping")
389  {
390  ARMARX_CHECK_EQUAL(value.size(), 6);
391  getWriterControlStruct().kdAdmittance = value;
392  }
393  else if (name == "admittance_inertia")
394  {
395  ARMARX_CHECK_EQUAL(value.size(), 6);
396  getWriterControlStruct().kmAdmittance = value;
397  }
398  else if (name == "nullspace_stiffness")
399  {
400  ARMARX_CHECK_EQUAL((unsigned)value.size(), targets.size());
401  getWriterControlStruct().kpNullspace = value;
402  }
403  else if (name == "nullspace_damping")
404  {
405  ARMARX_CHECK_EQUAL((unsigned)value.size(), targets.size());
406  getWriterControlStruct().kdNullspace = value;
407  }
408  else if (name == "desired_nullspace_joint_angles")
409  {
410  ARMARX_CHECK_EQUAL((unsigned)value.size(), targets.size());
411  getWriterControlStruct().desiredNullspaceJointAngles = value;
412  }
413  else
414  {
415  ARMARX_ERROR << name << " is not supported by TaskSpaceAdmittanceController";
416  }
418 }
419 
420 void NJointKeypointsAdmittanceController::setForceTorqueBaseline(const Eigen::Vector3f& forceBaseline, const Eigen::Vector3f& torqueBaseline, const Ice::Current &)
421 {
422  ftSensorBuffer.getWriteBuffer().forceBaseline = forceBaseline;
423  ftSensorBuffer.getWriteBuffer().torqueBaseline = torqueBaseline;
425 }
426 
428 {
429  ftSensorBuffer.getWriteBuffer().enableTCPGravityCompensation = true;
430  ftSensorBuffer.getWriteBuffer().tcpMass = mass;
432 }
433 
434 void NJointKeypointsAdmittanceController::setTCPCoMInFTFrame(const Eigen::Vector3f& tcpCoMInFTSensorFrame, const Ice::Current &)
435 {
436  ftSensorBuffer.getWriteBuffer().enableTCPGravityCompensation = true;
437  ftSensorBuffer.getWriteBuffer().tcpCoMInFTSensorFrame = tcpCoMInFTSensorFrame;
439 }
440 
442 {
443  rtReady.store(false);
444 }
445 
446 void NJointKeypointsAdmittanceController::toggleGravityCompensation(const bool toggle, const Ice::Current &)
447 {
448  ftSensorBuffer.getWriteBuffer().enableTCPGravityCompensation = toggle;
450  rtReady.store(false); /// you also need to re-calibrate ft sensor
451 }
452 
454 {
455  VirtualRobot::RobotNodeSetPtr rns = rtGetRobot()->getRobotNodeSet(kinematicChainName);
456  Eigen::Matrix4f currentPose = rns->getTCP()->getPoseInRootFrame();
457  ARMARX_IMPORTANT << "rt preactivate controller with target pose\n\n" << currentPose;
458  controller.preactivateInit(rns);
459  getWriterControlStruct().desiredNullspaceJointAngles = controller.s.desiredNullspaceJointAngles;
461 
463 }
464 } /// namespace armarx::control::njoint_controller::task_space
armarx::NJointControllerWithTripleBuffer< law::KeypointsAdmittanceController::Config >::reinitTripleBuffer
void reinitTripleBuffer(const law::KeypointsAdmittanceController::Config &initial)
Definition: NJointControllerWithTripleBuffer.h:68
armarx::control::njoint_controller::task_space::NJointKeypointsAdmittanceController::setKeypointsParameters
void setKeypointsParameters(const std::string &name, const Eigen::VectorXf &value, const Ice::Current &) override
Definition: KeypointsAdmittanceController.cpp:340
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::VariantType::Float
const VariantTypeId Float
Definition: Variant.h:918
armarx::TripleBuffer::getWriteBuffer
T & getWriteBuffer()
Definition: TripleBuffer.h:90
armarx::NJointControllerBase::useSynchronizedRtRobot
const VirtualRobot::RobotPtr & useSynchronizedRtRobot(bool updateCollisionModel=false)
Requests a VirtualRobot for use in rtRun *.
Definition: NJointController.cpp:293
armarx::NJointControllerWithTripleBuffer< law::KeypointsAdmittanceController::Config >::rtGetControlStruct
const law::KeypointsAdmittanceController::Config & rtGetControlStruct() const
Definition: NJointControllerWithTripleBuffer.h:32
armarx::StringVariantBaseMap
std::map< std::string, VariantBasePtr > StringVariantBaseMap
Definition: ManagedIceObject.h:111
armarx::control::njoint_controller::task_space::NJointKeypointsAdmittanceController::setTCPMass
void setTCPMass(Ice::Float, const Ice::Current &) override
Definition: KeypointsAdmittanceController.cpp:427
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::control::njoint_controller::task_space::NJointKeypointsAdmittanceController::additionalTask
virtual void additionalTask()
Definition: KeypointsAdmittanceController.h:80
armarx::ControlTargetBase
Brief description of class JointControlTargetBase.
Definition: ControlTargetBase.h:47
armarx::TripleBuffer::commitWrite
void commitWrite()
Definition: TripleBuffer.h:146
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::control::njoint_controller::task_space
Definition: AdmittanceController.cpp:37
armarx::CycleUtil
This util class helps with keeping a cycle time during a control cycle.
Definition: CycleUtil.h:40
armarx::ManagedIceObject::getState
int getState() const
Retrieve current state of the ManagedIceObject.
Definition: ManagedIceObject.cpp:725
ProsthesisInterface.values
values
Definition: ProsthesisInterface.py:190
armarx::control::njoint_controller::task_space::NJointKeypointsAdmittanceController::ftsensor
common::FTSensor ftsensor
Definition: KeypointsAdmittanceController.h:96
armarx::control::njoint_controller::task_space::NJointKeypointsAdmittanceController::rtPreActivateController
void rtPreActivateController() override
This function is called before the controller is activated.
Definition: KeypointsAdmittanceController.cpp:453
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:43
armarx::NJointControllerBase::ConfigPtrT
NJointControllerConfigPtr ConfigPtrT
Definition: NJointControllerBase.h:586
armarx::NJointControllerWithTripleBuffer< law::KeypointsAdmittanceController::Config >::getWriterControlStruct
law::KeypointsAdmittanceController::Config & getWriterControlStruct()
Definition: NJointControllerWithTripleBuffer.h:54
armarx::control::njoint_controller::task_space::NJointKeypointsAdmittanceController::reconfigureController
void reconfigureController(const std::string &filename, const Ice::Current &iceCurrent=Ice::emptyCurrent) override
set control target
Definition: KeypointsAdmittanceController.cpp:331
armarx::NJointControllerWithTripleBuffer< law::KeypointsAdmittanceController::Config >::LockGuardType
std::lock_guard< std::recursive_mutex > LockGuardType
Definition: NJointControllerWithTripleBuffer.h:14
armarx::control::njoint_controller::task_space::NJointKeypointsAdmittanceController::toggleGravityCompensation
void toggleGravityCompensation(const bool toggle, const Ice::Current &) override
Definition: KeypointsAdmittanceController.cpp:446
armarx::control::njoint_controller::task_space::registrationControllerNJointKeypointsAdmittanceController
NJointControllerRegistration< NJointKeypointsAdmittanceController > registrationControllerNJointKeypointsAdmittanceController("NJointKeypointsAdmittanceController")
armarx::control::njoint_controller::task_space::NJointKeypointsAdmittanceController::jointNames
std::vector< std::string > jointNames
Definition: KeypointsAdmittanceController.h:94
armarx::control::njoint_controller::task_space::NJointKeypointsAdmittanceController::onInitNJointController
void onInitNJointController() override
Definition: KeypointsAdmittanceController.cpp:142
armarx::control::njoint_controller::task_space::NJointKeypointsAdmittanceController::setForceTorqueBaseline
void setForceTorqueBaseline(const Eigen::Vector3f &, const Eigen::Vector3f &, const Ice::Current &) override
ft sensor
Definition: KeypointsAdmittanceController.cpp:420
armarx::NJointControllerBase::rtGetRobot
const VirtualRobot::RobotPtr & rtGetRobot()
TODO make protected and use attorneys.
Definition: NJointControllerBase.h:845
armarx::detail::ControlThreadOutputBufferEntry
Definition: ControlThreadOutputBuffer.h:177
cxxopts::value
std::shared_ptr< Value > value()
Definition: cxxopts.hpp:926
controller
Definition: AddOperation.h:39
armarx::control::njoint_controller::task_space::NJointKeypointsAdmittanceController::calibrateFTSensor
void calibrateFTSensor(const Ice::Current &) override
Definition: KeypointsAdmittanceController.cpp:441
armarx::control::njoint_controller::task_space::NJointKeypointsAdmittanceController::getKinematicChainName
std::string getKinematicChainName(const Ice::Current &) override
Definition: KeypointsAdmittanceController.cpp:137
armarx::control::njoint_controller::task_space::NJointKeypointsAdmittanceController::torqueSensors
std::vector< const SensorValue1DoFActuatorTorque * > torqueSensors
devices
Definition: KeypointsAdmittanceController.h:85
armarx::control::njoint_controller::task_space::NJointKeypointsAdmittanceController::onPublish
void onPublish(const SensorAndControl &, const DebugDrawerInterfacePrx &, const DebugObserverInterfacePrx &) override
Definition: KeypointsAdmittanceController.cpp:229
armarx::control::njoint_controller::task_space::NJointKeypointsAdmittanceController::getClassName
std::string getClassName(const Ice::Current &) const override
Definition: KeypointsAdmittanceController.cpp:132
armarx::NJointControllerBase::isControllerActive
bool isControllerActive(const Ice::Current &=Ice::emptyCurrent) const final override
Definition: NJointControllerBase.h:777
armarx::NJointControllerBase::runTask
void runTask(const std::string &taskName, Task &&task)
Executes a given task in a separate thread from the Application ThreadPool.
Definition: NJointControllerBase.h:753
armarx::NJointControllerWithTripleBuffer< law::KeypointsAdmittanceController::Config >::rtUpdateControlStruct
bool rtUpdateControlStruct()
Definition: NJointControllerWithTripleBuffer.h:38
armarx::control::njoint_controller::task_space::NJointKeypointsAdmittanceController::configFileName
std::string configFileName
variables
Definition: KeypointsAdmittanceController.h:93
armarx::NJointControllerWithTripleBuffer< law::KeypointsAdmittanceController::Config >::writeControlStruct
void writeControlStruct()
Definition: NJointControllerWithTripleBuffer.h:44
armarx::TripleBuffer::getReadBuffer
const T & getReadBuffer() const
Definition: TripleBuffer.h:102
filename
std::string filename
Definition: VisualizationRobot.cpp:83
ArmarXObjectScheduler.h
armarx::control::njoint_controller::task_space::NJointKeypointsAdmittanceController::ftSensorBuffer
TripleBuffer< common::FTSensor::FTBufferData > ftSensorBuffer
Definition: KeypointsAdmittanceController.h:100
armarx::control::njoint_controller::task_space::NJointKeypointsAdmittanceController::NJointKeypointsAdmittanceController
NJointKeypointsAdmittanceController(const RobotUnitPtr &robotUnit, const NJointControllerConfigPtr &config, const VirtualRobot::RobotPtr &)
Definition: KeypointsAdmittanceController.cpp:34
armarx::NJointControllerWithTripleBuffer< law::KeypointsAdmittanceController::Config >::controlDataMutex
MutexType controlDataMutex
Definition: NJointControllerWithTripleBuffer.h:73
ARMARX_ERROR
#define ARMARX_ERROR
Definition: Logging.h:189
armarx::armem::Time
armarx::core::time::DateTime Time
Definition: forward_declarations.h:13
armarx::control::njoint_controller::task_space::NJointKeypointsAdmittanceController::kinematicChainName
std::string kinematicChainName
Definition: KeypointsAdmittanceController.h:103
armarx::to_string
const std::string & to_string(const std::string &s)
Definition: StringHelpers.h:40
CycleUtil.h
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
KeypointsAdmittanceController.h
ARMARX_INFO
#define ARMARX_INFO
Definition: Logging.h:174
armarx::control::njoint_controller::task_space::NJointKeypointsAdmittanceController::rtRun
void rtRun(const IceUtil::Time &sensorValuesTimestamp, const IceUtil::Time &timeSinceLastIteration) override
TODO make protected and use attorneys.
Definition: KeypointsAdmittanceController.cpp:160
armarx::control::njoint_controller::task_space::NJointKeypointsAdmittanceController::velocitySensors
std::vector< const SensorValue1DoFActuatorVelocity * > velocitySensors
Definition: KeypointsAdmittanceController.h:86
armarx::control::njoint_controller::task_space::NJointKeypointsAdmittanceController::setTCPCoMInFTFrame
void setTCPCoMInFTFrame(const Eigen::Vector3f &, const Ice::Current &) override
Definition: KeypointsAdmittanceController.cpp:434
armarx::control::njoint_controller::task_space::NJointKeypointsAdmittanceController::controlStatusBuffer
TripleBuffer< law::KeypointsAdmittanceController::Status > controlStatusBuffer
set buffers
Definition: KeypointsAdmittanceController.h:99
IceInternal::ProxyHandle<::IceProxy::armarx::DebugDrawerInterface >
armarx::control::njoint_controller::task_space::NJointKeypointsAdmittanceController::positionSensors
std::vector< const SensorValue1DoFActuatorPosition * > positionSensors
Definition: KeypointsAdmittanceController.h:87
armarx::control::njoint_controller::task_space::NJointKeypointsAdmittanceController::setControlParameters
void setControlParameters(const std::string &, const Eigen::VectorXf &, const Ice::Current &) override
Definition: KeypointsAdmittanceController.cpp:370
armarx::control::njoint_controller::task_space::NJointKeypointsAdmittanceController::targets
std::vector< ControlTarget1DoFActuatorTorque * > targets
Definition: KeypointsAdmittanceController.h:88
armarx::control::njoint_controller::task_space::NJointKeypointsAdmittanceController::rtFirstRun
std::atomic_bool rtFirstRun
Definition: KeypointsAdmittanceController.h:102
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_WARNING
#define ARMARX_WARNING
Definition: Logging.h:186
armarx::control::njoint_controller::task_space::NJointKeypointsAdmittanceController::rtReady
std::atomic_bool rtReady
Definition: KeypointsAdmittanceController.h:104
armarx::TripleBuffer::reinitAllBuffers
std::enable_if< std::is_copy_constructible< U >::value >::type reinitAllBuffers(const T &init)
Definition: TripleBuffer.h:153
armarx::ManagedIceObject::getObjectScheduler
ArmarXObjectSchedulerPtr getObjectScheduler() const
Definition: ManagedIceObject.cpp:731
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