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