26 #include <VirtualRobot/RobotNodeSet.h>
49 NJointControllerRegistration<NJointTaskspaceCollisionAvoidanceMixedImpedanceVelocityController>
51 "NJointTaskspaceCollisionAvoidanceMixedImpedanceVelocityController");
56 const NJointControllerConfigPtr& config,
60 ConfigPtrT cfg = ConfigPtrT::dynamicCast(config);
62 userCfgWithColl = CollisionCtrlCfg::FromAron(cfg->config);
64 coll = std::make_shared<core::CollisionAvoidanceBase>(rtGetRobot(), userCfgWithColl.coll);
65 collReady.store(
true);
66 const std::string rootNodeName =
"root";
67 rootNode = rtGetRobot()->getRobotNode(rootNodeName);
68 ARMARX_INFO <<
"-- " << getClassName() <<
" initized --";
73 const Ice::Current&)
const
75 return "NJointTaskspaceCollisionAvoidanceMixedImpedanceVelocityController";
86 arm->controller.run(arm->rtConfig, arm->rtStatus);
92 const std::string rootNodeName =
"root";
94 coll->collLimb.at(arm->kinematicChainName).rts.globalPose =
96 coll->rtLimbControllerRun(arm->kinematicChainName,
97 arm->rtStatus.jointPos,
98 arm->rtStatus.qvelFiltered,
99 arm->rtConfig.torqueLimit,
100 arm->rtStatus.desiredJointTorques);
104 if (collReady.load())
107 arm->rtStatus.nDoFTorque,
108 arm->rtStatus.nDoFVelocity,
109 coll->collLimb.at(arm->kinematicChainName).rts.desiredJointTorques,
110 arm->rtStatus.desiredJointVelocity);
115 arm->rtStatus.nDoFTorque,
116 arm->rtStatus.nDoFVelocity,
117 arm->rtStatus.desiredJointTorques,
118 arm->rtStatus.desiredJointVelocity);
147 double deltaT = timeSinceLastIteration.toSecondsDouble();
150 if (collReady.load())
153 coll->updateRtConfigFromUser();
154 coll->rtCollisionChecking();
156 for (
auto& pair :
limb)
158 this->
limbRT(pair.second, deltaT);
162 hands->updateRTStatus(deltaT);
170 const Ice::Current& iceCurrent)
173 auto cfg = common::control_law::arondto::CollisionAvoidanceConfigDict::FromAron(dto);
174 coll->setUserCfg(cfg);
179 const Ice::Current& iceCurrent)
181 if (not collReady.load())
185 return coll->userCfg.toAronDTO();
191 const Ice::Current& iceCurrent)
194 userCfgWithColl = CollisionCtrlCfg::FromAron(dto);
196 coll->setUserCfg(userCfgWithColl.coll);
201 const Ice::Current& iceCurrent)
203 for (
auto& pair :
limb)
206 pair.second->bufferConfigRtToUser.getUpToDateReadBuffer();
209 return userCfgWithColl.toAronDTO();
222 datafields[
"trackingError"] =
new Variant(rtStatus.trackingError);
228 datafields,
"projectedImpedanceTorque", rtStatus.projImpedanceJointTorque);
234 const Eigen::VectorXf selfCollNullspace = rtStatus.selfCollNullSpace.diagonal();
235 const Eigen::VectorXf jointLimNullspace = rtStatus.jointLimNullSpace.diagonal();
258 datafields[
"collisionPairsNum"] =
new Variant(rtStatus.collisionPairsNum);
259 datafields[
"activeCollPairsNum"] =
new Variant(rtStatus.activeCollPairsNum);
261 datafields[
"collisionPairTime"] =
new Variant(rtStatus.collisionPairTime);
262 datafields[
"collisionTorqueTime"] =
new Variant(rtStatus.collisionTorqueTime);
263 datafields[
"jointLimitTorqueTime"] =
new Variant(rtStatus.jointLimitTorqueTime);
264 datafields[
"selfCollNullspaceTime"] =
new Variant(rtStatus.selfCollNullspaceTime);
265 datafields[
"jointLimitNullspaceTime"] =
new Variant(rtStatus.jointLimitNullspaceTime);
267 datafields[
"impForceRatio"] =
new Variant(rtStatus.impForceRatio);
268 datafields[
"impTorqueRatio"] =
new Variant(rtStatus.impTorqueRatio);
284 for (
int i = 0; i < rtStatus.activeCollPairsNum; ++i)
314 new Variant(rtStatus.selfCollDataVec[i].minDistance);
316 new Variant(rtStatus.selfCollDataVec[i].repulsiveForce);
318 new Variant(-1.0f * rtStatus.selfCollDataVec[i].damping *
319 rtStatus.selfCollDataVec[i].distanceVelocity);
321 new Variant(rtStatus.selfCollDataVec[i].desiredNSColl);
323 datafields,
std::to_string(i) +
"_point", rtStatus.selfCollDataVec[i].point1);
325 datafields,
std::to_string(i) +
"_dir", rtStatus.selfCollDataVec[i].direction);
610 debugObs->setDebugChannel(
"CollAvoid_ImpCtrl_" + arm.
nodeSetName, datafields);
622 for (
auto& pair : coll->collLimb)
633 "NJointTaskspaceCollisionAvoidanceMixedImpedanceVelocityController");
636 if (collReady.load())
639 coll->rtPreActivate();
647 if (collReady.load())
650 coll->rtPostDeactivate();
653 "NJointTaskspaceCollisionAvoidanceMixedImpedanceVelocityController");
659 const std::map<std::string, ConstControlDevicePtr>& controlDevices,
660 const std::map<std::string, ConstSensorDevicePtr>&)
666 ::armarx::WidgetDescription::WidgetSeq widgets;
669 LabelPtr label =
new Label;
670 label->text =
"select a controller config";
672 StringComboBoxPtr cfgBox =
new StringComboBox;
673 cfgBox->name =
"config_box";
674 cfgBox->defaultIndex = 0;
675 cfgBox->multiSelect =
false;
677 cfgBox->options = std::vector<std::string>{
"default",
679 "default_a7_right_zero_torque",
681 "default_a7_left_zero_torque",
682 "default_a7_with_hands",
683 "default_a7_zero_torque"};
686 layout->children.emplace_back(label);
687 layout->children.emplace_back(cfgBox);
690 layout->children.insert(layout->children.end(), widgets.begin(), widgets.end());
699 auto cfgName =
values.at(
"config_box")->getString();
702 "controller_config/NJointTaskspaceCollisionAvoidanceMixedImpedanceVelocityController/" +
707 auto cfgDTO = armarx::readFromJson<CollisionCtrlCfg>(configPath.
toSystemPath());
710 return new ConfigurableNJointControllerConfig{cfgDTO.toAronDTO()};