26 #include <VirtualRobot/IK/DifferentialIK.h>
27 #include <VirtualRobot/Robot.h>
28 #include <VirtualRobot/RobotNodeSet.h>
32 #include "../RobotUnit.h"
35 #define DEFAULT_TCP_STRING "default TCP"
40 NJointControllerRegistration<NJointTCPController>
46 return "NJointTCPController";
62 if (mode == VirtualRobot::IKSolver::All)
86 Eigen::MatrixXf jacobiInv = ik->getPseudoInverseJacobianMatrix(tcp, mode);
87 Eigen::VectorXf jointTargetVelocities = jacobiInv * x;
89 for (
size_t i = 0; i < targets.size(); ++i)
91 targets.at(i)->velocity = jointTargetVelocities(i);
95 ::armarx::WidgetDescription::WidgetSeq
99 ::armarx::WidgetDescription::WidgetSeq widgets;
100 auto addSlider = [&](
const std::string& label,
float limit)
102 widgets.emplace_back(
new Label(
false, label));
107 c_x->defaultValue = 0.0f;
109 widgets.emplace_back(c_x);
116 addSlider(
"roll", 0.5);
117 addSlider(
"pitch", 0.5);
118 addSlider(
"yaw", 0.5);
125 const std::map<std::string, ConstControlDevicePtr>& controlDevices,
126 const std::map<std::string, ConstSensorDevicePtr>&)
131 LabelPtr label =
new Label;
132 label->text =
"nodeset name";
133 layout->children.emplace_back(label);
134 StringComboBoxPtr box =
new StringComboBox;
135 box->defaultIndex = 0;
137 box->options = robot->getRobotNodeSetNames();
138 box->name =
"nodeSetName";
139 layout->children.emplace_back(box);
141 LabelPtr labelTCP =
new Label;
142 labelTCP->text =
"tcp name";
143 layout->children.emplace_back(labelTCP);
144 StringComboBoxPtr boxTCP =
new StringComboBox;
145 boxTCP->defaultIndex = 0;
147 boxTCP->options = robot->getRobotNodeNames();
149 boxTCP->name =
"tcpName";
150 layout->children.emplace_back(boxTCP);
152 LabelPtr labelMode =
new Label;
153 labelMode->text =
"mode";
154 layout->children.emplace_back(labelMode);
155 StringComboBoxPtr boxMode =
new StringComboBox;
156 boxMode->defaultIndex = 0;
158 boxMode->options = {
"Position",
"Orientation",
"Both"};
159 boxMode->name =
"mode";
160 layout->children.emplace_back(boxMode);
167 layout->children.emplace_back(
new HSpacer);
171 NJointTCPControllerConfigPtr
175 values.at(
"tcpName")->getString()};
179 const NJointTCPControllerConfigPtr& config,
185 auto nodeset =
rtGetRobot()->getRobotNodeSet(config->nodeSetName);
187 for (
size_t i = 0; i < nodeset->getSize(); ++i)
189 auto jointName = nodeset->getNode(i)->getName();
192 targets.push_back(ct->
asA<ControlTarget1DoFActuatorVelocity>());
193 sensors.push_back(sv->
asA<SensorValue1DoFActuatorPosition>());
195 ik.reset(
new VirtualRobot::DifferentialIK(
196 nodeset,
rtGetRobot()->getRootNode(), VirtualRobot::JacobiProvider::eSVDDamped));
199 :
rtGetRobot()->getRobotNode(config->tcpName);
202 nodeSetName = config->nodeSetName;
242 layout->children.insert(layout->children.end(), sliders.begin(), sliders.end());
243 return {{
"ControllerTarget", layout}};
251 if (name ==
"ControllerTarget")