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
24
25#include <VirtualRobot/MathTools.h>
26#include <VirtualRobot/RobotNodeSet.h>
27
30
35
37{
38 NJointControllerRegistration<NJointKeypointsAdmittanceController>
40 "NJointKeypointsAdmittanceController");
41
43 const RobotUnitPtr& robotUnit,
44 const NJointControllerConfigPtr& config,
46 {
47 ARMARX_INFO << "--------------------------------------- creating keypoints admittance "
48 "controller ---------------------------------------";
49 ConfigPtrT cfg = ConfigPtrT::dynamicCast(config);
50
52 ARMARX_CHECK_EXPRESSION(robotUnit);
53 ARMARX_CHECK_EXPRESSION(!cfg->nodeSetName.empty());
55 kinematicChainName = cfg->nodeSetName;
56
57 VirtualRobot::RobotNodeSetPtr rns = rtGetRobot()->getRobotNodeSet(cfg->nodeSetName);
58 ARMARX_CHECK_EXPRESSION(rns) << cfg->nodeSetName;
59
60 jointNames.clear();
61 for (size_t i = 0; i < rns->getSize(); ++i)
62 {
63 std::string jointName = rns->getNode(i)->getName();
64 jointNames.push_back(jointName);
65 ControlTargetBase* ct = useControlTarget(jointName, ControlModes::Torque1DoF);
67 const SensorValueBase* sv = useSensorValue(jointName);
69 auto casted_ct = ct->asA<ControlTarget1DoFActuatorTorque>();
70 ARMARX_CHECK_EXPRESSION(casted_ct);
71 targets.push_back(casted_ct);
72
73 const SensorValue1DoFActuatorTorque* torqueSensor =
74 sv->asA<SensorValue1DoFActuatorTorque>();
75 const SensorValue1DoFActuatorVelocity* velocitySensor =
76 sv->asA<SensorValue1DoFActuatorVelocity>();
77 const SensorValue1DoFActuatorPosition* positionSensor =
78 sv->asA<SensorValue1DoFActuatorPosition>();
79 if (!torqueSensor)
80 {
81 ARMARX_WARNING << "No Torque sensor available for " << jointName;
82 }
83 if (!velocitySensor)
84 {
85 ARMARX_WARNING << "No velocity sensor available for " << jointName;
86 }
87 if (!positionSensor)
88 {
89 ARMARX_WARNING << "No position sensor available for " << jointName;
90 }
91
92 torqueSensors.push_back(torqueSensor);
93 velocitySensors.push_back(velocitySensor);
94 positionSensors.push_back(positionSensor);
95 };
96 configFileName = cfg->controlParamJsonFile;
97 controller.initialize(rns, configFileName);
98 ftsensor.initialize(rns, robotUnit, configFileName);
99
100 common::FTSensor::FTBufferData ftData;
101 ftData.ftFilter = ftsensor.s.ftFilter;
102 ftData.deadZoneForce = ftsensor.s.deadZoneForce;
103 ftData.deadZoneTorque = ftsensor.s.deadZoneTorque;
104 ftData.timeLimit = ftsensor.s.timeLimit;
105 ftData.tcpMass = ftsensor.s.tcpMass;
106 ftData.tcpCoMInFTSensorFrame = ftsensor.s.tcpCoMInFTSensorFrame;
107 ftData.enableTCPGravityCompensation = ftsensor.s.enableTCPGravityCompensation;
108 ftData.forceBaseline = ftsensor.s.forceBaseline;
109 ftData.torqueBaseline = ftsensor.s.torqueBaseline;
110 ftSensorBuffer.reinitAllBuffers(ftData);
111
112 law::KeypointsAdmittanceController::Config configData;
113 configData.kpImpedance = controller.s.kpImpedance;
114 configData.kdImpedance = controller.s.kdImpedance;
115 configData.kpAdmittance = controller.s.kpAdmittance;
116 configData.kdAdmittance = controller.s.kdAdmittance;
117 configData.kmAdmittance = controller.s.kmAdmittance;
118
119 configData.kpNullspaceTorque = controller.s.kpNullspaceTorque;
120 configData.kdNullspaceTorque = controller.s.kdNullspaceTorque;
121
122 configData.currentForceTorque.setZero();
123 configData.desiredNullspaceJointAngles = controller.s.desiredNullspaceJointAngles;
124
125 configData.torqueLimit = controller.s.torqueLimit;
126 configData.qvelFilter = controller.s.qvelFilter;
127
128 configData.numPoints = controller.s.numPoints;
129 configData.keypointKp = controller.s.keypointKp;
130 configData.keypointKd = controller.s.keypointKd;
131
132 configData.currentKeypointPosition = controller.s.currentKeypointPosition;
133 configData.desiredKeypointPosition = controller.s.currentKeypointPosition;
134 configData.desiredKeypointVelocity = controller.s.desiredKeypointVelocity;
135 configData.keypointPositionFilter = controller.s.keypointPositionFilter;
136 configData.keypointVelocityFilter = controller.s.keypointVelocityFilter;
137
138 configData.isRigid = controller.s.isRigid;
139 configData.fixedTranslation = controller.s.fixedTranslation;
140 reinitTripleBuffer(configData);
141 ARMARX_INFO << "--------------------------------------- done "
142 "---------------------------------------";
143 }
144
145 std::string
147 {
148 return "NJointKeypointsAdmittanceController";
149 }
150
151 std::string
156
157 void
159 {
160 runTask("NJointTaskspaceAdmittanceAdditionalTask",
161 [&]
162 {
163 CycleUtil c(1);
164 getObjectScheduler()->waitForObjectStateMinimum(eManagedIceObjectStarted);
166 << "Create a new thread alone NJointKeypointsAdmittanceController";
167 while (getState() == eManagedIceObjectStarted)
168 {
169 if (isControllerActive() and rtReady.load())
170 {
172 }
173 c.waitForCycleDuration();
174 }
175 });
176 }
177
178 void
179 NJointKeypointsAdmittanceController::rtRun(const IceUtil::Time& /*sensorValuesTimestamp*/,
180 const IceUtil::Time& timeSinceLastIteration)
181 {
183 bool valid = controller.updateControlStatus(rtGetControlStruct(),
184 timeSinceLastIteration,
188
189 if (rtFirstRun.load())
190 {
191 rtFirstRun.store(false);
192 rtReady.store(false);
193 ftsensor.reset();
194 controller.firstRun();
195 }
196 else
197 {
198 ftsensor.compensateTCPGravity(ftSensorBuffer.getReadBuffer());
199 if (!rtReady.load())
200 {
201 if (ftsensor.calibrate(controller.s.deltaT))
202 {
203 rtReady.store(true);
204 }
205 }
206 else
207 {
208 if (valid)
209 {
210 controller.s.currentForceTorque =
211 ftsensor.getFilteredForceTorque(ftSensorBuffer.getReadBuffer());
212 }
213 }
214 }
215
216 controller.run(rtReady.load(), targets);
217
218
219 /// for debug output
220 {
221 controlStatusBuffer.getWriteBuffer().currentPose = controller.s.currentPose;
222 controlStatusBuffer.getWriteBuffer().currentTwist = controller.s.currentTwist * 1000.0f;
223 controlStatusBuffer.getWriteBuffer().deltaT = controller.s.deltaT;
224
225 controlStatusBuffer.getWriteBuffer().kpImpedance = controller.s.kpImpedance;
226 controlStatusBuffer.getWriteBuffer().kdImpedance = controller.s.kdImpedance;
227 controlStatusBuffer.getWriteBuffer().forceImpedance = controller.s.forceImpedance;
228 controlStatusBuffer.getWriteBuffer().currentForceTorque =
229 controller.s.currentForceTorque;
230 controlStatusBuffer.getWriteBuffer().pointTrackingForce =
231 controller.s.pointTrackingForce;
232
233 controlStatusBuffer.getWriteBuffer().virtualPose = controller.s.virtualPose;
234 controlStatusBuffer.getWriteBuffer().virtualVel = controller.s.virtualVel;
235 controlStatusBuffer.getWriteBuffer().virtualAcc = controller.s.virtualAcc;
236
237 controlStatusBuffer.getWriteBuffer().desiredPose = controller.s.desiredPose;
238 controlStatusBuffer.getWriteBuffer().desiredVel = controller.s.desiredVel;
239 controlStatusBuffer.getWriteBuffer().desiredAcc = controller.s.desiredAcc;
240
241 controlStatusBuffer.getWriteBuffer().desiredKeypointPosition =
242 controller.s.desiredKeypointPosition;
243 controlStatusBuffer.getWriteBuffer().currentKeypointPosition =
244 controller.s.currentKeypointPosition;
245 controlStatusBuffer.getWriteBuffer().currentKeypointVelocity =
246 controller.s.currentKeypointVelocity;
247 controlStatusBuffer.getWriteBuffer().filteredKeypointPosition =
248 controller.s.filteredKeypointPosition;
249
250 controlStatusBuffer.getWriteBuffer().desiredJointTorques =
251 controller.s.desiredJointTorques;
252 controlStatusBuffer.commitWrite();
253 }
254 }
255
256 void
259 const DebugObserverInterfacePrx& debugObs)
260 {
261 StringVariantBaseMap datafields;
262 auto values = controlStatusBuffer.getUpToDateReadBuffer().desiredJointTorques;
263 for (int i = 0; i < values.size(); i++)
264 {
265 datafields["torque_" + std::to_string(i)] = new Variant(values(i));
266 }
267
268 int dim = 3 * controlStatusBuffer.getUpToDateReadBuffer().numPoints;
269
270 Eigen::Matrix4f virtualPose = controlStatusBuffer.getUpToDateReadBuffer().virtualPose;
271 Eigen::Vector3f rpy = VirtualRobot::MathTools::eigen4f2rpy(virtualPose);
272 datafields["virtualPose_x"] = new Variant(virtualPose(0, 3));
273 datafields["virtualPose_y"] = new Variant(virtualPose(1, 3));
274 datafields["virtualPose_z"] = new Variant(virtualPose(2, 3));
275 datafields["virtualPose_rx"] = new Variant(rpy(0));
276 datafields["virtualPose_ry"] = new Variant(rpy(1));
277 datafields["virtualPose_rz"] = new Variant(rpy(2));
278
279 Eigen::Matrix4f desiredPose = controlStatusBuffer.getUpToDateReadBuffer().desiredPose;
280 Eigen::Vector3f rpyDesired = VirtualRobot::MathTools::eigen4f2rpy(desiredPose);
281 datafields["desiredPose_x"] = new Variant(desiredPose(0, 3));
282 datafields["desiredPose_y"] = new Variant(desiredPose(1, 3));
283 datafields["desiredPose_z"] = new Variant(desiredPose(2, 3));
284 datafields["desiredPose_rx"] = new Variant(rpyDesired(0));
285 datafields["desiredPose_ry"] = new Variant(rpyDesired(1));
286 datafields["desiredPose_rz"] = new Variant(rpyDesired(2));
287
288 datafields["virtualVel_x"] =
289 new Variant(controlStatusBuffer.getUpToDateReadBuffer().virtualVel(0));
290 datafields["virtualVel_y"] =
291 new Variant(controlStatusBuffer.getUpToDateReadBuffer().virtualVel(1));
292 datafields["virtualVel_z"] =
293 new Variant(controlStatusBuffer.getUpToDateReadBuffer().virtualVel(2));
294 datafields["virtualVel_rx"] =
295 new Variant(controlStatusBuffer.getUpToDateReadBuffer().virtualVel(3));
296 datafields["virtualVel_ry"] =
297 new Variant(controlStatusBuffer.getUpToDateReadBuffer().virtualVel(4));
298 datafields["virtualVel_rz"] =
299 new Variant(controlStatusBuffer.getUpToDateReadBuffer().virtualVel(5));
300
301 datafields["virtualAcc_x"] =
302 new Variant(controlStatusBuffer.getUpToDateReadBuffer().virtualAcc(0));
303 datafields["virtualAcc_y"] =
304 new Variant(controlStatusBuffer.getUpToDateReadBuffer().virtualAcc(1));
305 datafields["virtualAcc_z"] =
306 new Variant(controlStatusBuffer.getUpToDateReadBuffer().virtualAcc(2));
307 datafields["virtualAcc_rx"] =
308 new Variant(controlStatusBuffer.getUpToDateReadBuffer().virtualAcc(3));
309 datafields["virtualAcc_ry"] =
310 new Variant(controlStatusBuffer.getUpToDateReadBuffer().virtualAcc(4));
311 datafields["virtualAcc_rz"] =
312 new Variant(controlStatusBuffer.getUpToDateReadBuffer().virtualAcc(5));
313
314 datafields["desiredTwist_x"] =
315 new Variant(controlStatusBuffer.getUpToDateReadBuffer().desiredVel(0));
316 datafields["desiredTwist_y"] =
317 new Variant(controlStatusBuffer.getUpToDateReadBuffer().desiredVel(1));
318 datafields["desiredTwist_z"] =
319 new Variant(controlStatusBuffer.getUpToDateReadBuffer().desiredVel(2));
320 datafields["desiredTwist_rx"] =
321 new Variant(controlStatusBuffer.getUpToDateReadBuffer().desiredVel(3));
322 datafields["desiredTwist_ry"] =
323 new Variant(controlStatusBuffer.getUpToDateReadBuffer().desiredVel(4));
324 datafields["desiredTwist_rz"] =
325 new Variant(controlStatusBuffer.getUpToDateReadBuffer().desiredVel(5));
326
327 datafields["desiredAcc_x"] =
328 new Variant(controlStatusBuffer.getUpToDateReadBuffer().desiredAcc(0));
329 datafields["desiredAcc_y"] =
330 new Variant(controlStatusBuffer.getUpToDateReadBuffer().desiredAcc(1));
331 datafields["desiredAcc_z"] =
332 new Variant(controlStatusBuffer.getUpToDateReadBuffer().desiredAcc(2));
333 datafields["desiredAcc_rx"] =
334 new Variant(controlStatusBuffer.getUpToDateReadBuffer().desiredAcc(3));
335 datafields["desiredAcc_ry"] =
336 new Variant(controlStatusBuffer.getUpToDateReadBuffer().desiredAcc(4));
337 datafields["desiredAcc_rz"] =
338 new Variant(controlStatusBuffer.getUpToDateReadBuffer().desiredAcc(5));
339
340 datafields["kpImpedance_x"] =
341 new Variant(controlStatusBuffer.getUpToDateReadBuffer().kpImpedance(0));
342 datafields["kpImpedance_y"] =
343 new Variant(controlStatusBuffer.getUpToDateReadBuffer().kpImpedance(1));
344 datafields["kpImpedance_z"] =
345 new Variant(controlStatusBuffer.getUpToDateReadBuffer().kpImpedance(2));
346 datafields["kpImpedance_rx"] =
347 new Variant(controlStatusBuffer.getUpToDateReadBuffer().kpImpedance(3));
348 datafields["kpImpedance_ry"] =
349 new Variant(controlStatusBuffer.getUpToDateReadBuffer().kpImpedance(4));
350 datafields["kpImpedance_rz"] =
351 new Variant(controlStatusBuffer.getUpToDateReadBuffer().kpImpedance(5));
352
353 datafields["kdImpedance_x"] =
354 new Variant(controlStatusBuffer.getUpToDateReadBuffer().kdImpedance(0));
355 datafields["kdImpedance_y"] =
356 new Variant(controlStatusBuffer.getUpToDateReadBuffer().kdImpedance(1));
357 datafields["kdImpedance_z"] =
358 new Variant(controlStatusBuffer.getUpToDateReadBuffer().kdImpedance(2));
359 datafields["kdImpedance_rx"] =
360 new Variant(controlStatusBuffer.getUpToDateReadBuffer().kdImpedance(3));
361 datafields["kdImpedance_ry"] =
362 new Variant(controlStatusBuffer.getUpToDateReadBuffer().kdImpedance(4));
363 datafields["kdImpedance_rz"] =
364 new Variant(controlStatusBuffer.getUpToDateReadBuffer().kdImpedance(5));
365
366 datafields["forceImpedance_x"] =
367 new Variant(controlStatusBuffer.getUpToDateReadBuffer().forceImpedance(0));
368 datafields["forceImpedance_y"] =
369 new Variant(controlStatusBuffer.getUpToDateReadBuffer().forceImpedance(1));
370 datafields["forceImpedance_z"] =
371 new Variant(controlStatusBuffer.getUpToDateReadBuffer().forceImpedance(2));
372 datafields["forceImpedance_rx"] =
373 new Variant(controlStatusBuffer.getUpToDateReadBuffer().forceImpedance(3));
374 datafields["forceImpedance_ry"] =
375 new Variant(controlStatusBuffer.getUpToDateReadBuffer().forceImpedance(4));
376 datafields["forceImpedance_rz"] =
377 new Variant(controlStatusBuffer.getUpToDateReadBuffer().forceImpedance(5));
378
379 datafields["currentForceTorque_x"] =
380 new Variant(controlStatusBuffer.getUpToDateReadBuffer().currentForceTorque(0));
381 datafields["currentForceTorque_y"] =
382 new Variant(controlStatusBuffer.getUpToDateReadBuffer().currentForceTorque(1));
383 datafields["currentForceTorque_z"] =
384 new Variant(controlStatusBuffer.getUpToDateReadBuffer().currentForceTorque(2));
385 datafields["currentForceTorque_rx"] =
386 new Variant(controlStatusBuffer.getUpToDateReadBuffer().currentForceTorque(3));
387 datafields["currentForceTorque_ry"] =
388 new Variant(controlStatusBuffer.getUpToDateReadBuffer().currentForceTorque(4));
389 datafields["currentForceTorque_rz"] =
390 new Variant(controlStatusBuffer.getUpToDateReadBuffer().currentForceTorque(5));
391
392 datafields["pointTrackingForce_x"] =
393 new Variant(controlStatusBuffer.getUpToDateReadBuffer().pointTrackingForce(0));
394 datafields["pointTrackingForce_y"] =
395 new Variant(controlStatusBuffer.getUpToDateReadBuffer().pointTrackingForce(1));
396 datafields["pointTrackingForce_z"] =
397 new Variant(controlStatusBuffer.getUpToDateReadBuffer().pointTrackingForce(2));
398 datafields["pointTrackingForce_rx"] =
399 new Variant(controlStatusBuffer.getUpToDateReadBuffer().pointTrackingForce(3));
400 datafields["pointTrackingForce_ry"] =
401 new Variant(controlStatusBuffer.getUpToDateReadBuffer().pointTrackingForce(4));
402 datafields["pointTrackingForce_rz"] =
403 new Variant(controlStatusBuffer.getUpToDateReadBuffer().pointTrackingForce(5));
404
405 for (int i = 0; i < dim; i++)
406 {
407 datafields["desiredKeypointPosition_" + std::to_string(i)] =
408 new Variant(controlStatusBuffer.getUpToDateReadBuffer().desiredKeypointPosition(i));
409 datafields["currentKeypointPosition_" + std::to_string(i)] =
410 new Variant(controlStatusBuffer.getUpToDateReadBuffer().currentKeypointPosition(i));
411 datafields["currentKeypointVelocity_" + std::to_string(i)] =
412 new Variant(controlStatusBuffer.getUpToDateReadBuffer().currentKeypointVelocity(i));
413 datafields["filteredKeypointPosition_" + std::to_string(i)] = new Variant(
414 controlStatusBuffer.getUpToDateReadBuffer().filteredKeypointPosition(i));
415 }
416 debugObs->setDebugChannel("NJointKeypointsAdmittanceController", datafields);
417 }
418
419 void
421 const Ice::Current&)
422 {
423 law::KeypointsAdmittanceController::Config config = controller.reconfigure(filename);
424 reinitTripleBuffer(config);
425
426 common::FTSensor::FTBufferData ftConfig = ftsensor.reconfigure(filename);
427 ftSensorBuffer.reinitAllBuffers(ftConfig);
428 }
429
430 void
432 const Eigen::VectorXf& value,
433 const Ice::Current&)
434 {
436 if (name == "target")
437 {
438 ARMARX_CHECK_EQUAL(value.size(), controller.s.numPoints);
439 getWriterControlStruct().desiredKeypointPosition = value;
440 }
441 else if (name == "current")
442 {
443 ARMARX_CHECK_EQUAL(value.size(), controller.s.numPoints);
444 getWriterControlStruct().currentKeypointPosition = value;
445 }
446 else if (name == "kp")
447 {
448 ARMARX_CHECK_EQUAL(value.size(), controller.s.numPoints);
449 getWriterControlStruct().keypointKp = value;
450 }
451 else if (name == "kd")
452 {
453 ARMARX_CHECK_EQUAL(value.size(), controller.s.numPoints);
454 getWriterControlStruct().keypointKd = value;
455 }
456 else if (name == "translation")
457 {
458 ARMARX_CHECK_EQUAL(value.size(), controller.s.numPoints);
459 getWriterControlStruct().fixedTranslation = value;
460 }
461 }
462
463 void
465 const Eigen::VectorXf& value,
466 const Ice::Current&)
467 {
469 if (name == "impedance_stiffness")
470 {
471 ARMARX_CHECK_EQUAL(value.size(), 6);
472 getWriterControlStruct().kpImpedance = value;
473 }
474 else if (name == "impedance_damping")
475 {
476 ARMARX_CHECK_EQUAL(value.size(), 6);
477 getWriterControlStruct().kdImpedance = value;
478 }
479 else if (name == "admittance_stiffness")
480 {
481 ARMARX_CHECK_EQUAL(value.size(), 6);
482 getWriterControlStruct().kpAdmittance = value;
483 }
484 else if (name == "admittance_damping")
485 {
486 ARMARX_CHECK_EQUAL(value.size(), 6);
487 getWriterControlStruct().kdAdmittance = value;
488 }
489 else if (name == "admittance_inertia")
490 {
491 ARMARX_CHECK_EQUAL(value.size(), 6);
492 getWriterControlStruct().kmAdmittance = value;
493 }
494 else if (name == "nullspace_stiffness")
495 {
496 ARMARX_CHECK_EQUAL((unsigned)value.size(), targets.size());
497 getWriterControlStruct().kpNullspaceTorque = value;
498 }
499 else if (name == "nullspace_damping")
500 {
501 ARMARX_CHECK_EQUAL((unsigned)value.size(), targets.size());
502 getWriterControlStruct().kdNullspaceTorque = value;
503 }
504 else if (name == "desired_nullspace_joint_angles")
505 {
506 ARMARX_CHECK_EQUAL((unsigned)value.size(), targets.size());
507 getWriterControlStruct().desiredNullspaceJointAngles = value;
508 }
509 else
510 {
511 ARMARX_ERROR << name << " is not supported by TaskSpaceAdmittanceController";
512 }
514 }
515
516 void
518 const Eigen::Vector3f& forceBaseline,
519 const Eigen::Vector3f& torqueBaseline,
520 const Ice::Current&)
521 {
522 ftSensorBuffer.getWriteBuffer().forceBaseline = forceBaseline;
523 ftSensorBuffer.getWriteBuffer().torqueBaseline = torqueBaseline;
524 ftSensorBuffer.commitWrite();
525 }
526
527 void
528 NJointKeypointsAdmittanceController::setTCPMass(Ice::Float mass, const Ice::Current&)
529 {
530 ftSensorBuffer.getWriteBuffer().enableTCPGravityCompensation = true;
531 ftSensorBuffer.getWriteBuffer().tcpMass = mass;
532 ftSensorBuffer.commitWrite();
533 }
534
535 void
537 const Eigen::Vector3f& tcpCoMInFTSensorFrame,
538 const Ice::Current&)
539 {
540 ftSensorBuffer.getWriteBuffer().enableTCPGravityCompensation = true;
541 ftSensorBuffer.getWriteBuffer().tcpCoMInFTSensorFrame = tcpCoMInFTSensorFrame;
542 ftSensorBuffer.commitWrite();
543 }
544
545 void
547 {
548 rtReady.store(false);
549 }
550
551 void
553 const Ice::Current&)
554 {
555 ftSensorBuffer.getWriteBuffer().enableTCPGravityCompensation = toggle;
556 ftSensorBuffer.commitWrite();
557 rtReady.store(false); /// you also need to re-calibrate ft sensor
558 }
559
560 void
562 {
563 VirtualRobot::RobotNodeSetPtr rns = rtGetRobot()->getRobotNodeSet(kinematicChainName);
564 Eigen::Matrix4f currentPose = rns->getTCP()->getPoseInRootFrame();
565 ARMARX_IMPORTANT << "rt preactivate controller with target pose\n\n" << currentPose;
566 controller.preactivateInit(rns);
567 getWriterControlStruct().desiredNullspaceJointAngles =
568 controller.s.desiredNullspaceJointAngles;
570
571 controlStatusBuffer.reinitAllBuffers(controller.s);
572 }
573} // namespace armarx::control::njoint_controller::task_space
constexpr T c
Brief description of class JointControlTargetBase.
This util class helps with keeping a cycle time during a control cycle.
Definition CycleUtil.h:41
ArmarXObjectSchedulerPtr getObjectScheduler() const
int getState() const
Retrieve current state of the ManagedIceObject.
bool isControllerActive(const Ice::Current &=Ice::emptyCurrent) const final override
const SensorValueBase * useSensorValue(const std::string &sensorDeviceName) const
Get a const ptr to the given SensorDevice's SensorValue.
void runTask(const std::string &taskName, Task &&task)
Executes a given task in a separate thread from the Application ThreadPool.
const VirtualRobot::RobotPtr & useSynchronizedRtRobot(bool updateCollisionModel=false)
Requests a VirtualRobot for use in rtRun *.
const VirtualRobot::RobotPtr & rtGetRobot()
TODO make protected and use attorneys.
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...
The SensorValueBase class.
const T * asA() const
The Variant class is described here: Variants.
Definition Variant.h:224
void onPublish(const SensorAndControl &, const DebugDrawerInterfacePrx &, const DebugObserverInterfacePrx &) override
TripleBuffer< law::KeypointsAdmittanceController::Status > controlStatusBuffer
set buffers
NJointKeypointsAdmittanceController(const RobotUnitPtr &robotUnit, const NJointControllerConfigPtr &config, const VirtualRobot::RobotPtr &)
void setForceTorqueBaseline(const Eigen::Vector3f &, const Eigen::Vector3f &, const Ice::Current &) override
ft sensor
void rtRun(const IceUtil::Time &sensorValuesTimestamp, const IceUtil::Time &timeSinceLastIteration) override
TODO make protected and use attorneys.
void reconfigureController(const std::string &filename, const Ice::Current &iceCurrent=Ice::emptyCurrent) override
set control target
void setKeypointsParameters(const std::string &name, const Eigen::VectorXf &value, const Ice::Current &) override
void setControlParameters(const std::string &, const Eigen::VectorXf &, const Ice::Current &) override
void rtPreActivateController() override
This function is called before the controller is activated.
#define ARMARX_CHECK_EXPRESSION(expression)
This macro evaluates the expression and if it turns out to be false it will throw an ExpressionExcept...
#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...
#define ARMARX_INFO
The normal logging level.
Definition Logging.h:181
#define ARMARX_IMPORTANT
The logging level for always important information, but expected behaviour (in contrast to ARMARX_WAR...
Definition Logging.h:190
#define ARMARX_ERROR
The logging level for unexpected behaviour, that must be fixed.
Definition Logging.h:196
#define ARMARX_WARNING
The logging level for unexpected behaviour, but not a serious problem.
Definition Logging.h:193
std::shared_ptr< class Robot > RobotPtr
Definition Bus.h:19
NJointControllerRegistration< NJointKeypointsAdmittanceController > registrationControllerNJointKeypointsAdmittanceController("NJointKeypointsAdmittanceController")
::IceInternal::ProxyHandle<::IceProxy::armarx::DebugObserverInterface > DebugObserverInterfacePrx
std::map< std::string, VariantBasePtr > StringVariantBaseMap
IceUtil::Handle< class RobotUnit > RobotUnitPtr
Definition FTSensor.h:34
::IceInternal::ProxyHandle<::IceProxy::armarx::DebugDrawerInterface > DebugDrawerInterfacePrx
detail::ControlThreadOutputBufferEntry SensorAndControl