25 #include <VirtualRobot/MathTools.h>
35 const RobotUnitPtr& robotUnit,
36 const NJointControllerConfigPtr& config,
39 ARMARX_INFO <<
"--------------------------------------- creating keypoints admittance controller ---------------------------------------";
40 ConfigPtrT cfg = ConfigPtrT::dynamicCast(config);
48 VirtualRobot::RobotNodeSetPtr rns =
rtGetRobot()->getRobotNodeSet(cfg->nodeSetName);
52 for (
size_t i = 0; i < rns->getSize(); ++i)
54 std::string jointName = rns->getNode(i)->getName();
60 auto casted_ct = ct->
asA<ControlTarget1DoFActuatorTorque>();
64 const SensorValue1DoFActuatorTorque* torqueSensor = sv->
asA<SensorValue1DoFActuatorTorque>();
65 const SensorValue1DoFActuatorVelocity* velocitySensor = sv->
asA<SensorValue1DoFActuatorVelocity>();
66 const SensorValue1DoFActuatorPosition* positionSensor = sv->
asA<SensorValue1DoFActuatorPosition>();
73 ARMARX_WARNING <<
"No velocity sensor available for " << jointName;
77 ARMARX_WARNING <<
"No position sensor available for " << jointName;
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;
94 ftData.tcpCoMInFTSensorFrame =
ftsensor.s.tcpCoMInFTSensorFrame;
95 ftData.enableTCPGravityCompensation =
ftsensor.s.enableTCPGravityCompensation;
96 ftData.forceBaseline =
ftsensor.s.forceBaseline;
97 ftData.torqueBaseline =
ftsensor.s.torqueBaseline;
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;
107 configData.kpNullspace =
controller.s.kpNullspace;
108 configData.kdNullspace =
controller.s.kdNullspace;
110 configData.currentForceTorque.setZero();
111 configData.desiredNullspaceJointAngles =
controller.s.desiredNullspaceJointAngles;
113 configData.torqueLimit =
controller.s.torqueLimit;
114 configData.qvelFilter =
controller.s.qvelFilter;
116 configData.numPoints =
controller.s.numPoints;
117 configData.keypointKp =
controller.s.keypointKp;
118 configData.keypointKd =
controller.s.keypointKd;
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;
127 configData.fixedTranslation =
controller.s.fixedTranslation;
129 ARMARX_INFO <<
"--------------------------------------- done ---------------------------------------";
134 return "NJointKeypointsAdmittanceController";
144 runTask(
"NJointTaskspaceAdmittanceAdditionalTask", [&]
148 ARMARX_IMPORTANT <<
"Create a new thread alone NJointKeypointsAdmittanceController";
149 while (
getState() == eManagedIceObjectStarted)
155 c.waitForCycleDuration();
165 timeSinceLastIteration,
233 for (
int i = 0; i <
values.size(); i++)
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));
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));
321 for (
int i = 0; i < dim; i++)
328 debugObs->setDebugChannel(
"NJointKeypointsAdmittanceController", datafields);
343 if (name ==
"target")
348 else if (name ==
"current")
353 else if (name ==
"kp")
358 else if (name ==
"kd")
363 else if (name ==
"translation")
373 if (name ==
"impedance_stiffness")
378 else if (name ==
"impedance_damping")
383 else if (name ==
"admittance_stiffness")
388 else if (name ==
"admittance_damping")
393 else if (name ==
"admittance_inertia")
398 else if (name ==
"nullspace_stiffness")
403 else if (name ==
"nullspace_damping")
408 else if (name ==
"desired_nullspace_joint_angles")
415 ARMARX_ERROR << name <<
" is not supported by TaskSpaceAdmittanceController";
457 ARMARX_IMPORTANT <<
"rt preactivate controller with target pose\n\n" << currentPose;