26 #include "../MotionControlGroupStatechartContext.h"
32 #include <VirtualRobot/LinkedCoordinate.h>
35 using namespace MotionControlGroup;
56 std::string kinChainName = in.getKinematicChainName();
57 float positionTolerance = in.getTcpPositionTolerance();
58 float orientationTolerance = in.getTcpOrientationTolerance();
68 if (!robot->hasRobotNodeSet(kinChainName))
77 float tcpPositionDistanceToTarget = 0;
78 float tcpOrientationDistanceToTarget = 0;
81 if (isInputParameterSet(
"TcpTargetPosition"))
83 framedPosition = in.getTcpTargetPosition();
84 tcpPositionDistanceToTarget = (framedPosition->toGlobal(robot)->toEigen() - robot->getRobotNodeSet(kinChainName)->getTCP()->getGlobalPose().block<3, 1>(0, 3)).norm();
88 if (isInputParameterSet(
"TcpTargetOrientation"))
90 framedOrientation = in.getTcpTargetOrientation();
91 auto globalOri = framedOrientation->toGlobal(robot);
94 Eigen::Quaternionf currentOrientation(robot->getRobotNodeSet(kinChainName)->getTCP()->getGlobalPose().block<3, 3>(0, 0));
96 tcpOrientationDistanceToTarget = currentOrientation.angularDistance(targetOrientation);
99 out.setTcpFinalPositionDistanceToTarget(tcpPositionDistanceToTarget);
100 out.setTcpFinalOrientationDistanceToTarget(tcpOrientationDistanceToTarget);
103 if (in.getDontMoveIfAlreadyClose() && tcpPositionDistanceToTarget < positionTolerance && tcpOrientationDistanceToTarget < orientationTolerance)
109 ARMARX_INFO <<
"Target not yet reached: position distance = " << tcpPositionDistanceToTarget <<
" (Tolerance: " << positionTolerance <<
"), orientation distance = "
110 << tcpOrientationDistanceToTarget <<
" (Tolerance: " << orientationTolerance <<
")";
111 emitTargetNotReached();