ImpedanceController.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 
23 #include "ImpedanceController.h"
24 
25 #include <VirtualRobot/MathTools.h>
26 #include <VirtualRobot/Nodes/RobotNode.h>
27 #include <VirtualRobot/RobotNodeSet.h>
28 
30 #include <ArmarXCore/core/PackagePath.h> // for GUI
34 
38 
39 #include <armarx/control/common/aron_conversions.h> // for GUI
42 
44 {
45  NJointControllerRegistration<NJointTaskspaceImpedanceController>
47  "NJointTaskspaceImpedanceController");
48 
49  void
50  NJointTaskspaceImpedanceController::limbInit(const std::string nodeSetName,
51  ArmPtr& arm,
52  Config& cfg,
53  VirtualRobot::RobotPtr& nonRtRobotPtr)
54  {
55  arm->kinematicChainName = nodeSetName;
56  VirtualRobot::RobotNodeSetPtr rtRns =
57  rtGetRobot()->getRobotNodeSet(arm->kinematicChainName);
58  VirtualRobot::RobotNodeSetPtr nonRtRns =
59  nonRtRobotPtr->getRobotNodeSet(arm->kinematicChainName);
60  ARMARX_CHECK_EXPRESSION(rtRns) << arm->kinematicChainName;
61  ARMARX_CHECK_EXPRESSION(nonRtRns) << arm->kinematicChainName;
62  ARMARX_IMPORTANT << "Creating Taskspace Impedance controller with kinematic chain: "
63  << arm->kinematicChainName << " with num of joints: (RT robot) "
64  << rtRns->getSize() << ", and (non-RT robot) " << nonRtRns->getSize();
65 
66  arm->controller.initialize(nonRtRns, rtRns);
67  arm->controller.ftsensor.initialize(rtRns, robotUnit, cfg.ftConfig);
68  arm->jointNames.clear();
69  for (size_t i = 0; i < rtRns->getSize(); ++i)
70  {
71  std::string jointName = rtRns->getNode(i)->getName();
72  arm->jointNames.push_back(jointName);
73 
74  ControlTargetBase* ct = useControlTarget(jointName, ControlModes::Torque1DoF);
76  auto* casted_ct = ct->asA<ControlTarget1DoFActuatorTorque>();
77  ARMARX_CHECK_EXPRESSION(casted_ct);
78  arm->targets.push_back(casted_ct);
79 
80  const SensorValueBase* sv = useSensorValue(jointName);
82  arm->sensorDevices.append(sv, jointName);
83  };
84 
85  validateConfigData(cfg, arm);
86  arm->rtConfig = cfg;
87  arm->nonRtConfig = cfg;
88  arm->rtStatus.reset(rtRns->getSize());
89  }
90 
92  const RobotUnitPtr& robotUnit,
93  const NJointControllerConfigPtr& config,
94  const VirtualRobot::RobotPtr&) :
95  robotUnit(robotUnit)
96  {
98 
99  ConfigPtrT cfg = ConfigPtrT::dynamicCast(config);
101  userConfig.fromAron(cfg->config);
102 
104  nonRtRobot = robotUnit->cloneRobot();
105  robotUnit->updateVirtualRobot(nonRtRobot);
106 
107  for (auto& pair : userConfig.limbs)
108  {
109  limb.emplace(pair.first, std::make_unique<ArmData>());
110  limbInit(pair.first, limb.at(pair.first), pair.second, nonRtRobot);
111  controllableNodeSets.emplace(pair.first, nonRtRobot->getRobotNodeSet(pair.first));
112  }
113 
114  if (not userConfig.hands.empty())
115  {
116  hands = std::make_shared<core::HandControlBase>(nonRtRobot, userConfig.hands);
117  for (auto& pair : userConfig.hands)
118  {
119  for (auto& jointName : hands->hands.at(pair.first)->jointNames)
120  {
121  hands->appendDevice(pair.first,
122  useSensorValue(jointName),
123  useControlTarget(jointName, ControlModes::Position1DoF),
124  jointName);
125  }
126  ARMARX_INFO << "construction of hand "
127  << hands->hands.at(pair.first)->kinematicChainName;
128  controllableNodeSets.emplace(pair.first, nonRtRobot->getRobotNodeSet(pair.first));
129  }
130  }
131  }
132 
133  std::string
135  {
136  return "NJointTaskspaceImpedanceController";
137  }
138 
139  void
141  {
142  std::string taskName = getClassName() + "AdditionalTask";
143  runTask(taskName,
144  [&]
145  {
147  4); // please don't set this to 0 as it is the rtRun/control thread
150 
151  CycleUtil c(1);
152  getObjectScheduler()->waitForObjectStateMinimum(eManagedIceObjectStarted);
153  ARMARX_IMPORTANT << "Create a new thread for " << getClassName();
154  while (getState() == eManagedIceObjectStarted)
155  {
156  if (isControllerActive())
157  {
158  additionalTask();
159  }
160  c.waitForCycleDuration();
161  }
162  });
163  }
164 
165  void
167  {
168  arm->bufferConfigNonRtToRt.getWriteBuffer() = arm->nonRtConfig;
169  arm->bufferConfigNonRtToRt.commitWrite();
170  }
171 
172  void
174  {
175  bool rtSafe = additionalTaskUpdateStatus();
177  if (not rtSafe)
178  {
180  }
181  }
182 
183  bool
185  {
186  robotUnit->updateVirtualRobot(nonRtRobot);
187  bool rtSafe = true;
188  for (auto& pair : limb)
189  {
190  auto& arm = pair.second;
191  arm->nonRtConfig = arm->bufferConfigUserToNonRt.getUpToDateReadBuffer();
192  arm->rtStatusInNonRT = arm->bufferRtStatusToNonRt.getUpToDateReadBuffer();
193  rtSafe = rtSafe and pair.second->rtStatusInNonRT.rtSafe;
194  }
195  if (hands)
196  {
197  hands->nonRTUpdateStatus();
198  }
199  return rtSafe;
200  }
201 
202  void
204  {
205  for (auto& pair : limb)
206  {
207  limbNonRT(pair.second);
208  }
209  if (hands)
210  {
211  hands->nonRTSetTarget();
212  }
213  }
214 
215  void
217  {
218  for (auto& pair : limb)
219  {
220  if (not pair.second->rtReady)
221  continue;
222 
223  if (not pair.second->rtStatusInNonRT.rtTargetSafe)
224  {
225  pair.second->rtStatusInNonRT =
226  pair.second->bufferRtStatusToNonRt.getUpToDateReadBuffer();
228  pair.second->rtStatusInNonRT.currentPose,
229  pair.second->nonRtConfig.desiredPose,
230  "current pose",
231  "desired pose");
232  }
233  }
234  }
235 
236  /// -------------------------------- Real time cotnrol -----------------------------------------
237  void
239  {
240  arm->rtConfig = arm->bufferConfigNonRtToRt.getUpToDateReadBuffer();
241  arm->rtStatus.deltaT = deltaT;
242  arm->rtStatus.accumulateTime += deltaT;
243 
244  arm->controller.ftsensor.updateStatus(arm->rtConfig.ftConfig,
245  arm->rtStatus.currentForceTorque,
246  arm->rtStatus.deltaT,
247  arm->rtFirstRun.load());
248 
249  arm->sensorDevices.updateJointValues(
250  arm->rtStatus.jointPos, arm->rtStatus.jointVel, arm->rtStatus.jointTor);
251 
252 
253  arm->bufferRtStatusToNonRt.getWriteBuffer() = arm->rtStatus;
254  arm->bufferRtStatusToNonRt.commitWrite();
255  arm->bufferRtStatusToUser.getWriteBuffer() = arm->rtStatus;
256  arm->bufferRtStatusToUser.commitWrite();
257  }
258 
259  void
261  const Eigen::VectorXf& targetTorque)
262  {
263  for (unsigned int i = 0; i < targetTorque.size(); i++)
264  {
265  arm->targets.at(i)->torque = targetTorque(i);
266  if (!arm->targets.at(i)->isValid())
267  {
268  arm->targets.at(i)->torque = 0;
269  }
270  }
271  arm->bufferRtStatusToOnPublish.getWriteBuffer() = arm->rtStatus;
272  arm->bufferRtStatusToOnPublish.commitWrite();
273 
274  arm->bufferConfigRtToOnPublish.getWriteBuffer() = arm->rtConfig;
275  arm->bufferConfigRtToOnPublish.commitWrite();
276 
277  arm->bufferConfigRtToUser.getWriteBuffer() = arm->rtConfig;
278  arm->bufferConfigRtToUser.commitWrite();
279 
280  if (arm->rtFirstRun.load())
281  {
282  arm->rtFirstRun.store(false);
283  arm->rtReady.store(true);
284  }
285  }
286 
287  void
289  {
290  double time_measure = IceUtil::Time::now().toMicroSecondsDouble();
291  limbRTUpdateStatus(arm, deltaT);
292  double time_update_status = IceUtil::Time::now().toMicroSecondsDouble() - time_measure;
293 
294  arm->controller.run(arm->rtConfig, arm->rtStatus);
295  double time_run_rt = IceUtil::Time::now().toMicroSecondsDouble() - time_measure;
296 
297  limbRTSetTarget(arm, arm->rtStatus.desiredJointTorques);
298 
299  double time_set_target = IceUtil::Time::now().toMicroSecondsDouble() - time_measure;
300  time_measure = IceUtil::Time::now().toMicroSecondsDouble() - time_measure;
301 
302  if (time_measure > 200)
303  {
304  ARMARX_RT_LOGF_WARN("---- rt too slow: "
305  "time_update_status: %.2f\n"
306  "run_rt_limb: %.2f\n"
307  "set_target_limb: %.2f\n"
308  "time all: %.2f\n",
309  time_update_status, // 0-1 us
310  time_run_rt - time_update_status, //
311  time_set_target - time_run_rt, //
312  time_measure)
313  .deactivateSpam(1.0f); // 0-1 us
314  }
315  }
316 
317  void
319  const IceUtil::Time& timeSinceLastIteration)
320  {
321  double deltaT = timeSinceLastIteration.toSecondsDouble();
322  for (auto& pair : limb)
323  {
324  limbRT(pair.second, deltaT);
325  }
326  if (hands)
327  {
328  hands->updateRTStatus(deltaT);
329  hands->setTargets();
330  }
331  }
332 
333  /// ------------------------------ update/get config -------------------------------------------
334  void
336  const Ice::Current& iceCurrent)
337  {
338  auto prevCfg = userConfig;
339  userConfig.fromAron(dto);
340 
341  for (auto& pair : userConfig.limbs)
342  {
343  validateConfigData(pair.second, limb.at(pair.first));
345  pair.second.desiredPose,
346  prevCfg.limbs.at(pair.first).desiredPose,
347  "new desired pose",
348  "previous desired pose",
349  pair.second.safeDistanceMMToGoal,
350  pair.second.safeRotAngleDegreeToGoal,
351  "updateConfig_" + pair.first))
352  {
353  ARMARX_INFO << "use the existing target pose";
354  pair.second.desiredPose = prevCfg.limbs.at(pair.first).desiredPose;
355  }
356  limb.at(pair.first)->bufferConfigUserToNonRt.getWriteBuffer() = pair.second;
357  limb.at(pair.first)->bufferConfigUserToNonRt.commitWrite();
358  }
359  if (hands)
360  {
361  hands->updateConfig(userConfig.hands);
362  }
363  }
364 
366  NJointTaskspaceImpedanceController::getConfig(const Ice::Current& iceCurrent)
367  {
368  for (auto& pair : limb)
369  {
370  userConfig.limbs.at(pair.first) =
371  pair.second->bufferConfigRtToUser.getUpToDateReadBuffer();
372  }
373  if (hands)
374  {
375  hands->getConfig(userConfig.hands);
376  }
377  return userConfig.toAronDTO();
378  }
379 
380  void
382  const bool forceGuard,
383  const bool torqueGuard,
384  const Ice::Current& iceCurrent)
385  {
386  auto it = userConfig.limbs.find(nodeSetName);
387  if (it != userConfig.limbs.end())
388  {
389  it->second.ftConfig.enableSafeGuardForce = forceGuard;
390  it->second.ftConfig.enableSafeGuardTorque = torqueGuard;
391  limb.at(nodeSetName)->controller.ftsensor.enableSafeGuard(forceGuard, torqueGuard);
393  << "reset safe guard with force torque sensors: safe? "
394  << limb.at(nodeSetName)->controller.ftsensor.isSafe(it->second.ftConfig);
395  limb.at(nodeSetName)->bufferConfigUserToNonRt.getWriteBuffer() = it->second;
396  limb.at(nodeSetName)->bufferConfigUserToNonRt.commitWrite();
397  }
398  else
399  {
400  ARMARX_WARNING << "no robot node set with name " << nodeSetName
401  << " found in the controllers.";
402  }
403  }
404 
405  /// -------------------------------- Other interaces -------------------------------------------
406  bool
408  const Ice::Current& iceCurrent)
409  {
410  auto it = userConfig.limbs.find(nodeSetName);
411  if (it != userConfig.limbs.end())
412  {
413  return limb.at(nodeSetName)->controller.ftsensor.ftSafe.load();
414  }
415 
416  ARMARX_WARNING << "no robot node set with name " << nodeSetName
417  << " found in the controllers.";
418  return false;
419  }
420 
421  Ice::FloatSeq
423  const Ice::Current& iceCurrent)
424  {
425  std::vector<float> tcpVel;
426  auto& arm = limb.at(rns);
427  auto s = arm->bufferRtStatusToUser.getUpToDateReadBuffer();
428  for (int i = 0; i < s.currentTwist.size(); i++)
429  {
430  tcpVel.push_back(s.currentTwist[i]);
431  }
432  return tcpVel;
433  }
434 
435  bool
437  const TargetPoseMap& targetPoseMap,
438  const TargetNullspaceMap& targetNullspaceMap,
439  const Ice::Current& iceCurrent)
440  {
441  for (auto& pair : userConfig.limbs)
442  {
443  for (size_t i = 0; i < 4; ++i)
444  {
445  for (int j = 0; j < 4; ++j)
446  {
447  pair.second.desiredPose(i, j) = targetPoseMap.at(pair.first)[i][j];
448  }
449  }
450  if (targetNullspaceMap.at(pair.first).size() > 0)
451  {
452  const size_t nDoF = pair.second.desiredNullspaceJointAngles.value().size();
453  ARMARX_CHECK_EQUAL(targetNullspaceMap.at(pair.first).size(), nDoF)
454  << "the joint numbers does not match";
455  for (size_t i = 0; i < nDoF; ++i)
456  {
457  pair.second.desiredNullspaceJointAngles.value()(i) =
458  targetNullspaceMap.at(pair.first)[i];
459  }
460  }
461  limb.at(pair.first)->bufferConfigUserToNonRt.getWriteBuffer() = pair.second;
462  limb.at(pair.first)->bufferConfigUserToNonRt.commitWrite();
463  }
464  return true;
465  }
466 
467  void
469  {
470  const auto nDoF = arm->controller.numOfJoints;
471 
472  const auto checkSize = [nDoF](const auto& v) { ARMARX_CHECK_EQUAL(v.rows(), nDoF); };
473  const auto checkNonNegative = [](const auto& v) { ARMARX_CHECK((v.array() >= 0).all()); };
474 
475  if (!configData.desiredNullspaceJointAngles.has_value())
476  {
477  if (!isControllerActive())
478  {
479  ARMARX_INFO << "No user defined nullspace target, reset to zero with "
480  << VAROUT(nDoF);
481  configData.desiredNullspaceJointAngles = Eigen::VectorXf::Zero(nDoF);
482  arm->reInitPreActivate.store(true);
483  }
484  else
485  {
486  auto currentValue =
487  arm->bufferConfigRtToUser.getUpToDateReadBuffer().desiredNullspaceJointAngles;
489  << "Controller is active, but no user defined nullspace target. \n"
490  "You should first get up-to-date config of this controller and then update "
491  "it:\n"
492  " auto cfg = ctrl->getConfig(); \n"
493  " cfg.desiredPose = xxx;\n"
494  " ctrl->updateConfig(cfg);\n"
495  "Now, I decide by myself to use the existing values of nullspace target\n"
496  << currentValue.value();
497  configData.desiredNullspaceJointAngles = currentValue;
498  }
499  }
500  ARMARX_CHECK_GREATER(configData.safeDistanceMMToGoal, 100.0f);
501  checkSize(configData.desiredNullspaceJointAngles.value());
502  checkSize(configData.kdNullspace);
503  checkSize(configData.kpNullspace);
504 
505  checkNonNegative(configData.kdNullspace);
506  checkNonNegative(configData.kpNullspace);
507  checkNonNegative(configData.kdImpedance);
508  checkNonNegative(configData.kpImpedance);
509  }
510 
511  void
513  const DebugObserverInterfacePrx& debugObs)
514  {
515  StringVariantBaseMap datafields;
516  auto rtData = arm->bufferConfigRtToOnPublish.getUpToDateReadBuffer();
517  auto rtStatus = arm->bufferRtStatusToOnPublish.getUpToDateReadBuffer();
518 
519  common::debugEigenVec(datafields, "kpImpedance", rtData.kpImpedance);
520  common::debugEigenVec(datafields, "kdImpedance", rtData.kdImpedance);
521  if (rtData.desiredNullspaceJointAngles.has_value())
522  {
523  common::debugEigenVec(datafields,
524  "desiredNullspaceJointAngles",
525  rtData.desiredNullspaceJointAngles.value());
526  }
527  common::debugEigenPose(datafields, "current_pose", rtStatus.currentPose);
528  common::debugEigenPose(datafields, "desired_pose", rtStatus.desiredPose);
529  common::debugEigenVec(datafields, "currentForceTorque", rtStatus.currentForceTorque);
530 
531  common::debugEigenVec(datafields, "forceImpedance", rtStatus.forceImpedance);
532  common::debugEigenVec(datafields, "nullspaceTorque", rtStatus.nullspaceTorque);
533  common::debugEigenVec(datafields, "desiredJointTorques", rtStatus.desiredJointTorques);
534 
535  datafields["safeDistanceToGoalThr"] = new Variant(rtData.safeDistanceMMToGoal);
536  debugObs->setDebugChannel(getClassName() + "_" + arm->kinematicChainName, datafields);
537  }
538 
539  void
542  const DebugObserverInterfacePrx& debugObs)
543  {
544  for (auto& pair : limb)
545  {
546  if (not pair.second->rtReady.load())
547  continue;
548  limbPublish(pair.second, debugObs);
549  }
550  if (hands)
551  {
552  hands->onPublish(debugObs);
553  }
554  }
555 
556  void
558  {
559  for (auto& pair : limb)
560  {
561  pair.second->rtReady.store(false);
562  }
563  }
564 
565  void
567  {
568  VirtualRobot::RobotNodeSetPtr rns = rtGetRobot()->getRobotNodeSet(arm->kinematicChainName);
569  Eigen::Matrix4f currentPose = rns->getTCP()->getPoseInRootFrame();
570  auto quat = VirtualRobot::MathTools::eigen4f2quat(currentPose);
571  ARMARX_RT_LOGF_INFO("rt preactivate controller with target pose\n\n "
572  "[ %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %.2f ].",
573  currentPose(0, 3),
574  currentPose(1, 3),
575  currentPose(2, 3),
576  quat.w,
577  quat.x,
578  quat.y,
579  quat.z);
580 
581  if (arm->reInitPreActivate.load())
582  {
583  arm->rtConfig.desiredNullspaceJointAngles.value() = rns->getJointValuesEigen();
584  arm->rtConfig.desiredPose = currentPose;
585 
586  arm->bufferConfigUserToNonRt.reinitAllBuffers(arm->rtConfig);
587  arm->reInitPreActivate.store(false);
588  }
589  {
590  arm->nonRtConfig = arm->rtConfig;
591  arm->bufferConfigNonRtToRt.reinitAllBuffers(arm->rtConfig);
592  arm->bufferConfigRtToOnPublish.reinitAllBuffers(arm->rtConfig);
593  arm->bufferConfigRtToUser.reinitAllBuffers(arm->rtConfig);
594  }
595  {
596  arm->sensorDevices.updateJointValues(
597  arm->rtStatus.jointPos, arm->rtStatus.jointVel, arm->rtStatus.jointTor);
598  arm->rtStatus.rtPreActivate(currentPose);
599 
600  arm->rtStatusInNonRT = arm->rtStatus;
601  arm->nonRTDeltaT = 0.0;
602  arm->nonRTAccumulateTime = 0.0;
603  arm->bufferRtStatusToOnPublish.reinitAllBuffers(arm->rtStatus);
604  arm->bufferRtStatusToNonRt.reinitAllBuffers(arm->rtStatus);
605  arm->bufferRtStatusToUser.reinitAllBuffers(arm->rtStatus);
606  }
607 
608  arm->controller.preactivateInit(rns);
609  }
610 
611  void
613  {
614  for (auto& pair : limb)
615  {
616  ARMARX_RT_LOGF_INFO("rtPreActivateController for %s", pair.first.c_str());
617  limbReInit(pair.second);
618  userConfig.limbs.at(pair.first) = pair.second->rtConfig;
619  }
620  if (hands)
621  {
622  hands->rtPreActivate();
623  }
624  }
625 
626  void
628  {
629  // for (auto& pair : limb)
630  // {
631  // pair.second->controller.isInitialized.store(false);
632  // }
633  if (hands)
634  {
635  hands->rtPostDeactivate();
636  }
637  }
638 
639  /// ----------------------------------- GUI Widget ---------------------------------------------
642  const VirtualRobot::RobotPtr& robot,
643  const std::map<std::string, ConstControlDevicePtr>& controlDevices,
644  const std::map<std::string, ConstSensorDevicePtr>&)
645  {
646  using namespace armarx::WidgetDescription;
647  HBoxLayoutPtr layout = new HBoxLayout;
648 
649 
650  ::armarx::WidgetDescription::WidgetSeq widgets;
651 
652  /// select default config
653  LabelPtr label = new Label;
654  label->text = "select a controller config";
655 
656  StringComboBoxPtr cfgBox = new StringComboBox;
657  cfgBox->name = "config_box";
658  cfgBox->defaultIndex = 0;
659  cfgBox->multiSelect = false;
660 
661  cfgBox->options = std::vector<std::string>{"default", "default_right", "default_a7_right"};
662  ARMARX_TRACE;
663 
664  layout->children.emplace_back(label);
665  layout->children.emplace_back(cfgBox);
666  ARMARX_TRACE;
667 
668  layout->children.insert(layout->children.end(), widgets.begin(), widgets.end());
669  ARMARX_INFO_S << "Layout done";
670  return layout;
671  }
672 
676  {
677  auto cfgName = values.at("config_box")->getString();
678  const armarx::PackagePath configPath(
679  "armarx_control",
680  "controller_config/NJointTaskspaceImpedanceController/" + cfgName + ".json");
681  ARMARX_INFO_S << "Loading config from " << configPath.toSystemPath();
682  ARMARX_CHECK(std::filesystem::exists(configPath.toSystemPath()));
683 
684  auto cfgDTO = armarx::readFromJson<ConfigDict>(configPath.toSystemPath());
685 
686  ARMARX_TRACE;
687  return new ConfigurableNJointControllerConfig{cfgDTO.toAronDTO()};
688  }
689 
690 } // namespace armarx::control::njoint_controller::task_space
armarx::ControlTargetBase::asA
const T * asA() const
Definition: ControlTargetBase.h:76
armarx::Variant
The Variant class is described here: Variants.
Definition: Variant.h:223
ARMARX_RT_LOGF_INFO
#define ARMARX_RT_LOGF_INFO(...)
Definition: ControlThreadOutputBuffer.h:344
SingleTypeVariantList.h
armarx::control::common::debugEigenPose
void debugEigenPose(StringVariantBaseMap &datafields, const std::string &name, Eigen::Matrix4f pose)
Definition: utils.cpp:113
armarx::control::ethercat::RTUtility::RT_THREAD_PRIORITY
static constexpr int RT_THREAD_PRIORITY
The thread priority for rt-threads.
Definition: RTUtility.h:24
armarx::control::njoint_controller::task_space::NJointTaskspaceImpedanceController::limbRT
void limbRT(ArmPtr &arm, const double deltaT)
Definition: ImpedanceController.cpp:288
armarx::NJointControllerBase::useSynchronizedRtRobot
const VirtualRobot::RobotPtr & useSynchronizedRtRobot(bool updateCollisionModel=false)
Requests a VirtualRobot for use in rtRun *.
Definition: NJointController.cpp:293
armarx::StringVariantBaseMap
std::map< std::string, VariantBasePtr > StringVariantBaseMap
Definition: ManagedIceObject.h:110
ARMARX_IMPORTANT
#define ARMARX_IMPORTANT
Definition: Logging.h:190
armarx::SensorValueBase
The SensorValueBase class.
Definition: SensorValueBase.h:40
armarx::control::njoint_controller::task_space::NJointTaskspaceImpedanceController::GenerateConfigFromVariants
static ConfigPtrT GenerateConfigFromVariants(const StringVariantBaseMap &values)
Definition: ImpedanceController.cpp:674
armarx::control::njoint_controller::task_space::NJointTaskspaceImpedanceController::handleRTNotSafeInNonRT
void handleRTNotSafeInNonRT()
Definition: ImpedanceController.cpp:216
armarx::ControlTargetBase
Brief description of class JointControlTargetBase.
Definition: ControlTargetBase.h:47
RobotUnit.h
armarx::control::njoint_controller::task_space::NJointTaskspaceImpedanceController::GenerateConfigDescription
static WidgetDescription::WidgetPtr GenerateConfigDescription(const VirtualRobot::RobotPtr &, const std::map< std::string, ConstControlDevicePtr > &, const std::map< std::string, ConstSensorDevicePtr > &)
--------------------------------— GUI Widget ------------------------------------------—
Definition: ImpedanceController.cpp:641
GfxTL::Matrix4f
MatrixXX< 4, 4, float > Matrix4f
Definition: MatrixXX.h:650
armarx::control::njoint_controller::task_space::NJointTaskspaceImpedanceController::hands
core::HandControlPtr hands
Definition: ImpedanceController.h:165
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::common::detectAndReportPoseDeviationWarning
bool detectAndReportPoseDeviationWarning(const Eigen::Matrix4f &pose1, const Eigen::Matrix4f &pose2, const std::string &namePose1, const std::string &namePose2, float positionThrMM, float angleThrDeg, const std::string &who)
Definition: utils.cpp:646
armarx::control::njoint_controller::task_space::NJointTaskspaceImpedanceController::onInitNJointController
void onInitNJointController() override
NJointControllerBase interface.
Definition: ImpedanceController.cpp:140
armarx::control::NJointTaskspaceImpedanceControllerInterface::calibrateFTSensor
void calibrateFTSensor()
ft sensor
armarx::control::njoint_controller::task_space
Definition: AdmittanceController.cpp:43
armarx::control::ethercat::RTUtility::pinThreadToCPU
static bool pinThreadToCPU(unsigned int cpu)
Pins the calling thread to the CPU with the given id.
Definition: RTUtility.cpp:52
ARMARX_CHECK_GREATER
#define ARMARX_CHECK_GREATER(lhs, rhs)
This macro evaluates whether lhs is greater (>) than rhs and if it turns out to be false it will thro...
Definition: ExpressionException.h:116
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:769
armarx::control::njoint_controller::task_space::NJointTaskspaceImpedanceController::limbInit
void limbInit(const std::string nodeSetName, ArmPtr &arm, Config &cfg, VirtualRobot::RobotPtr &nonRtRobotPtr)
Definition: ImpedanceController.cpp:50
ProsthesisInterface.values
values
Definition: ProsthesisInterface.py:190
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:46
armarx::NJointControllerBase::ConfigPtrT
NJointControllerConfigPtr ConfigPtrT
Definition: NJointControllerBase.h:587
armarx::control::njoint_controller::task_space::NJointTaskspaceImpedanceController::limbPublish
void limbPublish(ArmPtr &arm, const DebugObserverInterfacePrx &debugObs)
Definition: ImpedanceController.cpp:512
aron_conversions.h
armarx::control::common::reportPoseDeviationWarning
void reportPoseDeviationWarning(const std::string &who, const Eigen::Matrix4f &pose1, const Eigen::Matrix4f &pose2, const std::string &namePose1, const std::string &namePose2)
Definition: utils.cpp:623
armarx::control::njoint_controller::task_space::NJointTaskspaceImpedanceController::rtPostDeactivateController
void rtPostDeactivateController() override
This function is called after the controller is deactivated.
Definition: ImpedanceController.cpp:627
armarx::control::njoint_controller::task_space::NJointTaskspaceImpedanceController::enableSafeGuardForceTorque
void enableSafeGuardForceTorque(const std::string &nodeSetName, const bool forceGuard, const bool torqueGuard, const Ice::Current &iceCurrent=Ice::emptyCurrent) override
Definition: ImpedanceController.cpp:381
ARMARX_CHECK
#define ARMARX_CHECK(expression)
Shortcut for ARMARX_CHECK_EXPRESSION.
Definition: ExpressionException.h:82
armarx::control::njoint_controller::task_space::NJointTaskspaceImpedanceController::rtRun
void rtRun(const IceUtil::Time &sensorValuesTimestamp, const IceUtil::Time &timeSinceLastIteration) override
TODO make protected and use attorneys.
Definition: ImpedanceController.cpp:318
armarx::control::njoint_controller::task_space::NJointTaskspaceImpedanceController::updateConfig
void updateConfig(const ::armarx::aron::data::dto::DictPtr &dto, const Ice::Current &iceCurrent=Ice::emptyCurrent) override
NJointController interface.
Definition: ImpedanceController.cpp:335
IceInternal::Handle
Definition: forward_declarations.h:8
armarx::NJointControllerBase::rtGetRobot
const VirtualRobot::RobotPtr & rtGetRobot()
TODO make protected and use attorneys.
Definition: NJointControllerBase.h:846
armarx::detail::ControlThreadOutputBufferEntry
Definition: ControlThreadOutputBuffer.h:182
visionx::voxelgrid::Label
uint32_t Label
Type of an object label.
Definition: types.h:6
armarx::control::TargetNullspaceMap
dictionary< string, Ice::FloatSeq > TargetNullspaceMap
Definition: ControllerInterface.ice:40
armarx::WidgetDescription
Definition: DefaultWidgetDescriptions.cpp:27
armarx::control::njoint_controller::task_space::NJointTaskspaceImpedanceController::ArmPtr
std::unique_ptr< ArmData > ArmPtr
Definition: ImpedanceController.h:98
armarx::control::njoint_controller::task_space::NJointTaskspaceImpedanceController::onPublish
void onPublish(const SensorAndControl &, const DebugDrawerInterfacePrx &, const DebugObserverInterfacePrx &) override
Definition: ImpedanceController.cpp:540
ARMARX_TRACE
#define ARMARX_TRACE
Definition: trace.h:77
armarx::control::njoint_controller::task_space::NJointTaskspaceImpedanceController::NJointTaskspaceImpedanceController
NJointTaskspaceImpedanceController(const RobotUnitPtr &robotUnit, const NJointControllerConfigPtr &config, const VirtualRobot::RobotPtr &)
Definition: ImpedanceController.cpp:91
armarx::control::njoint_controller::task_space::NJointTaskspaceImpedanceController::getTCPVel
Ice::FloatSeq getTCPVel(const std::string &rns, const Ice::Current &iceCurrent=Ice::emptyCurrent) override
Definition: ImpedanceController.cpp:422
armarx::PackagePath::toSystemPath
static std::filesystem::path toSystemPath(const data::PackagePath &pp)
Definition: PackagePath.cpp:47
armarx::NJointControllerBase::isControllerActive
bool isControllerActive(const Ice::Current &=Ice::emptyCurrent) const final override
Definition: NJointControllerBase.h:778
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:754
armarx::control::njoint_controller::task_space::NJointTaskspaceImpedanceController::limbRTSetTarget
void limbRTSetTarget(ArmPtr &arm, const Eigen::VectorXf &targetTorque)
Definition: ImpedanceController.cpp:260
armarx::control::njoint_controller::task_space::NJointTaskspaceImpedanceController::ConfigPtrT
ConfigurableNJointControllerConfigPtr ConfigPtrT
Definition: ImpedanceController.h:54
armarx::control::njoint_controller::task_space::NJointTaskspaceImpedanceController::validateConfigData
void validateConfigData(Config &config, ArmPtr &arm)
Definition: ImpedanceController.cpp:468
armarx::control::njoint_controller::task_space::NJointTaskspaceImpedanceController::nonRtRobot
VirtualRobot::RobotPtr nonRtRobot
Definition: ImpedanceController.h:162
ArmarXObjectScheduler.h
ControlTarget1DoFActuator.h
armarx::control::njoint_controller::task_space::NJointTaskspaceImpedanceController::isSafeForceTorque
bool isSafeForceTorque(const std::string &nodeSetName, const Ice::Current &iceCurrent=Ice::emptyCurrent) override
-----------------------------— Other interaces ----------------------------------------—
Definition: ImpedanceController.cpp:407
armarx::control::njoint_controller::task_space::NJointTaskspaceImpedanceController::rtPreActivateController
void rtPreActivateController() override
This function is called before the controller is activated.
Definition: ImpedanceController.cpp:612
armarx::control::ethercat::RTUtility::elevateThreadPriority
static bool elevateThreadPriority(int priority)
Elevate the thread priority of the calling thread to the given priority.
Definition: RTUtility.cpp:17
armarx::armem::Time
armarx::core::time::DateTime Time
Definition: forward_declarations.h:13
armarx::control::njoint_controller::task_space::NJointTaskspaceImpedanceController::getConfig
::armarx::aron::data::dto::DictPtr getConfig(const Ice::Current &iceCurrent=Ice::emptyCurrent) override
Definition: ImpedanceController.cpp:366
armarx::control::common::debugEigenVec
void debugEigenVec(StringVariantBaseMap &datafields, const std::string &name, Eigen::VectorXf vec)
Definition: utils.cpp:125
utils.h
CycleUtil.h
armarx::RemoteGui::Client::HBoxLayout
Definition: Widgets.h:160
NJointController.h
armarx::aron::data::DictPtr
std::shared_ptr< Dict > DictPtr
Definition: Dict.h:41
armarx::control::njoint_controller::task_space::registrationControllerNJointTaskspaceImpedanceController
NJointControllerRegistration< NJointTaskspaceImpedanceController > registrationControllerNJointTaskspaceImpedanceController("NJointTaskspaceImpedanceController")
armarx::control::njoint_controller::task_space::NJointTaskspaceImpedanceController::additionalTask
virtual void additionalTask()
Definition: ImpedanceController.cpp:173
armarx::ctrlutil::v
double v(double t, double v0, double a0, double j)
Definition: CtrlUtil.h:39
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
armarx::control::njoint_controller::task_space::NJointTaskspaceImpedanceController::controllableNodeSets
std::map< std::string, VirtualRobot::RobotNodeSetPtr > controllableNodeSets
Definition: ImpedanceController.h:166
TimeUtil.h
ARMARX_INFO
#define ARMARX_INFO
Definition: Logging.h:181
armarx::control::njoint_controller::task_space::NJointTaskspaceImpedanceController::getClassName
std::string getClassName(const Ice::Current &=Ice::emptyCurrent) const override
Definition: ImpedanceController.cpp:134
VAROUT
#define VAROUT(x)
Definition: StringHelpers.h:198
IceUtil::Handle< class RobotUnit >
armarx::control::njoint_controller::task_space::NJointTaskspaceImpedanceController::additionalTaskSetTarget
void additionalTaskSetTarget()
Definition: ImpedanceController.cpp:203
armarx::control::njoint_controller::task_space::NJointTaskspaceImpedanceController::limb
std::map< std::string, ArmPtr > limb
Definition: ImpedanceController.h:161
IceInternal::ProxyHandle<::IceProxy::armarx::DebugObserverInterface >
armarx::control::TargetPoseMap
dictionary< string, FloatSeqSeq > TargetPoseMap
Definition: ControllerInterface.ice:39
armarx::control::njoint_controller::task_space::NJointTaskspaceImpedanceController::Config
law::TaskspaceImpedanceController::Config Config
Definition: ImpedanceController.h:55
ImpedanceController.h
armarx::control::njoint_controller::task_space::NJointTaskspaceImpedanceController::limbRTUpdateStatus
void limbRTUpdateStatus(ArmPtr &arm, const double deltaT)
-----------------------------— Real time cotnrol --------------------------------------—
Definition: ImpedanceController.cpp:238
armarx::control::njoint_controller::task_space::NJointTaskspaceImpedanceController::limbReInit
void limbReInit(ArmPtr &arm)
Definition: ImpedanceController.cpp:566
ARMARX_INFO_S
#define ARMARX_INFO_S
Definition: Logging.h:202
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:193
armarx::control::njoint_controller::task_space::NJointTaskspaceImpedanceController::limbNonRT
void limbNonRT(ArmPtr &arm)
Definition: ImpedanceController.cpp:166
ARMARX_RT_LOGF_WARN
#define ARMARX_RT_LOGF_WARN(...)
Definition: ControlThreadOutputBuffer.h:350
armarx::control::njoint_controller::task_space::NJointTaskspaceImpedanceController::updateTargetPose
bool updateTargetPose(const TargetPoseMap &targetPoseMap, const TargetNullspaceMap &targetNullspaceMap, const Ice::Current &=Ice::emptyCurrent) override
Definition: ImpedanceController.cpp:436
armarx::control::njoint_controller::task_space::NJointTaskspaceImpedanceController::additionalTaskUpdateStatus
bool additionalTaskUpdateStatus()
Definition: ImpedanceController.cpp:184
armarx::PackagePath
Definition: PackagePath.h:52
armarx::ctrlutil::s
double s(double t, double s0, double v0, double a0, double j)
Definition: CtrlUtil.h:33
armarx::control::njoint_controller::task_space::NJointTaskspaceImpedanceController::userConfig
ConfigDict userConfig
Definition: ImpedanceController.h:164
armarx::control::njoint_controller::task_space::NJointTaskspaceImpedanceController::robotUnit
RobotUnitPtr robotUnit
Definition: ImpedanceController.h:163
RTUtility.h
armarx::ManagedIceObject::getObjectScheduler
ArmarXObjectSchedulerPtr getObjectScheduler() const
Definition: ManagedIceObject.cpp:776
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:19
PackagePath.h