30 #include <RobotAPI/interface/units/KinematicUnitInterface.h>
32 #include <RobotAPI/interface/components/TrajectoryPlayerInterface.h>
35 #include <VirtualRobot/RobotConfig.h>
38 using namespace MotionControlGroup;
52 auto combinedTraj = in.getTrajectory();
54 if (in.getUseTrajectoryPlayerComponent())
56 TrajectoryPlayerInterfacePrx trajPlayer = context->
getProxy<TrajectoryPlayerInterfacePrx>(in.getTrajectoryPlayerName());
57 trajPlayer->resetTrajectoryPlayer(
false);
58 trajPlayer->considerConstraints(
false);
59 trajPlayer->setLoopPlayback(
false);
60 trajPlayer->loadJointTraj(combinedTraj);
61 trajPlayer->startTrajectoryPlayer();
62 auto endTime = trajPlayer->getEndTime();
63 double currentTime = 0;
68 currentTime = trajPlayer->getCurrentTime();
70 while (currentTime < endTime && !isRunningTaskStopped());
71 if (!isRunningTaskStopped() && currentTime >= endTime)
73 if (in.getWaitTimeAfterExecution() > 0)
75 ARMARX_INFO <<
"Waiting for " << in.getWaitTimeAfterExecution();
78 trajPlayer->pauseTrajectoryPlayer();
81 else if (isRunningTaskStopped())
83 trajPlayer->pauseTrajectoryPlayer();
89 auto duration = combinedTraj->getTimeLength();
90 auto jointNames = combinedTraj->getDimensionNames();
91 auto rns = VirtualRobot::RobotNodeSet::createRobotNodeSet(robot,
"tempset", jointNames, robot->getRootNode()->getName());
96 auto timestep = in.getTimeStep();
98 NameControlModeMap modes;
101 for (
auto& jointName : jointNames)
103 modes[jointName] = eVelocityControl;
107 while (!isRunningTaskStopped())
112 Eigen::VectorXf velocityTargets = ctrl.
update(timestep, rns->getJointValuesEigen());
114 for (
auto& jointName : jointNames)
116 targetVelocities[jointName] = velocityTargets(i);
130 for (
auto& jointName : jointNames)
132 targetVelocities[jointName] = 0;