3 #include <VirtualRobot/Nodes/RobotNode.h>
4 #include <VirtualRobot/Robot.h>
15 NJointControllerRegistration<NJointZeroTorqueOrVelocityController>
17 "NJointZeroTorqueOrVelocityController");
22 return "NJointZeroTorqueOrVelocityController";
27 const NJointZeroTorqueOrVelocityControllerConfigPtr& config,
31 RobotUnitPtr robotUnit = RobotUnitPtr::dynamicCast(prov);
35 not(config->jointNamesZeroTorque.empty() and config->jointNamesZeroVelocity.empty()));
38 for (
auto& jointName : config->jointNamesZeroTorque)
40 if (std::find(config->jointNamesZeroVelocity.begin(),
41 config->jointNamesZeroVelocity.end(),
42 jointName) != config->jointNamesZeroVelocity.end())
44 ARMARX_ERROR << jointName <<
" exists in both torque and velocity controlled mode";
46 auto node = r->getRobotNode(jointName);
54 for (
auto& jointName : config->jointNamesZeroVelocity)
56 auto node = r->getRobotNode(jointName);
61 targetsVel.push_back(ct->
asA<ControlTarget1DoFActuatorZeroVelocity>());
65 config->jointNamesZeroTorque.size() + config->jointNamesZeroVelocity.size();
72 target.targetTorqueOrVelocity = Ice::FloatSeq(numJoints, 0.0f);
87 size_t torqueIndex = 0;
109 const std::map<std::string, ConstControlDevicePtr>& controlDevices,
110 const std::map<std::string, ConstSensorDevicePtr>&)
116 ::armarx::WidgetDescription::WidgetSeq widgets;
117 auto addSlider = [&](
const std::string& label,
float min,
float max,
float defaultValue)
119 widgets.emplace_back(
new Label(
false, label));
124 c_x->defaultValue = defaultValue;
126 widgets.emplace_back(c_x);
131 LabelPtr label =
new Label;
132 label->text =
"zero torque joints";
133 layout->children.emplace_back(label);
135 StringComboBoxPtr box =
new StringComboBox;
136 box->name =
"jointNamesZeroTorque";
137 box->defaultIndex = 0;
138 box->multiSelect =
true;
140 for (
auto&
c : controlDevices)
142 if (
c.second->hasJointController(ControlModes::ZeroTorque1DoF))
144 box->options.push_back(
c.first);
147 layout->children.emplace_back(box);
151 LabelPtr labelControlMode =
new Label;
152 labelControlMode->text =
"zero velocity joints";
153 layout->children.emplace_back(labelControlMode);
155 StringComboBoxPtr boxControlMode =
new StringComboBox;
156 boxControlMode->name =
"jointNamesZeroVelocity";
157 boxControlMode->defaultIndex = 0;
158 boxControlMode->multiSelect =
true;
160 for (
auto&
c : controlDevices)
162 if (
c.second->hasJointController(ControlModes::ZeroVelocity1DoF))
164 boxControlMode->options.push_back(
c.first);
167 layout->children.emplace_back(boxControlMode);
170 addSlider(
"maxTorque", 0, 100, 10);
171 addSlider(
"maxVeloicty", 0, 3.14, 2.0);
173 layout->children.insert(layout->children.end(), widgets.begin(), widgets.end());
184 NJointZeroTorqueOrVelocityControllerConfigPtr
188 auto varZeroTorque = VariantPtr::dynamicCast(
values.at(
"jointNamesZeroTorque"));
190 auto varZeroVelocity = VariantPtr::dynamicCast(
values.at(
"jointNamesZeroVelocity"));
194 std::cout << pair.first;
201 values.at(
"maxTorque")->getFloat(),
202 values.at(
"maxVeloicty")->getFloat()};