27 #include <VirtualRobot/RobotConfig.h>
28 #include <VirtualRobot/RobotNodeSet.h>
33 #include <RobotAPI/interface/components/TrajectoryPlayerInterface.h>
34 #include <RobotAPI/interface/units/KinematicUnitInterface.h>
39 using namespace MotionControlGroup;
42 MoveJointTrajectory::SubClassRegistry
55 getContext<MotionControlGroupStatechartContext>();
58 auto combinedTraj = in.getTrajectory();
60 if (in.getUseTrajectoryPlayerComponent())
62 TrajectoryPlayerInterfacePrx trajPlayer =
63 context->
getProxy<TrajectoryPlayerInterfacePrx>(in.getTrajectoryPlayerName());
64 trajPlayer->resetTrajectoryPlayer(
false);
65 trajPlayer->considerConstraints(
false);
66 trajPlayer->setLoopPlayback(
false);
67 trajPlayer->loadJointTraj(combinedTraj);
68 trajPlayer->startTrajectoryPlayer();
69 auto endTime = trajPlayer->getEndTime();
70 double currentTime = 0;
74 <<
" endTime: " << endTime;
76 currentTime = trajPlayer->getCurrentTime();
77 }
while (currentTime < endTime && !isRunningTaskStopped());
78 if (!isRunningTaskStopped() && currentTime >= endTime)
80 if (in.getWaitTimeAfterExecution() > 0)
82 ARMARX_INFO <<
"Waiting for " << in.getWaitTimeAfterExecution();
85 trajPlayer->pauseTrajectoryPlayer();
88 else if (isRunningTaskStopped())
90 trajPlayer->pauseTrajectoryPlayer();
96 auto duration = combinedTraj->getTimeLength();
97 auto jointNames = combinedTraj->getDimensionNames();
98 auto rns = VirtualRobot::RobotNodeSet::createRobotNodeSet(
99 robot,
"tempset", jointNames, robot->getRootNode()->getName());
102 auto timestep = in.getTimeStep();
104 NameControlModeMap modes;
107 for (
auto& jointName : jointNames)
109 modes[jointName] = eVelocityControl;
113 while (!isRunningTaskStopped())
118 Eigen::VectorXf velocityTargets = ctrl.
update(timestep, rns->getJointValuesEigen());
120 for (
auto& jointName : jointNames)
122 targetVelocities[jointName] = velocityTargets(i);
128 <<
" Duration: " << duration;
137 for (
auto& jointName : jointNames)
139 targetVelocities[jointName] = 0;