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