25 #include <VirtualRobot/MathTools.h>
31 #include <armarx/control/common/control_law/aron/KeypointControllerConfig.aron.generated.h>
37 NJointControllerRegistration<NJointKeypointsImpedanceController>
39 "NJointKeypointsImpedanceController");
42 const RobotUnitPtr& robotUnit,
43 const NJointControllerConfigPtr& config,
46 ConfigPtrT cfg = ConfigPtrT::dynamicCast(config);
51 auto configData = ::armarx::fromAronDict<AronDTO, BO>(cfg->config);
75 for (
size_t i = 0; i < rtRns->getSize(); ++i)
77 std::string jointName = rtRns->getNode(i)->getName();
83 auto casted_ct = ct->
asA<ControlTarget1DoFActuatorTorque>();
87 const SensorValue1DoFActuatorTorque* torqueSensor = sv->
asA<SensorValue1DoFActuatorTorque>();
88 const SensorValue1DoFActuatorVelocity* velocitySensor = sv->
asA<SensorValue1DoFActuatorVelocity>();
89 const SensorValue1DoFActuatorPosition* positionSensor = sv->
asA<SensorValue1DoFActuatorPosition>();
96 ARMARX_WARNING <<
"No velocity sensor available for " << jointName;
100 ARMARX_WARNING <<
"No position sensor available for " << jointName;
114 return "NJointKeypointsImpedanceController";
125 runTask(
"NJointTaskspaceAdmittanceAdditionalTask",
130 ARMARX_IMPORTANT <<
"Create a new thread alone NJointKeypointsImpedanceController";
131 while (
getState() == eManagedIceObjectStarted)
137 c.waitForCycleDuration();
157 double deltaT = timeSinceLastIteration.toSecondsDouble();
169 for (
size_t i = 0; i < nDoF; ++i)
192 const Ice::Current& iceCurrent)
194 auto configData = ::armarx::fromAronDict<AronDTO, BO>(dto);
209 return armarx::toAronDict<AronDTO, BO>(configData);
218 const auto checkNonNegative = [](
const auto&
v) {
ARMARX_CHECK((
v.array() >= 0).all()); };
222 ARMARX_INFO <<
"No user defined nullspace target, reset to zero with " <<
VAROUT(nDoF);
223 configData.desiredNullspaceJointAngles = Eigen::VectorXf::Zero(nDoF);
226 checkSize(configData.desiredNullspaceJointAngles.value());
227 checkSize(configData.kdNullspace);
228 checkSize(configData.kpNullspace);
230 checkNonNegative(configData.kdNullspace);
231 checkNonNegative(configData.kpNullspace);
232 checkNonNegative(configData.kdImpedance);
233 checkNonNegative(configData.kpImpedance);
251 auto nonRtData =
controller.bufferNonRtToOnPublish.getUpToDateReadBuffer();
252 auto rtData =
controller.bufferRtToOnPublish.getUpToDateReadBuffer();
274 debugObs->setDebugChannel(
"NJointKeypointsImpedanceController", datafields);
283 ARMARX_IMPORTANT <<
"rt preactivate controller with target pose\n\n" << currentPose;
289 c.desiredNullspaceJointAngles.value() = rns->getJointValuesEigen();
297 const auto nDoF = rns->getSize();
304 for (
size_t i = 0; i < nDoF; ++i)