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();
91 "KinematicUnitDynamicSimulation");
93 execTask->setDelayWarningTolerance(100);
108 NameValueMap angleValues;
109 NameValueMap velocitiyValues;
110 NameValueMap torqueValues;
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;
314 NameValueMap applyPosMap;
315 NameValueMap applyVelMap;
316 NameValueMap applyPosVelMap_pos;
317 NameValueMap applyPosVelMap_vel;
318 NameValueMap applyTorMap;
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();
430 ::armarx::NameStatusMap jointStatus;
433 jointStatus[jointName] = {
434 .operation = eOnline,
437 .emergencyStop =
false
442 .jointAngles = robotState.jointAngles,
443 .jointVelocities = robotState.jointVelocities,
444 .jointAccelerations = {},
445 .jointTorques = robotState.jointTorques,
447 .jointMotorTemperatures = {},
448 .jointStatus = jointStatus};
Property< PropertyType > getProperty(const std::string &name)
void releaseJoints(const Ice::StringSeq &joints, const Ice::Current &c=Ice::emptyCurrent) override
NameValueMap currentJointTargets
void requestJoints(const Ice::StringSeq &joints, const Ice::Current &c=Ice::emptyCurrent) override
NameValueMap currentJointTorqueTargets
void setJointAngles(const NameValueMap &targetJointAngles, const Ice::Current &c=Ice::emptyCurrent) override
void switchControlMode(const NameControlModeMap &targetJointModes, const Ice::Current &c=Ice::emptyCurrent) override
void setJointTorques(const NameValueMap &targetJointTorques, const Ice::Current &c=Ice::emptyCurrent) override
NameValueMap currentJointValues
SimulatorInterfacePrx simulatorPrx
PeriodicTask< KinematicUnitDynamicSimulation >::pointer_type execTask
void onInitKinematicUnit() override
void setJointAccelerations(const NameValueMap &targetJointAccelerations, const Ice::Current &c=Ice::emptyCurrent) override
void setJointDecelerations(const NameValueMap &targetJointDecelerations, const Ice::Current &c=Ice::emptyCurrent) override
DebugInfo getDebugInfo(const Ice::Current &c=Ice::emptyCurrent) const override
void reportState(SimulatedRobotState const &state, const Ice::Current &) override
void onStartKinematicUnit() override
std::set< std::string > nodeNames
NameValueMap currentJointVelTargets
NameControlModeMap currentControlModes
NameControlModeMap getControlModes(const Ice::Current &c=Ice::emptyCurrent) override
std::recursive_mutex accessMutex
void onExitKinematicUnit() override
std::string simulatorPrxName
void setJointVelocities(const NameValueMap &targetJointVelocities, const Ice::Current &c=Ice::emptyCurrent) override
std::string robotTopicName
VirtualRobot::RobotPtr robot
std::vector< VirtualRobot::RobotNodePtr > robotNodes
std::string robotNodeSetName
KinematicUnitListenerPrx listenerPrx
bool usingProxy(const std::string &name, const std::string &endpoints="")
Registers a proxy for retrieval after initialization and adds it to the dependency list.
void usingTopic(const std::string &name, bool orderedPublishing=false)
Registers a proxy for subscription after initialization.
Ice::ObjectPrx getProxy(long timeoutMs=0, bool waitForScheduler=true) const
Returns the proxy of this object (optionally it waits for the proxy)
The periodic task executes one thread method repeatedly using the time period specified in the constr...
bool hasProperty(const std::string &name)
void release(const Ice::Current &c=Ice::emptyCurrent) override
Release exclusive access to current unit.
void request(const Ice::Current &c=Ice::emptyCurrent) override
Request exclusive access to current unit.
#define ARMARX_INFO
The normal logging level.
#define ARMARX_WARNING
The logging level for unexpected behaviour, but not a serious problem.
#define ARMARX_VERBOSE
The logging level for verbose information.
This file offers overloads of toIce() and fromIce() functions for STL container types.
const LogSender::manipulator flush