26 #include "../MotionControlGroupStatechartContext.h"
29 #include <VirtualRobot/RobotConfig.h>
32 using namespace MotionControlGroup;
54 int decelerationTime = in.getDecelerationTime();
56 if (decelerationTime != 0)
58 setTimeoutEvent(decelerationTime, createEventTimeout());
61 std::string kinematicChain =
"";
63 if (in.isKinematicChainNameSet())
65 kinematicChain = in.getKinematicChainName();
68 Ice::StringSeq nodeNames, realJointNames;
70 if (kinematicChain.empty())
76 VirtualRobot::RobotNodeSetPtr nodeSet = context->
getLocalRobot()->getRobotNodeSet(kinematicChain);
78 for (
size_t i = 0; i < nodeSet->getSize(); ++i)
80 nodeNames.push_back(nodeSet->getNode(i)->getName());
85 Term zeroVeloCondition;
88 ChannelRegistryEntry& channelEntry = channels[
"jointvelocities"];
91 for (
auto& nodeName : nodeNames)
93 if (channelEntry.dataFields.count(nodeName) == 0 || !channelEntry.dataFields[nodeName].value->getInitialized())
98 jointVelocities[nodeName] = channelEntry.dataFields[nodeName].value->getFloat();
100 realJointNames.push_back(nodeName);
104 installConditionForZeroVelocityReached(zeroVeloCondition);
105 out.setJointNames(realJointNames);
114 std::string kinematicChain =
"";
116 if (in.isKinematicChainNameSet())
118 kinematicChain = in.getKinematicChainName();
135 ChannelRegistryEntry& channelEntry = channels[
"jointvelocities"];
137 Ice::StringSeq validJoints;
139 for (
auto& node : jointMap)
141 if (channelEntry.dataFields.count(node.first) == 0 || !channelEntry.dataFields[node.first].value->getInitialized())
146 jointVelocities[node.first] = channelEntry.dataFields[node.first].value->getFloat();
147 validJoints.push_back(node.first);
151 while (!isRunningTaskStopped())
154 for (
auto& jointName : validJoints)
170 auto nodes = out.getJointNames();
171 Ice::StringSeq activeJoints;
172 std::vector<float> jointTargets;
174 for (
auto nodeName : nodes)
176 auto it = config.find(nodeName);
178 if (it != config.end())
181 jointTargets.push_back(it->second);
182 activeJoints.push_back(it->first);
186 out.setJointNames(activeJoints);
187 out.setCurrentJointPositions(jointTargets);