3 #include <VirtualRobot/Robot.h>
4 #include <VirtualRobot/RobotNodeSet.h>
15 NJointControllerRegistration<NJointZeroTorqueOrVelocityWithFTController>
17 "NJointZeroTorqueOrVelocityWithFTController");
22 return "NJointZeroTorqueOrVelocityWithFTController";
27 const NJointZeroTorqueOrVelocityWithFTControllerConfigPtr& config,
31 RobotUnitPtr robotUnit = RobotUnitPtr::dynamicCast(prov);
37 for (
auto& robotNodeSetName : config->robotNodeSetList)
39 VirtualRobot::RobotNodeSetPtr rtRns =
rtGetRobot()->getRobotNodeSet(robotNodeSetName);
42 for (
size_t i = 0; i < rtRns->getSize(); i++)
44 std::string jointName = rtRns->getNode(i)->getName();
45 if (jointName.find(
"wri") != std::string::npos and
46 config->useZeroVelocityModeForWrist)
51 targetsVel.push_back(ct->
asA<ControlTarget1DoFActuatorZeroVelocity>());
71 target.targetTorqueOrVelocity = Ice::FloatSeq(numJoints, 0.0f);
74 ik.reset(
new VirtualRobot::DifferentialIK(
75 rtRns, rtRns->getRobot()->getRootNode(), VirtualRobot::JacobiProvider::eSVDDamped));
86 target.targetTorqueOrVelocity = Ice::FloatSeq(numJoints, 0.0f);
96 ik->getJacobianMatrix(rtTCP, VirtualRobot::IKSolver::CartesianSelection::All);
97 rtStatus.jacobi.block(0, 0, 3, rtStatus.numJoints) =
98 0.001 * rtStatus.jacobi.block(0, 0, 3, rtStatus.numJoints);
103 ik->computePseudoInverseJacobianMatrix(rtStatus.jacobi.transpose(), lambda);
104 rtStatus.jpinv = ik->computePseudoInverseJacobianMatrix(rtStatus.jacobi, lambda);
109 size_t torqueIndex = 0;
138 const std::map<std::string, ConstControlDevicePtr>& controlDevices,
139 const std::map<std::string, ConstSensorDevicePtr>&)
145 ::armarx::WidgetDescription::WidgetSeq widgets;
146 auto addSlider = [&](
const std::string& label,
float min,
float max,
float defaultValue)
148 widgets.emplace_back(
new Label(
false, label));
153 c_x->defaultValue = defaultValue;
155 widgets.emplace_back(c_x);
160 LabelPtr label =
new Label;
161 label->text =
"Robot Node Sets";
162 layout->children.emplace_back(label);
164 StringComboBoxPtr box =
new StringComboBox;
165 box->name =
"robotNodeSetSelector";
166 box->defaultIndex = 0;
167 box->multiSelect =
true;
168 box->options.push_back(
"LeftArm");
169 box->options.push_back(
"RightArm");
170 layout->children.emplace_back(box);
176 CheckBoxPtr checkBox =
new CheckBox;
177 checkBox->name =
"useZeroVelocityModeForWrist";
178 checkBox->label =
"Wrist ZeroVelocity";
179 checkBox->defaultValue =
true;
181 addSlider(
"maxTorque", 0, 100, 10);
182 addSlider(
"maxVeloicty", 0, 3.14, 2.0);
184 layout->children.insert(layout->children.end(), widgets.begin(), widgets.end());
188 NJointZeroTorqueOrVelocityWithFTControllerConfigPtr
192 auto varNodeSets = VariantPtr::dynamicCast(
values.at(
"robotNodeSetSelector"));
198 values.at(
"useZeroVelocityModeForWrist")->getBool(),
199 values.at(
"maxTorque")->getFloat(),
200 values.at(
"maxVeloicty")->getFloat()};