31#include <VirtualRobot/Nodes/RobotNode.h>
32#include <VirtualRobot/RobotNodeSet.h>
33#include <VirtualRobot/VirtualRobot.h>
34#include <VirtualRobot/VirtualRobotException.h>
35#include <VirtualRobot/XML/RobotIO.h>
48 std::string jointName = robotNode->getName();
93 "KinematicUnitDynamicSimulation");
95 execTask->setDelayWarningTolerance(100);
110 NameValueMap angleValues;
111 NameValueMap velocitiyValues;
112 NameValueMap torqueValues;
119 if (state.jointAngles.size() > 0)
122 for (
const auto& actualJointAngle : state.jointAngles)
126 angleValues[actualJointAngle.first] = actualJointAngle.second;
135 for (
const auto& actualVelocity : state.jointVelocities)
139 velocitiyValues[actualVelocity.first] = actualVelocity.second;
145 for (
const auto& actualJointTorque : state.jointTorques)
149 torqueValues[actualJointTorque.first] = actualJointTorque.second;
155 if (angleValues.size() > 0)
157 listenerPrx->reportJointAngles(angleValues, state.timestampInMicroSeconds,
true);
159 if (velocitiyValues.size() > 0)
161 listenerPrx->reportJointVelocities(velocitiyValues, state.timestampInMicroSeconds,
true);
163 if (torqueValues.size() > 0)
165 listenerPrx->reportJointTorques(torqueValues, state.timestampInMicroSeconds,
true);
172 NameControlModeMap result;
181 result[nodeName] = ePositionControl;
185 result[nodeName] =
c->second;
194 const Ice::Current&
c)
199 NameControlModeMap::const_iterator itAng = targetJointModes.begin();
201 while (itAng != targetJointModes.end())
208 targetJointModes, IceUtil::Time::now().toMicroSeconds(),
true);
213 const Ice::Current&
c)
219 NameValueMap::const_iterator itAng = targetJointAngles.begin();
221 while (itAng != targetJointAngles.end())
230 const Ice::Current&
c)
233 NameValueMap::const_iterator itVel = targetJointVelocities.begin();
235 while (itVel != targetJointVelocities.end())
244 const Ice::Current&
c)
249 NameValueMap::const_iterator itAng = targetJointTorques.begin();
251 while (itAng != targetJointTorques.end())
260 const Ice::Current&
c)
266 const Ice::Current&
c)
276 for (
const auto& joint : joints)
292 for (
const auto& joint : joints)
311 float factorLoopTime = 1.1f;
316 NameValueMap applyPosMap;
317 NameValueMap applyVelMap;
318 NameValueMap applyPosVelMap_pos;
319 NameValueMap applyPosVelMap_vel;
320 NameValueMap applyTorMap;
325 switch (itMode->second)
327 case ePositionControl:
330 applyPosMap[itMode->first] =
336 case eVelocityControl:
347 it->second * loopTime * factorLoopTime;
348 applyPosVelMap_pos[itMode->first] = posTarget;
349 applyPosVelMap_vel[itMode->first] = it->second;
355 applyVelMap[itMode->first] =
367 applyTorMap[itMode->first] =
373 case ePositionVelocityControl:
378 applyPosVelMap_pos[itMode->first] =
380 applyPosVelMap_vel[itMode->first] =
396 if (applyPosMap.size() > 0)
398 batchPrx->actuateRobotJointsPos(
robotName, applyPosMap);
401 if (applyVelMap.size() > 0)
403 batchPrx->actuateRobotJointsVel(
robotName, applyVelMap);
406 if (applyTorMap.size() > 0)
408 batchPrx->actuateRobotJointsTorque(
robotName, applyTorMap);
411 if (applyPosVelMap_pos.size() > 0)
413 batchPrx->actuateRobotJoints(
robotName, applyPosVelMap_pos, applyPosVelMap_vel);
415 batchPrx->ice_flushBatchRequests();
432 ::armarx::NameStatusMap jointStatus;
435 jointStatus[jointName] = {
436 .operation = eOnline,
439 .emergencyStop =
false
444 .jointAngles = robotState.jointAngles,
445 .jointVelocities = robotState.jointVelocities,
446 .jointAccelerations = {},
447 .jointTorques = robotState.jointTorques,
449 .jointMotorTemperatures = {},
450 .jointStatus = jointStatus};
#define ARMARX_REGISTER_COMPONENT_EXECUTABLE(ComponentT, applicationName)
Property< PropertyType > getProperty(const std::string &name)
This component implements the KinemticUnit with access to a physics simulator.
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
static std::string GetDefaultName()
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