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<NJointCartesianTorqueController>
46 return "NJointCartesianTorqueController";
51 NJointCartesianTorqueControllerConfigPtr config,
56 VirtualRobot::RobotNodeSetPtr rns =
rtGetRobot()->getRobotNodeSet(config->nodeSetName);
58 for (
size_t i = 0; i < rns->getSize(); ++i)
60 std::string jointName = rns->getNode(i)->getName();
63 targets.push_back(ct->
asA<ControlTarget1DoFActuatorTorque>());
84 nodeSetName = config->nodeSetName;
86 ik.reset(
new VirtualRobot::DifferentialIK(
87 rns, rns->getRobot()->getRootNode(), VirtualRobot::JacobiProvider::eSVDDamped));
106 Eigen::VectorXf cartesianFT(6);
111 Eigen::MatrixXf jacobi =
112 ik->getJacobianMatrix(tcp, VirtualRobot::IKSolver::CartesianSelection::All);
113 Eigen::MatrixXf jacobiT = jacobi.transpose();
116 Eigen::VectorXf jointTargetTorques = jacobiT * cartesianFT;
120 for (
size_t i = 0; i < targets.size(); ++i)
122 targets.at(i)->torque = jointTargetTorques(i);
126 WidgetDescription::HBoxLayoutPtr
131 auto addSlider = [&](
const std::string& label,
float min,
float max,
float defaultValue)
133 layout->children.emplace_back(
new Label(
false, label));
135 floatSlider->name = label;
136 floatSlider->min =
min;
137 floatSlider->defaultValue = defaultValue;
138 floatSlider->max =
max;
139 layout->children.emplace_back(floatSlider);
142 addSlider(
"forceX", -10, 10, 0);
143 addSlider(
"forceY", -10, 10, 0);
144 addSlider(
"forceZ", -10, 10, 0);
145 addSlider(
"torqueX", -1, 1, 0);
146 addSlider(
"torqueY", -1, 1, 0);
147 addSlider(
"torqueZ", -1, 1, 0);
178 const std::map<std::string, ConstControlDevicePtr>& controlDevices,
179 const std::map<std::string, ConstSensorDevicePtr>&)
184 LabelPtr label =
new Label;
185 label->text =
"nodeset name";
186 layout->children.emplace_back(label);
187 StringComboBoxPtr box =
new StringComboBox;
188 box->defaultIndex = 0;
190 box->options = robot->getRobotNodeSetNames();
191 box->name =
"nodeSetName";
192 layout->children.emplace_back(box);
194 LabelPtr labelTCP =
new Label;
195 labelTCP->text =
"tcp name";
196 layout->children.emplace_back(labelTCP);
197 StringComboBoxPtr boxTCP =
new StringComboBox;
198 boxTCP->defaultIndex = 0;
200 boxTCP->options = robot->getRobotNodeNames();
202 boxTCP->name =
"tcpName";
203 layout->children.emplace_back(boxTCP);
216 layout->children.emplace_back(
new HSpacer);
220 NJointCartesianTorqueControllerConfigPtr
223 return new NJointCartesianTorqueControllerConfig(
values.at(
"nodeSetName")->getString(),
224 values.at(
"tcpName")->getString());
244 return {{
"ControllerTarget", layout}};
252 if (name ==
"ControllerTarget")