26 #include <VirtualRobot/RobotNodeSet.h>
30 #include "../RobotUnit.h"
33 #define DEFAULT_TCP_STRING "default TCP"
38 NJointControllerRegistration<NJointCartesianTorqueController>
44 return "NJointCartesianTorqueController";
49 NJointCartesianTorqueControllerConfigPtr config,
54 VirtualRobot::RobotNodeSetPtr rns =
rtGetRobot()->getRobotNodeSet(config->nodeSetName);
56 for (
size_t i = 0; i < rns->getSize(); ++i)
58 std::string jointName = rns->getNode(i)->getName();
61 targets.push_back(ct->
asA<ControlTarget1DoFActuatorTorque>());
82 nodeSetName = config->nodeSetName;
84 ik.reset(
new VirtualRobot::DifferentialIK(
85 rns, rns->getRobot()->getRootNode(), VirtualRobot::JacobiProvider::eSVDDamped));
104 Eigen::VectorXf cartesianFT(6);
109 Eigen::MatrixXf jacobi =
110 ik->getJacobianMatrix(tcp, VirtualRobot::IKSolver::CartesianSelection::All);
111 Eigen::MatrixXf jacobiT = jacobi.transpose();
114 Eigen::VectorXf jointTargetTorques = jacobiT * cartesianFT;
118 for (
size_t i = 0; i < targets.size(); ++i)
120 targets.at(i)->torque = jointTargetTorques(i);
124 WidgetDescription::HBoxLayoutPtr
129 auto addSlider = [&](
const std::string& label,
float min,
float max,
float defaultValue)
131 layout->children.emplace_back(
new Label(
false, label));
133 floatSlider->name = label;
134 floatSlider->min =
min;
135 floatSlider->defaultValue = defaultValue;
136 floatSlider->max =
max;
137 layout->children.emplace_back(floatSlider);
140 addSlider(
"forceX", -10, 10, 0);
141 addSlider(
"forceY", -10, 10, 0);
142 addSlider(
"forceZ", -10, 10, 0);
143 addSlider(
"torqueX", -1, 1, 0);
144 addSlider(
"torqueY", -1, 1, 0);
145 addSlider(
"torqueZ", -1, 1, 0);
176 const std::map<std::string, ConstControlDevicePtr>& controlDevices,
177 const std::map<std::string, ConstSensorDevicePtr>&)
182 LabelPtr label =
new Label;
183 label->text =
"nodeset name";
184 layout->children.emplace_back(label);
185 StringComboBoxPtr box =
new StringComboBox;
186 box->defaultIndex = 0;
188 box->options = robot->getRobotNodeSetNames();
189 box->name =
"nodeSetName";
190 layout->children.emplace_back(box);
192 LabelPtr labelTCP =
new Label;
193 labelTCP->text =
"tcp name";
194 layout->children.emplace_back(labelTCP);
195 StringComboBoxPtr boxTCP =
new StringComboBox;
196 boxTCP->defaultIndex = 0;
198 boxTCP->options = robot->getRobotNodeNames();
200 boxTCP->name =
"tcpName";
201 layout->children.emplace_back(boxTCP);
214 layout->children.emplace_back(
new HSpacer);
218 NJointCartesianTorqueControllerConfigPtr
221 return new NJointCartesianTorqueControllerConfig(
values.at(
"nodeSetName")->getString(),
222 values.at(
"tcpName")->getString());
242 return {{
"ControllerTarget", layout}};
250 if (name ==
"ControllerTarget")