ZeroTorqueOrVelocityController.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 
24 
25 #include <VirtualRobot/MathTools.h>
26 
32 
35 
37 {
38  NJointControllerRegistration<NJointTaskspaceZeroTorqueOrVelocityController>
40  "NJointTaskspaceZeroTorqueOrVelocityController");
41 
42  void
44  ArmPtr& arm,
45  Config cfg,
46  VirtualRobot::RobotPtr& nonRtRobotPtr)
47  {
48  arm->kinematicChainName = nodeSetName;
49  VirtualRobot::RobotNodeSetPtr rtRns =
50  rtGetRobot()->getRobotNodeSet(arm->kinematicChainName);
51  VirtualRobot::RobotNodeSetPtr nonRtRns =
52  nonRtRobotPtr->getRobotNodeSet(arm->kinematicChainName);
53  ARMARX_CHECK_EXPRESSION(rtRns) << arm->kinematicChainName;
54  ARMARX_CHECK_EXPRESSION(nonRtRns) << arm->kinematicChainName;
56  << "Creating Taskspace Zero Torque or Velocity Controller with kinematic chain: "
57  << arm->kinematicChainName << " with num of joints: (RT robot) " << rtRns->getSize()
58  << ", and (non-RT robot) " << nonRtRns->getSize();
59 
60  std::vector<size_t> jointIDTorqueMode;
61  std::vector<size_t> jointIDVelocityMode;
62  arm->jointNames.clear();
63  for (size_t i = 0; i < rtRns->getSize(); ++i)
64  {
65 
66  std::string jointName = rtRns->getNode(i)->getName();
67  arm->jointNames.push_back(jointName);
68 
69  bool foundControlDevice = false;
70  auto it = std::find(
71  cfg.jointNameListTorque.begin(), cfg.jointNameListTorque.end(), jointName);
72  if (it != cfg.jointNameListTorque.end())
73  {
74  ControlTargetBase* ct = useControlTarget(jointName, ControlModes::ZeroTorque1DoF);
76  auto* casted_ct = ct->asA<ControlTarget1DoFActuatorZeroTorque>();
77  ARMARX_CHECK_EXPRESSION(casted_ct);
78  arm->targetsTorque.push_back(casted_ct);
79  jointIDTorqueMode.push_back(i);
80  foundControlDevice = true;
81  }
82 
83  it = std::find(
84  cfg.jointNameListVelocity.begin(), cfg.jointNameListVelocity.end(), jointName);
85  if (it != cfg.jointNameListVelocity.end())
86  {
87  ControlTargetBase* ct = useControlTarget(jointName, ControlModes::ZeroVelocity1DoF);
89  auto* casted_ct = ct->asA<ControlTarget1DoFActuatorZeroVelocity>();
90  ARMARX_CHECK_EXPRESSION(casted_ct);
91  arm->targetsVel.push_back(casted_ct);
92  jointIDVelocityMode.push_back(i);
93  foundControlDevice = true;
94  }
95  if (not foundControlDevice)
96  {
97  ARMARX_INFO << jointName << " is not selected for " << arm->kinematicChainName;
98  }
99  auto namesTorque = armarx::control::common::sVecToString(cfg.jointNameListTorque);
100  auto namesVelocity = armarx::control::common::sVecToString(cfg.jointNameListVelocity);
101  ARMARX_INFO << "Robot node set '" << arm->kinematicChainName
102  << "' has torque controlled joints [" << namesTorque
103  << "] and velocity controlled joints [" << namesVelocity << "].";
104 
105  const SensorValueBase* sv = useSensorValue(jointName);
107  const auto* torqueSensor = sv->asA<SensorValue1DoFActuatorTorque>();
108  const auto* velocitySensor = sv->asA<SensorValue1DoFActuatorVelocity>();
109  const auto* positionSensor = sv->asA<SensorValue1DoFActuatorPosition>();
110 
111  if (torqueSensor == nullptr)
112  {
113  ARMARX_WARNING << "No Torque sensor available for " << jointName;
114  }
115  if (velocitySensor == nullptr)
116  {
117  ARMARX_WARNING << "No velocity sensor available for " << jointName;
118  }
119  if (positionSensor == nullptr)
120  {
121  ARMARX_WARNING << "No position sensor available for " << jointName;
122  }
123 
124 
125  arm->sensorDevices.torqueSensors.push_back(torqueSensor);
126  arm->sensorDevices.velocitySensors.push_back(velocitySensor);
127  arm->sensorDevices.positionSensors.push_back(positionSensor);
128  };
129  ARMARX_DEBUG << "Number of torque controlled joints " << jointIDTorqueMode.size();
130  ARMARX_DEBUG << "Number of velocity controlled joints " << jointIDVelocityMode.size();
131  // ARMARX_CHECK_EQUAL(rtRns->getNodeNames().size(),
132  // jointIDTorqueMode.size() + jointIDVelocityMode.size());
133 
134  arm->controller.initialize(nonRtRns, rtRns, jointIDTorqueMode, jointIDVelocityMode);
135  arm->controller.ftsensor.initialize(rtRns, robotUnit, cfg.ftConfig);
136 
137  validateConfigData(cfg, arm);
138  arm->rtConfig = cfg;
139  arm->nonRtConfig = cfg;
140  }
141 
143  const RobotUnitPtr& robotUnit,
144  const NJointControllerConfigPtr& config,
145  const VirtualRobot::RobotPtr&) :
146  robotUnit(robotUnit)
147  {
149 
150  ConfigPtrT cfg = ConfigPtrT::dynamicCast(config);
152  userConfig = ::armarx::fromAronDict<ConfigDict, ConfigDict>(cfg->config);
153 
155  nonRtRobot = robotUnit->cloneRobot();
156  robotUnit->updateVirtualRobot(nonRtRobot);
157 
158  for (auto& pair : userConfig.limbs)
159  {
160  limb.emplace(pair.first, std::make_unique<ArmData>());
161  limbInit(pair.first, limb.at(pair.first), pair.second, nonRtRobot);
162  }
163  }
164 
165  std::string
167  {
168  return "NJointTaskspaceZeroTorqueOrVelocityController";
169  }
170 
171  void
173  {
174  }
175 
176  void
178  {
179  double timeMeasure = IceUtil::Time::now().toMicroSecondsDouble();
180  arm->rtConfig = arm->bufferNonRtToRt.getUpToDateReadBuffer();
181  double time_update_non_rt_buffer =
182  IceUtil::Time::now().toMicroSecondsDouble() - timeMeasure;
183 
184  if (arm->rtFirstRun.load())
185  {
186  arm->rtFirstRun.store(false);
187  arm->rtReady.store(true);
188  }
189  arm->controller.ftsensor.updateStatus(
190  arm->rtConfig.ftConfig, arm->rtStatus.currentForceTorque, arm->rtStatus.deltaT, arm->rtFirstRun.load());
191 
192  double time_update_ft = IceUtil::Time::now().toMicroSecondsDouble() - timeMeasure;
193 
194  size_t nDoF = arm->sensorDevices.positionSensors.size();
195  double time_update_size = IceUtil::Time::now().toMicroSecondsDouble() - timeMeasure;
196  for (size_t i = 0; i < nDoF; ++i)
197  {
198  arm->rtStatus.jointPosition[i] = arm->sensorDevices.positionSensors[i]->position;
199  arm->rtStatus.jointVelocity[i] = arm->sensorDevices.velocitySensors[i]->velocity;
200  arm->rtStatus.jointTorque[i] = arm->sensorDevices.torqueSensors[i]->torque;
201  }
202 
203  double time_update_js = IceUtil::Time::now().toMicroSecondsDouble() - timeMeasure;
204  arm->rtStatus.deltaT = deltaT;
205  double time_update_rt_status = IceUtil::Time::now().toMicroSecondsDouble() - timeMeasure;
206 
207  arm->bufferRtToNonRt.getWriteBuffer() = arm->rtStatus;
208  arm->bufferRtToNonRt.commitWrite();
209  arm->bufferRtStatusToUser.getWriteBuffer() = arm->rtStatus;
210  arm->bufferRtStatusToUser.commitWrite();
211  double time_write_rt_buffer = IceUtil::Time::now().toMicroSecondsDouble() - timeMeasure;
212 
213  arm->controller.run(arm->rtConfig, arm->rtStatus);
214  double time_run_rt = IceUtil::Time::now().toMicroSecondsDouble() - timeMeasure;
215 
216  for (unsigned int i = 0; i < arm->rtStatus.nDoFTorque; i++)
217  {
218  auto jointIdx = arm->controller.jointIDTorqueMode[i];
219  arm->targetsTorque.at(i)->torque = arm->rtStatus.desiredJointTorques(jointIdx);
220  if (!arm->targetsTorque.at(i)->isValid())
221  {
222  arm->targetsTorque.at(i)->torque = 0;
223  }
224  }
225  for (unsigned int i = 0; i < arm->rtStatus.nDoFVelocity; i++)
226  {
227  auto jointIdx = arm->controller.jointIDVelocityMode[i];
228  arm->targetsVel.at(i)->velocity = arm->rtStatus.desiredJointVelocity(jointIdx);
229  // if (!targets.at(i)->isValid() || fabs(targets.at(i)->velocity) > cfg->maxJointVelocity)
230  if (!arm->targetsVel.at(i)->isValid())
231  {
232  arm->targetsVel.at(i)->velocity = 0;
233  }
234  }
235  arm->bufferRtStatusToOnPublish.getWriteBuffer() = arm->rtStatus;
236  arm->bufferRtStatusToOnPublish.commitWrite();
237 
238  arm->bufferRtConfigToOnPublish.getWriteBuffer() = arm->rtConfig;
239  arm->bufferRtConfigToOnPublish.commitWrite();
240 
241  arm->bufferRtConfigToUser.getWriteBuffer() = arm->rtConfig;
242  arm->bufferRtConfigToUser.commitWrite();
243  double time_rt_status_buffer = IceUtil::Time::now().toMicroSecondsDouble() - timeMeasure;
244  timeMeasure = IceUtil::Time::now().toMicroSecondsDouble() - timeMeasure;
245 
246  if (timeMeasure > 100)
247  {
248  ARMARX_RT_LOGF_WARN("---- rt too slow: unit in (us)"
249  "update_non_rt_buffer: %.2f\n"
250  "update_ft: %.2f\n"
251  "update_size: %.2f\n"
252  "update_js: %.2f\n"
253  "update_rt_status: %.2f\n"
254  "write_rt_buffer: %.2f\n"
255  "run_rt: %.2f\n"
256  "rt_status_buffer: %.2f\n"
257  "time all: %.2f\n",
258  time_update_non_rt_buffer, // 0-1 us
259  time_update_ft - time_update_non_rt_buffer, //
260  time_update_size - time_update_ft, //
261  time_update_js - time_update_size, //
262  time_update_rt_status - time_update_non_rt_buffer, // 1-2 us
263  time_write_rt_buffer - time_update_rt_status, // 0-1 us
264  time_run_rt - time_write_rt_buffer, // 26-33 us
265  time_rt_status_buffer - time_run_rt,
266  timeMeasure); // 0-1 us
267  }
268  }
269 
270  void
272  const IceUtil::Time& /*sensorValuesTimestamp*/,
273  const IceUtil::Time& timeSinceLastIteration)
274  {
275  double deltaT = timeSinceLastIteration.toSecondsDouble();
276  for (auto& pair : limb)
277  {
278  limbRT(pair.second, deltaT);
279  }
280  }
281 
282  void
285  const Ice::Current& iceCurrent)
286  {
287  userConfig = userConfig.FromAron(dto);
288  // userConfig = ::armarx::fromAronDict<ConfigDict, ConfigDict>(dto);
289 
290  for (auto& pair : userConfig.limbs)
291  {
292  validateConfigData(pair.second, limb.at(pair.first));
293  limb.at(pair.first)->bufferUserToNonRt.getWriteBuffer() = pair.second;
294  limb.at(pair.first)->bufferUserToNonRt.commitWrite();
295  }
296  }
297 
300  {
301  for (auto& pair : limb)
302  {
303  userConfig.limbs.at(pair.first) =
304  pair.second->bufferRtConfigToUser.getUpToDateReadBuffer();
305  }
306  return userConfig.toAronDTO();
307  }
308 
309  void
311  ArmPtr& arm)
312  {
313  const auto checkNonNegative = [](const auto& v) { ARMARX_CHECK(v >= 0); };
314  const auto checkVecNonNegative = [](const auto& v)
315  { ARMARX_CHECK((v.array() >= 0).all()); };
316 
317  checkVecNonNegative(configData.kpCartesianVel);
318  checkVecNonNegative(configData.kdCartesianVel);
319 
320  checkNonNegative(configData.torqueLimit);
321  checkNonNegative(configData.velocityLimit);
322  checkNonNegative(configData.qvelFilter);
323  checkNonNegative(configData.cartesianLinearVelLimit);
324  checkNonNegative(configData.cartesianAngularVelLimit);
325  }
326 
327  void
329  ArmPtr& arm,
330  const DebugObserverInterfacePrx& debugObs)
331  {
332  StringVariantBaseMap datafields;
333  auto rtConfig = arm->bufferRtConfigToOnPublish.getUpToDateReadBuffer();
334  auto rtStatus = arm->bufferRtStatusToOnPublish.getUpToDateReadBuffer();
335 
336  // datafields[name + "_x"] = new Variant(pose(0, 3));
337 
338  common::debugEigenVec(datafields, "cartesianVelTarget", rtStatus.cartesianVelTarget);
339  datafields["velocityLimit"] = new Variant(rtConfig.velocityLimit);
340  common::debugEigenVec(datafields, "desiredJointVelocity", rtStatus.desiredJointVelocity);
341  common::debugEigenVec(datafields, "currentForceTorque", rtStatus.currentForceTorque);
342  debugObs->setDebugChannel("ZT-ZV_" + arm->kinematicChainName, datafields);
343  }
344 
345  void
347  const SensorAndControl&,
349  const DebugObserverInterfacePrx& debugObs)
350  {
351  for (auto& pair : limb)
352  {
353  limbPublish(pair.second, debugObs);
354  }
355  }
356 
357  void
359  {
360  for (auto& pair : limb)
361  {
362  pair.second->rtReady.store(false);
363  }
364  }
365 
366  void
368  {
369  VirtualRobot::RobotNodeSetPtr rns = rtGetRobot()->getRobotNodeSet(arm->kinematicChainName);
370 
371  arm->bufferUserToNonRt.reinitAllBuffers(arm->rtConfig);
372  {
373  arm->nonRtConfig = arm->rtConfig;
374  arm->bufferNonRtToRt.reinitAllBuffers(arm->rtConfig);
375  arm->bufferRtConfigToOnPublish.reinitAllBuffers(arm->rtConfig);
376  arm->bufferRtConfigToUser.reinitAllBuffers(arm->rtConfig);
377  }
378 
379  const auto nDoF = rns->getSize();
380  const auto nDoFTorque = arm->controller.jointIDTorqueMode.size();
381  const auto nDoFVelocity = arm->controller.jointIDVelocityMode.size();
382  {
383  arm->rtStatus.nDoFTorque = nDoFTorque;
384  arm->rtStatus.nDoFVelocity = nDoFVelocity;
385  arm->rtStatus.numJoints = nDoF;
386  arm->rtStatus.desiredJointTorques.setZero(nDoF);
387  arm->rtStatus.desiredJointVelocity.setZero(nDoF);
388  arm->rtStatus.cartesianVelTarget.setZero();
389 
390  arm->rtStatus.jointPosition.resize(nDoF, 0.);
391  arm->rtStatus.jointVelocity.resize(nDoF, 0.);
392  arm->rtStatus.jointTorque.resize(nDoF, 0.);
393  for (size_t i = 0; i < nDoF; ++i)
394  {
395  arm->rtStatus.jointPosition[i] = arm->sensorDevices.positionSensors[i]->position;
396  arm->rtStatus.jointVelocity[i] = arm->sensorDevices.velocitySensors[i]->velocity;
397  arm->rtStatus.jointTorque[i] = arm->sensorDevices.torqueSensors[i]->torque;
398  }
399 
400  arm->rtStatus.qpos = rns->getJointValuesEigen();
401  arm->rtStatus.qvel.setZero(nDoF);
402  arm->rtStatus.qvelFiltered.setZero(nDoF);
403 
404  arm->rtStatus.currentTwist.setZero();
405  arm->rtStatus.jacobi.setZero(6, nDoF);
406 
407  arm->rtStatus.deltaT = 0.0;
408  arm->rtStatus.rtSafe = false;
409 
410  arm->rtStatus.currentForceTorque.setZero();
411 
412  arm->rtStatusInNonRT = arm->rtStatus;
413  arm->bufferRtStatusToOnPublish.reinitAllBuffers(arm->rtStatus);
414  arm->bufferRtToNonRt.reinitAllBuffers(arm->rtStatus);
415  arm->bufferRtStatusToUser.reinitAllBuffers(arm->rtStatus);
416  }
417 
418  arm->controller.preactivateInit(rns);
419  }
420 
421  void
423  {
424  for (auto& pair : limb)
425  {
426  ARMARX_INFO << "rtPreActivateController for " << pair.first;
427  limbReInit(pair.second);
428  userConfig.limbs.at(pair.first) = pair.second->rtConfig;
429  }
430  }
431 
432  void
434  {
435  // for (auto& pair : limb)
436  // {
437  // pair.second->controller.isInitialized.store(false);
438  // }
439  }
440 
443  const VirtualRobot::RobotPtr& robot,
444  const std::map<std::string, ConstControlDevicePtr>& controlDevices,
445  const std::map<std::string, ConstSensorDevicePtr>&)
446  {
447  using namespace armarx::WidgetDescription;
448  HBoxLayoutPtr layout = new HBoxLayout;
449 
450 
451  ::armarx::WidgetDescription::WidgetSeq widgets;
452  auto addSlider = [&](const std::string& label, float min, float max, float defaultValue)
453  {
454  widgets.emplace_back(new Label(false, label));
455  {
456  FloatSliderPtr c_x = new FloatSlider;
457  c_x->name = label;
458  c_x->min = min;
459  c_x->defaultValue = defaultValue;
460  c_x->max = max;
461  widgets.emplace_back(c_x);
462  }
463  };
464 
465  /// zero torque mode
466  LabelPtr label = new Label;
467  label->text = "ZeroTorque (L/R)";
468 
469  StringComboBoxPtr boxZeroTorqueLeft = new StringComboBox;
470  boxZeroTorqueLeft->name = "ZeroTorqueLeft";
471  boxZeroTorqueLeft->defaultIndex = 0;
472  boxZeroTorqueLeft->multiSelect = true;
473 
474  StringComboBoxPtr boxZeroTorqueRight = new StringComboBox;
475  boxZeroTorqueRight->name = "ZeroTorqueRight";
476  boxZeroTorqueRight->defaultIndex = 0;
477  boxZeroTorqueRight->multiSelect = true;
478 
479  /// zero velocity mode
480  LabelPtr labelZVMode = new Label;
481  labelZVMode->text = "ZeroVelocity (L/R)";
482 
483  StringComboBoxPtr boxZeroVelocityLeft = new StringComboBox;
484  boxZeroVelocityLeft->name = "ZeroVelocityLeft";
485  boxZeroVelocityLeft->defaultIndex = 0;
486  boxZeroVelocityLeft->multiSelect = true;
487 
488  StringComboBoxPtr boxZeroVelocityRight = new StringComboBox;
489  boxZeroVelocityRight->name = "ZeroVelocityRight";
490  boxZeroVelocityRight->defaultIndex = 0;
491  boxZeroVelocityRight->multiSelect = true;
492 
493  ARMARX_INFO_S << "Building check boxes";
494  ARMARX_TRACE;
495  std::map<std::string, StringComboBoxPtr> boxes;
496  boxes.insert({"zv_left", boxZeroVelocityLeft});
497  boxes.insert({"zv_right", boxZeroVelocityRight});
498  boxes.insert({"zt_left", boxZeroTorqueLeft});
499  boxes.insert({"zt_right", boxZeroTorqueRight});
500 
501  ARMARX_TRACE;
502  for (auto& c : controlDevices)
503  {
504  std::string mode;
505  if (c.first.find("ArmL") != std::string::npos)
506  {
507  mode = "left";
508  }
509  else if (c.first.find("ArmR") != std::string::npos)
510  {
511  mode = "right";
512  }
513  else
514  {
515  continue;
516  }
517 
518  if (c.second->hasJointController(ControlModes::ZeroTorque1DoF))
519  {
520  boxes.at("zt_" + mode)->options.push_back(c.first);
521  }
522  else if (c.second->hasJointController(ControlModes::ZeroVelocity1DoF))
523  {
524  boxes.at("zv_" + mode)->options.push_back(c.first);
525  }
526  }
527  ARMARX_TRACE;
528 
529  layout->children.emplace_back(label);
530  layout->children.emplace_back(boxZeroTorqueLeft);
531  layout->children.emplace_back(boxZeroTorqueRight);
532  layout->children.emplace_back(labelZVMode);
533  layout->children.emplace_back(boxZeroVelocityLeft);
534  layout->children.emplace_back(boxZeroVelocityRight);
535 
536  addSlider("maxTorque", 0, 100, 10);
537  addSlider("maxVeloicty", 0, 3.14, 2.0);
538  ARMARX_TRACE;
539 
540  layout->children.insert(layout->children.end(), widgets.begin(), widgets.end());
541  ARMARX_INFO_S << "Layout done";
542  return layout;
543  }
544 
548  {
549  const armarx::PackagePath configPath(
550  "armarx_control",
551  "controller_config/NJointTaskspaceZeroTorqueOrVelocityController/default.json");
552  ARMARX_INFO_S << "Loading config from " << configPath.toSystemPath();
553  auto cfgDTO = armarx::readFromJson<ConfigDict>(configPath.toSystemPath());
554 
555  ARMARX_WARNING_S << "Left arm of armar7 is not yet calibrated, the default is set to "
556  "RightArm for safety reason!";
557 
558  auto varZTLeft = VariantPtr::dynamicCast(values.at("ZeroTorqueLeft"));
559  auto varZTRight = VariantPtr::dynamicCast(values.at("ZeroTorqueRight"));
560  auto varZVLeft = VariantPtr::dynamicCast(values.at("ZeroVelocityLeft"));
561  auto varZVRight = VariantPtr::dynamicCast(values.at("ZeroVelocityRight"));
562  ARMARX_CHECK_EXPRESSION(varZTLeft) << "ZeroTorqueLeft";
563  ARMARX_CHECK_EXPRESSION(varZTRight) << "ZeroTorqueRight";
564  ARMARX_CHECK_EXPRESSION(varZVLeft) << "ZeroVelocityLeft";
565  ARMARX_CHECK_EXPRESSION(varZVRight) << "ZeroVelocityRight";
566 
567  cfgDTO.limbs.at("RightArm").jointNameListTorque =
568  varZTRight->get<SingleTypeVariantList>()->toStdVector<std::string>();
569  cfgDTO.limbs.at("RightArm").jointNameListVelocity =
570  varZVRight->get<SingleTypeVariantList>()->toStdVector<std::string>();
571  cfgDTO.limbs.at("RightArm").torqueLimit = values.at("maxTorque")->getFloat();
572  cfgDTO.limbs.at("RightArm").velocityLimit = values.at("maxVeloicty")->getFloat();
573 
574  auto namesTorque =
575  armarx::control::common::sVecToString(cfgDTO.limbs.at("RightArm").jointNameListTorque);
576  auto namesVelocity =
577  armarx::control::common::sVecToString(cfgDTO.limbs.at("RightArm").jointNameListVelocity);
578  if (cfgDTO.limbs.at("RightArm").jointNameListTorque.size() > 0)
579  {
580  ARMARX_INFO_S << "'RightArm' has torque controlled joints [" << namesTorque << "].";
581  }
582  if (cfgDTO.limbs.at("RightArm").jointNameListVelocity.size() > 0)
583  {
584  ARMARX_INFO_S << "'RightArm' has velocity controlled joints [" << namesVelocity << "].";
585  }
586 
587  ARMARX_INFO_S << "torque limit: " << cfgDTO.limbs.at("RightArm").torqueLimit
588  << "velocity limit: " << cfgDTO.limbs.at("RightArm").velocityLimit;
589 
590  ARMARX_TRACE;
591  return new ConfigurableNJointControllerConfig{cfgDTO.toAronDTO()};
592  }
593 } // namespace armarx::control::njoint_controller::task_space
armarx::control::njoint_controller::task_space::NJointTaskspaceZeroTorqueOrVelocityController::rtPreActivateController
void rtPreActivateController() override
This function is called before the controller is activated.
Definition: ZeroTorqueOrVelocityController.cpp:422
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::control::njoint_controller::task_space::NJointTaskspaceZeroTorqueOrVelocityController::getClassName
std::string getClassName(const Ice::Current &) const override
Definition: ZeroTorqueOrVelocityController.cpp:166
SingleTypeVariantList.h
armarx::control::njoint_controller::task_space::NJointTaskspaceZeroTorqueOrVelocityController::rtPostDeactivateController
void rtPostDeactivateController() override
This function is called after the controller is deactivated.
Definition: ZeroTorqueOrVelocityController.cpp:433
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::asA
const T * asA() const
Definition: SensorValueBase.h:82
armarx::SensorValueBase
The SensorValueBase class.
Definition: SensorValueBase.h:40
armarx::ControlTargetBase
Brief description of class JointControlTargetBase.
Definition: ControlTargetBase.h:47
armarx::control::njoint_controller::task_space::NJointTaskspaceZeroTorqueOrVelocityController::robotUnit
RobotUnitPtr robotUnit
Definition: ZeroTorqueOrVelocityController.h:145
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::njoint_controller::task_space
Definition: AdmittanceController.cpp:37
armarx::max
std::vector< T > max(const std::vector< T > &v1, const std::vector< T > &v2)
Definition: VectorHelpers.h:267
ProsthesisInterface.values
values
Definition: ProsthesisInterface.py:190
armarx::control::njoint_controller::task_space::NJointTaskspaceZeroTorqueOrVelocityController::getConfig
::armarx::aron::data::dto::DictPtr getConfig(const Ice::Current &iceCurrent=Ice::emptyCurrent) override
Definition: ZeroTorqueOrVelocityController.cpp:299
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:43
armarx::control::njoint_controller::task_space::NJointTaskspaceZeroTorqueOrVelocityController::limbRT
void limbRT(ArmPtr &arm, const double deltaT)
Definition: ZeroTorqueOrVelocityController.cpp:177
armarx::NJointControllerBase::ConfigPtrT
NJointControllerConfigPtr ConfigPtrT
Definition: NJointControllerBase.h:586
aron_conversions.h
armarx::control::njoint_controller::task_space::registrationControllerNJointTaskspaceZeroTorqueOrVelocityController
NJointControllerRegistration< NJointTaskspaceZeroTorqueOrVelocityController > registrationControllerNJointTaskspaceZeroTorqueOrVelocityController("NJointTaskspaceZeroTorqueOrVelocityController")
ARMARX_CHECK
#define ARMARX_CHECK(expression)
Shortcut for ARMARX_CHECK_EXPRESSION.
Definition: ExpressionException.h:82
armarx::control::njoint_controller::task_space::NJointTaskspaceZeroTorqueOrVelocityController::limbReInit
void limbReInit(ArmPtr &arm)
Definition: ZeroTorqueOrVelocityController.cpp:367
IceInternal::Handle
Definition: forward_declarations.h:8
armarx::NJointControllerBase::rtGetRobot
const VirtualRobot::RobotPtr & rtGetRobot()
TODO make protected and use attorneys.
Definition: NJointControllerBase.h:845
ZeroTorqueOrVelocityController.h
armarx::detail::ControlThreadOutputBufferEntry
Definition: ControlThreadOutputBuffer.h:177
armarx::control::njoint_controller::task_space::NJointTaskspaceZeroTorqueOrVelocityController::ArmPtr
std::unique_ptr< ArmData > ArmPtr
Definition: ZeroTorqueOrVelocityController.h:99
visionx::voxelgrid::Label
uint32_t Label
Type of an object label.
Definition: types.h:7
armarx::WidgetDescription
Definition: DefaultWidgetDescriptions.cpp:27
ARMARX_TRACE
#define ARMARX_TRACE
Definition: trace.h:69
armarx::control::njoint_controller::task_space::NJointTaskspaceZeroTorqueOrVelocityController::rtRun
void rtRun(const IceUtil::Time &sensorValuesTimestamp, const IceUtil::Time &timeSinceLastIteration) override
TODO make protected and use attorneys.
Definition: ZeroTorqueOrVelocityController.cpp:271
armarx::RemoteGui::Client::FloatSlider
Definition: Widgets.h:107
armarx::PackagePath::toSystemPath
static std::filesystem::path toSystemPath(const data::PackagePath &pp)
Definition: PackagePath.cpp:54
ARMARX_DEBUG
#define ARMARX_DEBUG
Definition: Logging.h:177
armarx::control::NJointTaskspaceZeroTorqueOrVelocityControllerInterface::calibrateFTSensor
void calibrateFTSensor()
armarx::SingleTypeVariantList
The SingleTypeVariantList class is a subclass of VariantContainer and is comparable to a std::vector<...
Definition: SingleTypeVariantList.h:47
armarx::control::njoint_controller::task_space::NJointTaskspaceZeroTorqueOrVelocityController::limb
std::map< std::string, ArmPtr > limb
Definition: ZeroTorqueOrVelocityController.h:143
armarx::control::njoint_controller::task_space::NJointTaskspaceZeroTorqueOrVelocityController::nonRtRobot
VirtualRobot::RobotPtr nonRtRobot
Definition: ZeroTorqueOrVelocityController.h:144
armarx::control::njoint_controller::task_space::NJointTaskspaceZeroTorqueOrVelocityController::limbInit
void limbInit(const std::string nodeSetName, ArmPtr &arm, Config cfg, VirtualRobot::RobotPtr &nonRtRobotPtr)
Definition: ZeroTorqueOrVelocityController.cpp:43
armarx::control::njoint_controller::task_space::NJointTaskspaceZeroTorqueOrVelocityController::userConfig
ConfigDict userConfig
Definition: ZeroTorqueOrVelocityController.h:146
armarx::control::njoint_controller::task_space::NJointTaskspaceZeroTorqueOrVelocityController::GenerateConfigDescription
static WidgetDescription::WidgetPtr GenerateConfigDescription(const VirtualRobot::RobotPtr &, const std::map< std::string, ConstControlDevicePtr > &, const std::map< std::string, ConstSensorDevicePtr > &)
Definition: ZeroTorqueOrVelocityController.cpp:442
ArmarXObjectScheduler.h
ARMARX_WARNING_S
#define ARMARX_WARNING_S
Definition: Logging.h:206
armarx::armem::Time
armarx::core::time::DateTime Time
Definition: forward_declarations.h:13
armarx::control::njoint_controller::task_space::NJointTaskspaceZeroTorqueOrVelocityController::onPublish
void onPublish(const SensorAndControl &, const DebugDrawerInterfacePrx &, const DebugObserverInterfacePrx &) override
Definition: ZeroTorqueOrVelocityController.cpp:346
armarx::control::common::debugEigenVec
void debugEigenVec(StringVariantBaseMap &datafields, const std::string &name, Eigen::VectorXf vec)
Definition: utils.cpp:125
utils.h
armarx::control::njoint_controller::task_space::NJointTaskspaceZeroTorqueOrVelocityController::GenerateConfigFromVariants
static ConfigPtrT GenerateConfigFromVariants(const StringVariantBaseMap &values)
Definition: ZeroTorqueOrVelocityController.cpp:546
CycleUtil.h
armarx::RemoteGui::Client::HBoxLayout
Definition: Widgets.h:160
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::NJointTaskspaceZeroTorqueOrVelocityController::validateConfigData
void validateConfigData(Config &config, ArmPtr &arm)
Definition: ZeroTorqueOrVelocityController.cpp:310
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
TimeUtil.h
ARMARX_INFO
#define ARMARX_INFO
Definition: Logging.h:174
armarx::min
std::vector< T > min(const std::vector< T > &v1, const std::vector< T > &v2)
Definition: VectorHelpers.h:294
armarx::control::njoint_controller::task_space::NJointTaskspaceZeroTorqueOrVelocityController::limbPublish
void limbPublish(ArmPtr &arm, const DebugObserverInterfacePrx &debugObs)
Definition: ZeroTorqueOrVelocityController.cpp:328
IceInternal::ProxyHandle<::IceProxy::armarx::DebugObserverInterface >
ARMARX_INFO_S
#define ARMARX_INFO_S
Definition: Logging.h:195
armarx::control::njoint_controller::task_space::NJointTaskspaceZeroTorqueOrVelocityController::onInitNJointController
void onInitNJointController() override
NJointControllerBase interface.
Definition: ZeroTorqueOrVelocityController.cpp:172
armarx::control::common::sVecToString
std::string sVecToString(const std::vector< std::string > &vec, const std::string &delimiter)
Definition: utils.cpp:306
armarx::control::njoint_controller::task_space::NJointTaskspaceZeroTorqueOrVelocityController::updateConfig
void updateConfig(const ::armarx::aron::data::dto::DictPtr &dto, const Ice::Current &iceCurrent=Ice::emptyCurrent) override
NJointController interface.
Definition: ZeroTorqueOrVelocityController.cpp:283
ARMARX_WARNING
#define ARMARX_WARNING
Definition: Logging.h:186
ARMARX_RT_LOGF_WARN
#define ARMARX_RT_LOGF_WARN(...)
Definition: ControlThreadOutputBuffer.h:345
armarx::control::njoint_controller::task_space::NJointTaskspaceZeroTorqueOrVelocityController::NJointTaskspaceZeroTorqueOrVelocityController
NJointTaskspaceZeroTorqueOrVelocityController(const RobotUnitPtr &robotUnit, const NJointControllerConfigPtr &config, const VirtualRobot::RobotPtr &)
Definition: ZeroTorqueOrVelocityController.cpp:142
armarx::PackagePath
Definition: PackagePath.h:55
armarx::control::njoint_controller::task_space::NJointTaskspaceZeroTorqueOrVelocityController::Config
common::control_law::arondto::ZeroTorqueOrVelocityControllerConfig Config
Definition: ZeroTorqueOrVelocityController.h:61
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
armarx::control::njoint_controller::task_space::NJointTaskspaceZeroTorqueOrVelocityController::ConfigPtrT
ConfigurableNJointControllerConfigPtr ConfigPtrT
Definition: ZeroTorqueOrVelocityController.h:57