25 #include <VirtualRobot/MathTools.h>
26 #include <VirtualRobot/RobotNodeSet.h>
38 NJointControllerRegistration<NJointKeypointsAdmittanceController>
40 "NJointKeypointsAdmittanceController");
44 const NJointControllerConfigPtr& config,
47 ARMARX_INFO <<
"--------------------------------------- creating keypoints admittance "
48 "controller ---------------------------------------";
49 ConfigPtrT cfg = ConfigPtrT::dynamicCast(config);
57 VirtualRobot::RobotNodeSetPtr rns =
rtGetRobot()->getRobotNodeSet(cfg->nodeSetName);
61 for (
size_t i = 0; i < rns->getSize(); ++i)
63 std::string jointName = rns->getNode(i)->getName();
69 auto casted_ct = ct->
asA<ControlTarget1DoFActuatorTorque>();
73 const SensorValue1DoFActuatorTorque* torqueSensor =
74 sv->
asA<SensorValue1DoFActuatorTorque>();
75 const SensorValue1DoFActuatorVelocity* velocitySensor =
76 sv->
asA<SensorValue1DoFActuatorVelocity>();
77 const SensorValue1DoFActuatorPosition* positionSensor =
78 sv->
asA<SensorValue1DoFActuatorPosition>();
85 ARMARX_WARNING <<
"No velocity sensor available for " << jointName;
89 ARMARX_WARNING <<
"No position sensor available for " << jointName;
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;
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;
119 configData.kpNullspace =
controller.s.kpNullspace;
120 configData.kdNullspace =
controller.s.kdNullspace;
122 configData.currentForceTorque.setZero();
123 configData.desiredNullspaceJointAngles =
controller.s.desiredNullspaceJointAngles;
125 configData.torqueLimit =
controller.s.torqueLimit;
126 configData.qvelFilter =
controller.s.qvelFilter;
128 configData.numPoints =
controller.s.numPoints;
129 configData.keypointKp =
controller.s.keypointKp;
130 configData.keypointKd =
controller.s.keypointKd;
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;
139 configData.fixedTranslation =
controller.s.fixedTranslation;
141 ARMARX_INFO <<
"--------------------------------------- done "
142 "---------------------------------------";
148 return "NJointKeypointsAdmittanceController";
160 runTask(
"NJointTaskspaceAdmittanceAdditionalTask",
166 <<
"Create a new thread alone NJointKeypointsAdmittanceController";
167 while (
getState() == eManagedIceObjectStarted)
173 c.waitForCycleDuration();
184 timeSinceLastIteration,
263 for (
int i = 0; i <
values.size(); i++)
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));
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));
288 datafields[
"virtualVel_x"] =
290 datafields[
"virtualVel_y"] =
292 datafields[
"virtualVel_z"] =
294 datafields[
"virtualVel_rx"] =
296 datafields[
"virtualVel_ry"] =
298 datafields[
"virtualVel_rz"] =
301 datafields[
"virtualAcc_x"] =
303 datafields[
"virtualAcc_y"] =
305 datafields[
"virtualAcc_z"] =
307 datafields[
"virtualAcc_rx"] =
309 datafields[
"virtualAcc_ry"] =
311 datafields[
"virtualAcc_rz"] =
314 datafields[
"desiredTwist_x"] =
316 datafields[
"desiredTwist_y"] =
318 datafields[
"desiredTwist_z"] =
320 datafields[
"desiredTwist_rx"] =
322 datafields[
"desiredTwist_ry"] =
324 datafields[
"desiredTwist_rz"] =
327 datafields[
"desiredAcc_x"] =
329 datafields[
"desiredAcc_y"] =
331 datafields[
"desiredAcc_z"] =
333 datafields[
"desiredAcc_rx"] =
335 datafields[
"desiredAcc_ry"] =
337 datafields[
"desiredAcc_rz"] =
340 datafields[
"kpImpedance_x"] =
342 datafields[
"kpImpedance_y"] =
344 datafields[
"kpImpedance_z"] =
346 datafields[
"kpImpedance_rx"] =
348 datafields[
"kpImpedance_ry"] =
350 datafields[
"kpImpedance_rz"] =
353 datafields[
"kdImpedance_x"] =
355 datafields[
"kdImpedance_y"] =
357 datafields[
"kdImpedance_z"] =
359 datafields[
"kdImpedance_rx"] =
361 datafields[
"kdImpedance_ry"] =
363 datafields[
"kdImpedance_rz"] =
366 datafields[
"forceImpedance_x"] =
368 datafields[
"forceImpedance_y"] =
370 datafields[
"forceImpedance_z"] =
372 datafields[
"forceImpedance_rx"] =
374 datafields[
"forceImpedance_ry"] =
376 datafields[
"forceImpedance_rz"] =
379 datafields[
"currentForceTorque_x"] =
381 datafields[
"currentForceTorque_y"] =
383 datafields[
"currentForceTorque_z"] =
385 datafields[
"currentForceTorque_rx"] =
387 datafields[
"currentForceTorque_ry"] =
389 datafields[
"currentForceTorque_rz"] =
392 datafields[
"pointTrackingForce_x"] =
394 datafields[
"pointTrackingForce_y"] =
396 datafields[
"pointTrackingForce_z"] =
398 datafields[
"pointTrackingForce_rx"] =
400 datafields[
"pointTrackingForce_ry"] =
402 datafields[
"pointTrackingForce_rz"] =
405 for (
int i = 0; i < dim; i++)
416 debugObs->setDebugChannel(
"NJointKeypointsAdmittanceController", datafields);
432 const Eigen::VectorXf&
value,
436 if (name ==
"target")
441 else if (name ==
"current")
446 else if (name ==
"kp")
451 else if (name ==
"kd")
456 else if (name ==
"translation")
465 const Eigen::VectorXf&
value,
469 if (name ==
"impedance_stiffness")
474 else if (name ==
"impedance_damping")
479 else if (name ==
"admittance_stiffness")
484 else if (name ==
"admittance_damping")
489 else if (name ==
"admittance_inertia")
494 else if (name ==
"nullspace_stiffness")
499 else if (name ==
"nullspace_damping")
504 else if (name ==
"desired_nullspace_joint_angles")
511 ARMARX_ERROR << name <<
" is not supported by TaskSpaceAdmittanceController";
518 const Eigen::Vector3f& forceBaseline,
519 const Eigen::Vector3f& torqueBaseline,
537 const Eigen::Vector3f& tcpCoMInFTSensorFrame,
565 ARMARX_IMPORTANT <<
"rt preactivate controller with target pose\n\n" << currentPose;