29 #include <VirtualRobot/Nodes/RobotNode.h>
30 #include <VirtualRobot/RobotNodeSet.h>
31 #include <VirtualRobot/VirtualRobot.h>
32 #include <VirtualRobot/VirtualRobotException.h>
33 #include <VirtualRobot/XML/RobotIO.h>
46 std::string jointName = robotNode->getName();
55 hasProperty(
"RobotName") ? getProperty<std::string>(
"RobotName") :
robot->getName();
65 mapVelToPosVel = getProperty<bool>(
"MapVelocityToPositionVelocity").getValue();
79 cycleTime = 1000.f / getProperty<float>(
"ControlFrequency").getValue();
91 "KinematicUnitDynamicSimulation");
93 execTask->setDelayWarningTolerance(100);
117 if (state.jointAngles.size() > 0)
120 for (
const auto& actualJointAngle : state.jointAngles)
124 angleValues[actualJointAngle.first] = actualJointAngle.second;
133 for (
const auto& actualVelocity : state.jointVelocities)
137 velocitiyValues[actualVelocity.first] = actualVelocity.second;
143 for (
const auto& actualJointTorque : state.jointTorques)
147 torqueValues[actualJointTorque.first] = actualJointTorque.second;
153 if (angleValues.size() > 0)
155 listenerPrx->reportJointAngles(angleValues, state.timestampInMicroSeconds,
true);
157 if (velocitiyValues.size() > 0)
159 listenerPrx->reportJointVelocities(velocitiyValues, state.timestampInMicroSeconds,
true);
161 if (torqueValues.size() > 0)
163 listenerPrx->reportJointTorques(torqueValues, state.timestampInMicroSeconds,
true);
170 NameControlModeMap result;
179 result[nodeName] = ePositionControl;
183 result[nodeName] =
c->second;
192 const Ice::Current&
c)
197 NameControlModeMap::const_iterator itAng = targetJointModes.begin();
199 while (itAng != targetJointModes.end())
206 targetJointModes, IceUtil::Time::now().toMicroSeconds(),
true);
211 const Ice::Current&
c)
217 NameValueMap::const_iterator itAng = targetJointAngles.begin();
219 while (itAng != targetJointAngles.end())
228 const Ice::Current&
c)
231 NameValueMap::const_iterator itVel = targetJointVelocities.begin();
233 while (itVel != targetJointVelocities.end())
242 const Ice::Current&
c)
247 NameValueMap::const_iterator itAng = targetJointTorques.begin();
249 while (itAng != targetJointTorques.end())
258 const Ice::Current&
c)
264 const Ice::Current&
c)
274 for (
const auto& joint : joints)
290 for (
const auto& joint : joints)
309 float factorLoopTime = 1.1f;
323 switch (itMode->second)
325 case ePositionControl:
328 applyPosMap[itMode->first] =
334 case eVelocityControl:
345 it->second * loopTime * factorLoopTime;
346 applyPosVelMap_pos[itMode->first] = posTarget;
347 applyPosVelMap_vel[itMode->first] = it->second;
353 applyVelMap[itMode->first] =
365 applyTorMap[itMode->first] =
371 case ePositionVelocityControl:
376 applyPosVelMap_pos[itMode->first] =
378 applyPosVelMap_vel[itMode->first] =
394 if (applyPosMap.size() > 0)
396 batchPrx->actuateRobotJointsPos(
robotName, applyPosMap);
399 if (applyVelMap.size() > 0)
401 batchPrx->actuateRobotJointsVel(
robotName, applyVelMap);
404 if (applyTorMap.size() > 0)
406 batchPrx->actuateRobotJointsTorque(
robotName, applyTorMap);
409 if (applyPosVelMap_pos.size() > 0)
411 batchPrx->actuateRobotJoints(
robotName, applyPosVelMap_pos, applyPosVelMap_vel);
413 batchPrx->ice_flushBatchRequests();
428 const ::armarx::SimulatedRobotState robotState = simulatorPrx->getRobotState(robotName);
430 ::armarx::NameStatusMap jointStatus;
431 for (
const auto& [jointName, _] : currentControlModes)
433 jointStatus[jointName] = {
434 .operation = eOnline,
437 .emergencyStop =
false
441 return {.jointModes = currentControlModes,
442 .jointAngles = robotState.jointAngles,
443 .jointVelocities = robotState.jointVelocities,
444 .jointAccelerations = {},
445 .jointTorques = robotState.jointTorques,
447 .jointMotorTemperatures = {},
448 .jointStatus = jointStatus};