Go to the documentation of this file.
3 #include <VirtualRobot/Nodes/RobotNode.h>
4 #include <VirtualRobot/Robot.h>
16 return "NJointTorqueController";
22 RobotUnitPtr robotUnit = RobotUnitPtr::dynamicCast(prov);
26 for (
auto& jointName : config->jointNames)
28 auto node = r->getRobotNode(jointName);
33 targets.push_back(ct->
asA<ControlTarget1DoFActuatorTorque>());
37 target.targetTorques = Ice::FloatSeq(config->jointNames.size(), 0.0f);
48 for (
size_t i = 0; i <
targets.size(); ++i)
60 ::armarx::WidgetDescription::WidgetSeq widgets;
61 auto addSlider = [&](
const std::string & label,
float min,
float max,
float defaultValue)
63 widgets.emplace_back(
new Label(
false, label));
68 c_x->defaultValue = defaultValue;
70 widgets.emplace_back(c_x);
74 LabelPtr label =
new Label;
75 label->text =
"joint names";
76 layout->children.emplace_back(label);
77 StringComboBoxPtr box =
new StringComboBox;
78 box->defaultIndex = 0;
79 box->multiSelect =
true;
81 for (
auto&
c : controlDevices)
83 if (
c.second->hasJointController(ControlModes::ZeroTorque1DoF))
85 box->options.push_back(
c.first);
89 box->name =
"jointNames";
90 layout->children.emplace_back(box);
92 addSlider(
"maxTorque", 0, 100, 10);
94 layout->children.insert(layout->children.end(),
108 auto var = VariantPtr::dynamicCast(
values.at(
"jointNames"));
110 return new NJointTorqueControllerConfig {var->get<
SingleTypeVariantList>()->toStdVector<std::string>(),
111 values.at(
"maxTorque")->getFloat()
void reinitTripleBuffer(const NJointTorqueControllerTarget &initial)
const NJointTorqueControllerTarget & rtGetControlStruct() const
std::map< std::string, VariantBasePtr > StringVariantBaseMap
static NJointTorqueControllerConfigPtr GenerateConfigFromVariants(const StringVariantBaseMap &values)
std::string getClassName(const Ice::Current &) const override
Brief description of class JointControlTargetBase.
NJointTorqueController(RobotUnitPtr prov, const NJointTorqueControllerConfigPtr &config, const VirtualRobot::RobotPtr &)
ControlTargetBase * useControlTarget(const std::string &deviceName, const std::string &controlMode)
Declares to calculate the ControlTarget for the given ControlDevice in the given ControlMode when rtR...
#define ARMARX_CHECK_NOT_NULL(ptr)
This macro evaluates whether ptr is not null and if it turns out to be false it will throw an Express...
Vertex target(const detail::edge_base< Directed, Vertex > &e, const PCG &)
std::vector< T > max(const std::vector< T > &v1, const std::vector< T > &v2)
std::vector< ControlTarget1DoFActuatorTorque * > targets
NJointTorqueControllerTarget & getWriterControlStruct()
std::lock_guard< std::recursive_mutex > LockGuardType
double clamp(double x, double a, double b)
uint32_t Label
Type of an object label.
void rtRun(const IceUtil::Time &sensorValuesTimestamp, const IceUtil::Time &timeSinceLastIteration) override
TODO make protected and use attorneys.
The SingleTypeVariantList class is a subclass of VariantContainer and is comparable to a std::vector<...
void writeControlStruct()
NJointControllerRegistration< NJointTorqueController > registrationControllerNJointTorqueController("NJointTorqueController")
static WidgetDescription::WidgetPtr GenerateConfigDescription(const VirtualRobot::RobotPtr &, const std::map< std::string, ConstControlDevicePtr > &, const std::map< std::string, ConstSensorDevicePtr > &)
MutexType controlDataMutex
armarx::core::time::DateTime Time
void rtPreActivateController() override
This function is called before the controller is activated.
#define ARMARX_CHECK_EXPRESSION(expression)
This macro evaluates the expression and if it turns out to be false it will throw an ExpressionExcept...
std::vector< T > min(const std::vector< T > &v1, const std::vector< T > &v2)
void rtPostDeactivateController() override
This function is called after the controller is deactivated.
void setControllerTarget(const Ice::FloatSeq &, const Ice::Current &) override
std::shared_ptr< class Robot > RobotPtr