VelocityController.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 2024
19  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20  * GNU General Public License
21  */
22 
23 #include "VelocityController.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<NJointTaskspaceVelocityController>
41  "NJointTaskspaceVelocityController");
42 
43  void
44  NJointTaskspaceVelocityController::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::Velocity1DoF);
70  auto* casted_ct = ct->asA<ControlTarget1DoFActuatorVelocity>();
71  ARMARX_CHECK_EXPRESSION(casted_ct);
72  arm->targetsVel.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  NJointTaskspaceVelocityController(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 "NJointTaskspaceVelocityController";
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(arm->rtConfig.ftConfig,
237  arm->rtStatus.currentForceTorque,
238  arm->rtStatus.deltaT,
239  arm->rtFirstRun.load());
240 
241  arm->sensorDevices.updateJointValues(
242  arm->rtStatus.jointPos, arm->rtStatus.jointVel, arm->rtStatus.jointTor);
243 
244 
245  arm->bufferRtStatusToNonRt.getWriteBuffer() = arm->rtStatus;
246  arm->bufferRtStatusToNonRt.commitWrite();
247  arm->bufferRtStatusToUser.getWriteBuffer() = arm->rtStatus;
248  arm->bufferRtStatusToUser.commitWrite();
249  }
250 
251  void
253  ArmPtr& arm,
254  const Eigen::VectorXf& targetVelocity)
255  {
256  for (unsigned int i = 0; i < targetVelocity.size(); i++)
257  {
258  arm->targetsVel.at(i)->velocity = targetVelocity(i);
259  if (!arm->targetsVel.at(i)->isValid())
260  {
261  arm->targetsVel.at(i)->velocity = 0;
262  }
263  }
264  arm->bufferRtStatusToOnPublish.getWriteBuffer() = arm->rtStatus;
265  arm->bufferRtStatusToOnPublish.commitWrite();
266 
267  arm->bufferConfigRtToOnPublish.getWriteBuffer() = arm->rtConfig;
268  arm->bufferConfigRtToOnPublish.commitWrite();
269 
270  arm->bufferConfigRtToUser.getWriteBuffer() = arm->rtConfig;
271  arm->bufferConfigRtToUser.commitWrite();
272 
273  if (arm->rtFirstRun.load())
274  {
275  arm->rtFirstRun.store(false);
276  arm->rtReady.store(true);
277  }
278  }
279 
280  void
282  {
283  double time_measure = IceUtil::Time::now().toMicroSecondsDouble();
284  limbRTUpdateStatus(arm, deltaT);
285  double time_update_status = IceUtil::Time::now().toMicroSecondsDouble() - time_measure;
286 
287  arm->controller.run(arm->rtConfig, arm->rtStatus);
288  double time_run_rt = IceUtil::Time::now().toMicroSecondsDouble() - time_measure;
289 
290  limbRTSetTarget(arm, arm->rtStatus.desiredJointVelocity);
291 
292  double time_set_target = IceUtil::Time::now().toMicroSecondsDouble() - time_measure;
293  time_measure = IceUtil::Time::now().toMicroSecondsDouble() - time_measure;
294 
295  if (time_measure > 200)
296  {
297  ARMARX_RT_LOGF_WARN("---- rt too slow: "
298  "time_update_status: %.2f\n"
299  "run_rt_limb: %.2f\n"
300  "set_target_limb: %.2f\n"
301  "time all: %.2f\n",
302  time_update_status, // 0-1 us
303  time_run_rt - time_update_status, //
304  time_set_target - time_run_rt, //
305  time_measure)
306  .deactivateSpam(1.0f); // 0-1 us
307  }
308  }
309 
310  void
312  const IceUtil::Time& /*sensorValuesTimestamp*/,
313  const IceUtil::Time& timeSinceLastIteration)
314  {
315  double deltaT = timeSinceLastIteration.toSecondsDouble();
316  for (auto& pair : limb)
317  {
318  limbRT(pair.second, deltaT);
319  }
320  if (hands)
321  {
322  hands->updateRTStatus(deltaT);
323  hands->setTargets();
324  }
325  }
326 
327  /// ------------------------------ update/get config -------------------------------------------
328  void
331  const Ice::Current& iceCurrent)
332  {
333  auto prevCfg = userConfig;
334  userConfig.fromAron(dto);
335 
336  for (auto& pair : userConfig.limbs)
337  {
338  validateConfigData(pair.second, limb.at(pair.first));
339  if (common::detectAndReportPoseDeviationWarning(pair.second.desiredPose,
340  prevCfg.limbs.at(pair.first).desiredPose,
341  "new desired pose", "previous desired pose",
342  pair.second.safeDistanceMMToGoal,
343  pair.second.safeRotAngleDegreeToGoal,
344  "updateConfig_" + pair.first))
345  {
346  ARMARX_INFO << "use the existing target pose";
347  pair.second.desiredPose = prevCfg.limbs.at(pair.first).desiredPose;
348  }
349  limb.at(pair.first)->bufferConfigUserToNonRt.getWriteBuffer() = pair.second;
350  limb.at(pair.first)->bufferConfigUserToNonRt.commitWrite();
351  }
352  if (hands)
353  {
354  hands->updateConfig(userConfig.hands);
355  }
356  }
357 
359  NJointTaskspaceVelocityController::getConfig(const Ice::Current& iceCurrent)
360  {
361  for (auto& pair : limb)
362  {
363  userConfig.limbs.at(pair.first) =
364  pair.second->bufferConfigRtToUser.getUpToDateReadBuffer();
365  }
366  if (hands)
367  {
368  hands->getConfig(userConfig.hands);
369  }
370  return userConfig.toAronDTO();
371  }
372 
373  void
375  const std::string& nodeSetName,
376  const bool forceGuard,
377  const bool torqueGuard,
378  const Ice::Current& iceCurrent)
379  {
380  auto it = userConfig.limbs.find(nodeSetName);
381  if (it != userConfig.limbs.end())
382  {
383  it->second.ftConfig.enableSafeGuardForce = forceGuard;
384  it->second.ftConfig.enableSafeGuardTorque = torqueGuard;
385  limb.at(nodeSetName)->controller.ftsensor.enableSafeGuard(forceGuard, torqueGuard);
387  << "reset safe guard with force torque sensors: safe? "
388  << limb.at(nodeSetName)->controller.ftsensor.isSafe(it->second.ftConfig);
389  limb.at(nodeSetName)->bufferConfigUserToNonRt.getWriteBuffer() = it->second;
390  limb.at(nodeSetName)->bufferConfigUserToNonRt.commitWrite();
391  }
392  else
393  {
394  ARMARX_WARNING << "no robot node set with name " << nodeSetName
395  << " found in the controllers.";
396  }
397  }
398 
399  /// -------------------------------- Other interaces -------------------------------------------
400  bool
402  const std::string& nodeSetName,
403  const Ice::Current& iceCurrent)
404  {
405  auto it = userConfig.limbs.find(nodeSetName);
406  if (it != userConfig.limbs.end())
407  {
408  return limb.at(nodeSetName)->controller.ftsensor.ftSafe.load();
409  }
410  else
411  {
412  ARMARX_WARNING << "no robot node set with name " << nodeSetName
413  << " found in the controllers.";
414  }
415  return false;
416  }
417 
418  Ice::FloatSeq
420  const Ice::Current& iceCurrent)
421  {
422  std::vector<float> tcpVel;
423  auto& arm = limb.at(rns);
424  auto s = arm->bufferRtStatusToUser.getUpToDateReadBuffer();
425  for (int i = 0; i < s.currentTwist.size(); i++)
426  {
427  tcpVel.push_back(s.currentTwist[i]);
428  }
429  return tcpVel;
430  }
431 
432  bool
434  const TargetPoseMap& targetPoseMap,
435  const TargetNullspaceMap& targetNullspaceMap,
436  const Ice::Current& iceCurrent)
437  {
438  for (auto& pair : userConfig.limbs)
439  {
440  for (size_t i = 0; i < 4; ++i)
441  {
442  for (int j = 0; j < 4; ++j)
443  {
444  pair.second.desiredPose(i, j) = targetPoseMap.at(pair.first)[i][j];
445  }
446  }
447  if (targetNullspaceMap.at(pair.first).size() > 0)
448  {
449  const size_t nDoF = pair.second.desiredNullspaceJointAngles.value().size();
450  ARMARX_CHECK_EQUAL(targetNullspaceMap.at(pair.first).size(), nDoF)
451  << "the joint numbers does not match";
452  for (size_t i = 0; i < nDoF; ++i)
453  {
454  pair.second.desiredNullspaceJointAngles.value()(i) =
455  targetNullspaceMap.at(pair.first)[i];
456  }
457  }
458  limb.at(pair.first)->bufferConfigUserToNonRt.getWriteBuffer() = pair.second;
459  limb.at(pair.first)->bufferConfigUserToNonRt.commitWrite();
460  }
461  return true;
462  }
463 
464  void
466  ArmPtr& arm)
467  {
468  const auto nDoF = arm->controller.numOfJoints;
469 
470  const auto checkSize = [nDoF](const auto& v) { ARMARX_CHECK_EQUAL(v.rows(), nDoF); };
471  const auto checkNonNegative = [](const auto& v) { ARMARX_CHECK((v.array() >= 0).all()); };
472 
473  if (!configData.desiredNullspaceJointAngles.has_value())
474  {
475  if (!isControllerActive())
476  {
477  ARMARX_INFO << "No user defined nullspace target, reset to zero with "
478  << VAROUT(nDoF);
479  configData.desiredNullspaceJointAngles = Eigen::VectorXf::Zero(nDoF);
480  arm->reInitPreActivate.store(true);
481  }
482  else
483  {
484  auto currentValue =
485  arm->bufferConfigRtToUser.getUpToDateReadBuffer().desiredNullspaceJointAngles;
487  << "Controller is active, but no user defined nullspace target. \n"
488  "You should first get up-to-date config of this controller and then update "
489  "it:\n"
490  " auto cfg = ctrl->getConfig(); \n"
491  " cfg.desiredPose = xxx;\n"
492  " ctrl->updateConfig(cfg);\n"
493  "Now, I decide by myself to use the existing values of nullspace target\n"
494  << currentValue.value();
495  configData.desiredNullspaceJointAngles = currentValue;
496  }
497  }
498  ARMARX_CHECK_GREATER(configData.safeDistanceMMToGoal, 100.0f);
499  checkSize(configData.desiredNullspaceJointAngles.value());
500  checkSize(configData.kdNullspaceVel);
501  checkSize(configData.kpNullspaceVel);
502 
503  checkNonNegative(configData.kdNullspaceVel);
504  checkNonNegative(configData.kpNullspaceVel);
505  checkNonNegative(configData.kpNullspaceVel);
506  checkNonNegative(configData.kdNullspaceVel);
507  }
508 
509  void
511  ArmPtr& arm,
512  const DebugObserverInterfacePrx& debugObs)
513  {
514  StringVariantBaseMap datafields;
515  auto rtData = arm->bufferConfigRtToOnPublish.getUpToDateReadBuffer();
516  auto rtStatus = arm->bufferRtStatusToOnPublish.getUpToDateReadBuffer();
517 
518 
519  common::debugEigenPose(datafields, "current_pose", rtStatus.currentPose);
520  common::debugEigenPose(datafields, "desired_pose", rtStatus.desiredPose);
521  common::debugEigenVec(datafields, "kpCartVel", rtData.kpCartesianVel);
522  common::debugEigenVec(datafields, "kdCartVel", rtData.kdCartesianVel);
523 
524  common::debugEigenVec(datafields, "currentForceTorque", rtStatus.currentForceTorque);
525 
526  common::debugEigenVec(datafields, "cartesianVelTarget", rtStatus.cartesianVelTarget);
527  common::debugEigenVec(datafields, "nullspaceVel", rtStatus.nullspaceVelocity);
528  common::debugEigenVec(datafields, "nullspaceTarget", rtData.desiredNullspaceJointAngles.value());
529  common::debugEigenVec(datafields, "desiredJointVel", rtStatus.desiredJointVelocity);
530  debugObs->setDebugChannel(getClassName() + "_" + arm->kinematicChainName, datafields);
531  }
532 
533  void
535  const SensorAndControl&,
537  const DebugObserverInterfacePrx& debugObs)
538  {
539  for (auto& pair : limb)
540  {
541  if (not pair.second->rtReady.load())
542  continue;
543  limbPublish(pair.second, debugObs);
544  }
545  }
546 
547  void
549  {
550  for (auto& pair : limb)
551  {
552  pair.second->rtReady.store(false);
553  }
554  }
555 
556  void
558  {
559  VirtualRobot::RobotNodeSetPtr rns = rtGetRobot()->getRobotNodeSet(arm->kinematicChainName);
560  Eigen::Matrix4f currentPose = rns->getTCP()->getPoseInRootFrame();
561  auto quat = VirtualRobot::MathTools::eigen4f2quat(currentPose);
562  ARMARX_RT_LOGF_INFO("rt preactivate controller with target pose\n\n "
563  "[ %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %.2f ].",
564  currentPose(0, 3),
565  currentPose(1, 3),
566  currentPose(2, 3),
567  quat.w,
568  quat.x,
569  quat.y,
570  quat.z);
571 
572  if (arm->reInitPreActivate.load())
573  {
574  arm->rtConfig.desiredNullspaceJointAngles.value() = rns->getJointValuesEigen();
575  arm->rtConfig.desiredPose = currentPose;
576 
577  arm->bufferConfigUserToNonRt.reinitAllBuffers(arm->rtConfig);
578  arm->reInitPreActivate.store(false);
579  }
580  {
581  arm->nonRtConfig = arm->rtConfig;
582  arm->bufferConfigNonRtToRt.reinitAllBuffers(arm->rtConfig);
583  arm->bufferConfigRtToOnPublish.reinitAllBuffers(arm->rtConfig);
584  arm->bufferConfigRtToUser.reinitAllBuffers(arm->rtConfig);
585  }
586  {
587  arm->sensorDevices.updateJointValues(
588  arm->rtStatus.jointPos, arm->rtStatus.jointVel, arm->rtStatus.jointTor);
589  arm->rtStatus.rtPreActivate(currentPose);
590 
591  arm->rtStatusInNonRT = arm->rtStatus;
592  arm->bufferRtStatusToOnPublish.reinitAllBuffers(arm->rtStatus);
593  arm->bufferRtStatusToNonRt.reinitAllBuffers(arm->rtStatus);
594  arm->bufferRtStatusToUser.reinitAllBuffers(arm->rtStatus);
595  }
596 
597  arm->controller.preactivateInit(rns);
598  }
599 
600  void
602  {
603  for (auto& pair : limb)
604  {
605  ARMARX_RT_LOGF_INFO("rtPreActivateController for %s", pair.first.c_str());
606  limbReInit(pair.second);
607  userConfig.limbs.at(pair.first) = pair.second->rtConfig;
608  }
609  if (hands)
610  {
611  hands->rtPreActivate();
612  }
613  }
614 
615  void
617  {
618  // for (auto& pair : limb)
619  // {
620  // pair.second->controller.isInitialized.store(false);
621  // }
622  }
623 
624  /// ----------------------------------- GUI Widget ---------------------------------------------
627  const VirtualRobot::RobotPtr& robot,
628  const std::map<std::string, ConstControlDevicePtr>& controlDevices,
629  const std::map<std::string, ConstSensorDevicePtr>&)
630  {
631  using namespace armarx::WidgetDescription;
632  HBoxLayoutPtr layout = new HBoxLayout;
633 
634 
635  ::armarx::WidgetDescription::WidgetSeq widgets;
636 
637  /// select default config
638  LabelPtr label = new Label;
639  label->text = "select a controller config";
640 
641  StringComboBoxPtr cfgBox = new StringComboBox;
642  cfgBox->name = "config_box";
643  cfgBox->defaultIndex = 0;
644  cfgBox->multiSelect = false;
645 
646  cfgBox->options = std::vector<std::string>{"default", "default_right", "default_right_a7"};
647  ARMARX_TRACE;
648 
649  layout->children.emplace_back(label);
650  layout->children.emplace_back(cfgBox);
651  ARMARX_TRACE;
652 
653  layout->children.insert(layout->children.end(), widgets.begin(), widgets.end());
654  ARMARX_INFO_S << "Layout done";
655  return layout;
656  }
657 
661  {
662  auto cfgName = values.at("config_box")->getString();
663  const armarx::PackagePath configPath(
664  "armarx_control",
665  "controller_config/NJointTaskspaceVelocityController/" + cfgName +
666  ".json");
667  ARMARX_INFO_S << "Loading config from " << configPath.toSystemPath();
668  ARMARX_CHECK(std::filesystem::exists(configPath.toSystemPath()));
669 
670  auto cfgDTO = armarx::readFromJson<ConfigDict>(configPath.toSystemPath());
671 
672  ARMARX_TRACE;
673  return new ConfigurableNJointControllerConfig{cfgDTO.toAronDTO()};
674  }
675 
676 } // namespace armarx::control::njoint_controller::task_space
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::isSafeForceTorque
bool isSafeForceTorque(const std::string &nodeSetName, const Ice::Current &iceCurrent=Ice::emptyCurrent) override
-----------------------------— Other interaces ----------------------------------------—
Definition: VelocityController.cpp:401
armarx::ControlTargetBase::asA
const T * asA() const
Definition: ControlTargetBase.h:76
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::updateConfig
void updateConfig(const ::armarx::aron::data::dto::DictPtr &dto, const Ice::Current &iceCurrent=Ice::emptyCurrent) override
NJointController interface.
Definition: VelocityController.cpp:329
ARMARX_RT_LOGF_INFO
#define ARMARX_RT_LOGF_INFO(...)
Definition: ControlThreadOutputBuffer.h:339
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::handleRTNotSafeInNonRT
void handleRTNotSafeInNonRT()
Definition: VelocityController.cpp:210
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::updateTargetPose
bool updateTargetPose(const TargetPoseMap &targetPoseMap, const TargetNullspaceMap &targetNullspaceMap, const Ice::Current &=Ice::emptyCurrent) override
Definition: VelocityController.cpp:433
SingleTypeVariantList.h
armarx::control::common::debugEigenPose
void debugEigenPose(StringVariantBaseMap &datafields, const std::string &name, Eigen::Matrix4f pose)
Definition: utils.cpp:113
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::limbReInit
void limbReInit(ArmPtr &arm)
Definition: VelocityController.cpp:557
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::NJointTaskspaceVelocityController::limbRTUpdateStatus
void limbRTUpdateStatus(ArmPtr &arm, const double deltaT)
-----------------------------— Real time cotnrol --------------------------------------—
Definition: VelocityController.cpp:231
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::control::njoint_controller::task_space::NJointTaskspaceVelocityController::onInitNJointController
void onInitNJointController() override
NJointControllerBase interface.
Definition: VelocityController.cpp:134
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::limbNonRT
void limbNonRT(ArmPtr &arm)
Definition: VelocityController.cpp:160
armarx::SensorValueBase
The SensorValueBase class.
Definition: SensorValueBase.h:40
armarx::control::njoint_controller::task_space::registrationControllerNJointTaskspaceVelocityController
NJointControllerRegistration< NJointTaskspaceVelocityController > registrationControllerNJointTaskspaceVelocityController("NJointTaskspaceVelocityController")
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::additionalTaskUpdateStatus
bool additionalTaskUpdateStatus()
Definition: VelocityController.cpp:178
armarx::ControlTargetBase
Brief description of class JointControlTargetBase.
Definition: ControlTargetBase.h:47
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::rtPostDeactivateController
void rtPostDeactivateController() override
This function is called after the controller is deactivated.
Definition: VelocityController.cpp:616
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::limbRTSetTarget
void limbRTSetTarget(ArmPtr &arm, const Eigen::VectorXf &targetVelocity)
Definition: VelocityController.cpp:252
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
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::control::njoint_controller::task_space::NJointTaskspaceVelocityController::additionalTaskSetTarget
void additionalTaskSetTarget()
Definition: VelocityController.cpp:197
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::NJointTaskspaceVelocityController::enableSafeGuardForceTorque
void enableSafeGuardForceTorque(const std::string &nodeSetName, const bool forceGuard, const bool torqueGuard, const Ice::Current &iceCurrent=Ice::emptyCurrent) override
Definition: VelocityController.cpp:374
ProsthesisInterface.values
values
Definition: ProsthesisInterface.py:190
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:43
armarx::NJointControllerBase::ConfigPtrT
NJointControllerConfigPtr ConfigPtrT
Definition: NJointControllerBase.h:586
aron_conversions.h
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::NJointTaskspaceVelocityController
NJointTaskspaceVelocityController(const RobotUnitPtr &robotUnit, const NJointControllerConfigPtr &config, const VirtualRobot::RobotPtr &)
Definition: VelocityController.cpp:86
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::NJointTaskspaceVelocityController::robotUnit
RobotUnitPtr robotUnit
Definition: VelocityController.h:162
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::rtPreActivateController
void rtPreActivateController() override
This function is called before the controller is activated.
Definition: VelocityController.cpp:601
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::ArmPtr
std::unique_ptr< ArmData > ArmPtr
Definition: VelocityController.h:97
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::limbInit
void limbInit(const std::string nodeSetName, ArmPtr &arm, Config &cfg, VirtualRobot::RobotPtr &nonRtRobotPtr)
Definition: VelocityController.cpp:44
ARMARX_CHECK
#define ARMARX_CHECK(expression)
Shortcut for ARMARX_CHECK_EXPRESSION.
Definition: ExpressionException.h:82
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::limbRT
void limbRT(ArmPtr &arm, const double deltaT)
Definition: VelocityController.cpp:281
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::GenerateConfigDescription
static WidgetDescription::WidgetPtr GenerateConfigDescription(const VirtualRobot::RobotPtr &, const std::map< std::string, ConstControlDevicePtr > &, const std::map< std::string, ConstSensorDevicePtr > &)
--------------------------------— GUI Widget ------------------------------------------—
Definition: VelocityController.cpp:626
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_TRACE
#define ARMARX_TRACE
Definition: trace.h:69
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::userConfig
ConfigDict userConfig
Definition: VelocityController.h:163
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::control::njoint_controller::task_space::NJointTaskspaceVelocityController::rtRun
void rtRun(const IceUtil::Time &sensorValuesTimestamp, const IceUtil::Time &timeSinceLastIteration) override
TODO make protected and use attorneys.
Definition: VelocityController.cpp:311
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::NJointTaskspaceVelocityController::onPublish
void onPublish(const SensorAndControl &, const DebugDrawerInterfacePrx &, const DebugObserverInterfacePrx &) override
Definition: VelocityController.cpp:534
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::ConfigPtrT
ConfigurableNJointControllerConfigPtr ConfigPtrT
Definition: VelocityController.h:56
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::nonRtRobot
VirtualRobot::RobotPtr nonRtRobot
Definition: VelocityController.h:161
ArmarXObjectScheduler.h
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::limbPublish
void limbPublish(ArmPtr &arm, const DebugObserverInterfacePrx &debugObs)
Definition: VelocityController.cpp:510
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::NJointTaskspaceVelocityController::GenerateConfigFromVariants
static ConfigPtrT GenerateConfigFromVariants(const StringVariantBaseMap &values)
Definition: VelocityController.cpp:659
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::getTCPVel
Ice::FloatSeq getTCPVel(const std::string &rns, const Ice::Current &iceCurrent=Ice::emptyCurrent) override
Definition: VelocityController.cpp:419
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::control::njoint_controller::task_space::NJointTaskspaceVelocityController::additionalTask
virtual void additionalTask()
Definition: VelocityController.cpp:167
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::getClassName
std::string getClassName(const Ice::Current &=Ice::emptyCurrent) const override
Definition: VelocityController.cpp:128
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::getConfig
::armarx::aron::data::dto::DictPtr getConfig(const Ice::Current &iceCurrent=Ice::emptyCurrent) override
Definition: VelocityController.cpp:359
armarx::aron::data::DictPtr
std::shared_ptr< Dict > DictPtr
Definition: Dict.h:41
armarx::ctrlutil::v
double v(double t, double v0, double a0, double j)
Definition: CtrlUtil.h:39
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::Config
law::TaskspaceVelocityController::Config Config
Definition: VelocityController.h:57
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::NJointTaskspaceVelocityController::limb
std::map< std::string, ArmPtr > limb
Definition: VelocityController.h:160
TimeUtil.h
ARMARX_INFO
#define ARMARX_INFO
Definition: Logging.h:174
VAROUT
#define VAROUT(x)
Definition: StringHelpers.h:182
IceInternal::ProxyHandle<::IceProxy::armarx::DebugObserverInterface >
armarx::control::TargetPoseMap
dictionary< string, FloatSeqSeq > TargetPoseMap
Definition: ControllerInterface.ice:39
armarx::control::NJointTaskspaceVelocityControllerInterface::calibrateFTSensor
void calibrateFTSensor()
ft sensor
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::hands
core::HandControlPtr hands
Definition: VelocityController.h:164
VelocityController.h
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_RT_LOGF_WARN
#define ARMARX_RT_LOGF_WARN(...)
Definition: ControlThreadOutputBuffer.h:345
armarx::PackagePath
Definition: PackagePath.h:55
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::controllableNodeSets
std::map< std::string, VirtualRobot::RobotNodeSetPtr > controllableNodeSets
Definition: VelocityController.h:165
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::validateConfigData
void validateConfigData(Config &config, ArmPtr &arm)
Definition: VelocityController.cpp:465
armarx::ctrlutil::s
double s(double t, double s0, double v0, double a0, double j)
Definition: CtrlUtil.h:33
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