Go to the documentation of this file.
3 #include <VirtualRobot/Nodes/RobotNode.h>
4 #include <VirtualRobot/Robot.h>
16 return "NJointZeroTorqueController";
22 RobotUnitPtr robotUnit = RobotUnitPtr::dynamicCast(prov);
26 for (
auto& jointName : config->jointNames)
28 auto node = r->getRobotNode(jointName);
33 targets.push_back(ct->
asA<ControlTarget1DoFActuatorZeroTorque>());
37 target.targetTorques = Ice::FloatSeq(config->jointNames.size(), 0.0f);
50 for (
size_t i = 0; i <
targets.size(); ++i)
66 ::armarx::WidgetDescription::WidgetSeq widgets;
67 auto addSlider = [&](
const std::string & label,
float min,
float max,
float defaultValue)
69 widgets.emplace_back(
new Label(
false, label));
74 c_x->defaultValue = defaultValue;
76 widgets.emplace_back(c_x);
80 LabelPtr label =
new Label;
81 label->text =
"joint names";
82 layout->children.emplace_back(label);
83 StringComboBoxPtr box =
new StringComboBox;
84 box->defaultIndex = 0;
85 box->multiSelect =
true;
87 for (
auto&
c : controlDevices)
89 if (
c.second->hasJointController(ControlModes::ZeroTorque1DoF))
91 box->options.push_back(
c.first);
94 box->name =
"jointNames";
95 layout->children.emplace_back(box);
97 addSlider(
"maxTorque", 0, 100, 10);
99 layout->children.insert(layout->children.end(),
115 auto var = VariantPtr::dynamicCast(
values.at(
"jointNames"));
117 return new NJointZeroTorqueControllerConfig {var->get<
SingleTypeVariantList>()->toStdVector<std::string>(),
118 values.at(
"maxTorque")->getFloat()
void reinitTripleBuffer(const NJointZeroTorqueControllerTarget &initial)
const NJointZeroTorqueControllerTarget & rtGetControlStruct() const
std::map< std::string, VariantBasePtr > StringVariantBaseMap
Brief description of class JointControlTargetBase.
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)
void rtPreActivateController() override
This function is called before the controller is activated.
NJointZeroTorqueController(RobotUnitPtr prov, const NJointZeroTorqueControllerConfigPtr &config, const VirtualRobot::RobotPtr &)
void setControllerTarget(const Ice::FloatSeq &, const Ice::Current &) override
NJointZeroTorqueControllerTarget & getWriterControlStruct()
std::lock_guard< std::recursive_mutex > LockGuardType
uint32_t Label
Type of an object label.
The SingleTypeVariantList class is a subclass of VariantContainer and is comparable to a std::vector<...
void writeControlStruct()
MutexType controlDataMutex
NJointControllerRegistration< NJointZeroTorqueController > registrationControllerNJointZeroTorqueController("NJointZeroTorqueController")
armarx::core::time::DateTime Time
void rtPostDeactivateController() override
This function is called after the controller is deactivated.
static NJointZeroTorqueControllerConfigPtr GenerateConfigFromVariants(const StringVariantBaseMap &values)
std::vector< ControlTarget1DoFActuatorZeroTorque * > targets
static double LimitTo(double value, double absThreshold)
#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 rtRun(const IceUtil::Time &sensorValuesTimestamp, const IceUtil::Time &timeSinceLastIteration) override
TODO make protected and use attorneys.
static WidgetDescription::WidgetPtr GenerateConfigDescription(const VirtualRobot::RobotPtr &, const std::map< std::string, ConstControlDevicePtr > &, const std::map< std::string, ConstSensorDevicePtr > &)
std::shared_ptr< class Robot > RobotPtr
std::string getClassName(const Ice::Current &) const override