27 #include "../MotionControlGroupStatechartContext.h"
30 using namespace MotionControlGroup;
33 JointPositionControlApply::SubClassRegistry
47 getContext<MotionControlGroupStatechartContext>();
49 auto targetValues = in.getJointTargetValues();
51 float jointVelocity = 0;
53 if (isInputParameterSet(
"JointVelocity"))
55 jointVelocity = in.getJointVelocity();
60 NameControlModeMap jointControlModes;
62 for (
auto& pair : targetValues)
64 targetVelocities[pair.first] = jointVelocity;
65 jointControlModes[pair.first] = ePositionControl;
69 if (isInputParameterSet(
"JointVelocities"))
71 auto givenVelocities = in.getJointVelocities();
73 for (
auto& pair : givenVelocities)
75 targetVelocities[pair.first] = pair.second;
79 std::set<std::string> blacklist;
81 float tolerance = in.getJointTargetTolerance();
83 for (
auto& pair : targetValues)
88 if (!dataFieldIdentifier)
90 ARMARX_WARNING <<
"Could not generate DataFieldIdentifier from '" << pair.first <<
"'";
91 blacklist.insert(pair.first);
98 if (!dataField || !dataField->getInitialized())
100 ARMARX_WARNING <<
"Could not obtain DataField of '" << pair.first <<
"'";
101 blacklist.insert(pair.first);
105 float currentValue = dataField->getFloat();
107 if (currentValue >= pair.second - tolerance && currentValue <= pair.second + tolerance)
110 targetVelocities[pair.first] = 0;
114 targetVelocities[pair.first] = fabs(targetVelocities[pair.first]);
120 bool stillWaitingForJoint =
false;
122 for (
auto& pair : targetValues)
124 if (blacklist.find(pair.first) != blacklist.end())
132 if (targetVelocities[pair.first] == 0)
141 {pair.second, tolerance});
142 condition = condition || approx;
144 stillWaitingForJoint =
true;
147 if (stillWaitingForJoint)
149 installConditionForJointReachedTarget(condition);
153 int timeout = in.getTimeout();
157 setTimeoutEvent(timeout, createEventTimeout());
167 if (!stillWaitingForJoint)