30 using namespace MotionControlGroup;
44 if (!in.isTcpRelativeOrientationsSet() && !in.isTcpRelativePositionsSet())
46 ARMARX_ERROR <<
"TcpRelativeOrientations and/or TcpRelativePositions has to be set, but none has been set.";
50 int index = in.getIndex();
55 std::string rootFrameName = robot->getRootNode()->getName();
56 std::string agentName = robot->getName();
58 Eigen::Vector3f positionOffset = Eigen::Vector3f::Zero();
61 bool doPos = in.isTcpRelativePositionsSet();
62 bool doOri = in.isTcpRelativeOrientationsSet();
63 out.setIndex(
index + 1);
65 auto localRobot = robot->clone();
68 std::vector<FramedDirectionPtr> relativePositions = in.getTcpRelativePositions();
70 if (
static_cast<std::size_t
>(
index) >= relativePositions.size())
75 positionOffset = relativePositions.at(
index)->toRootEigen(localRobot);
79 std::vector<FramedOrientationPtr> relativeOrientations = in.getTcpRelativeOrientations();
81 if (
static_cast<std::size_t
>(
index) >= relativeOrientations.size())
86 orientationOffset = relativeOrientations.at(
index)->toRootEigen(localRobot);
89 Eigen::Vector3f referencePosition;
92 if (in.getRelativeMode() ==
"Initial")
94 referencePosition = in.getInitalTcpPosition()->toRootEigen(localRobot);
95 referenceOrientation = in.getInitailTcpOrientation()->toRootEigen(localRobot);
97 else if (in.getRelativeMode() ==
"TCP")
99 Eigen::Matrix4f currentTcpPose = robot->getRobotNodeSet(in.getKinematicChainName())->getTCP()->getPoseInRootFrame();
100 referencePosition = currentTcpPose.block<3, 1>(0, 3);
101 referenceOrientation = currentTcpPose.block<3, 3>(0, 0);
103 else if (in.getRelativeMode() ==
"Previous")
105 referencePosition = doPos ? in.getTcpPosition()->toRootEigen(localRobot) : Eigen::Vector3f::Zero();
110 ARMARX_ERROR <<
"Invalid RelativeMode '" << in.getRelativeMode() <<
"'. Valid options: 'Initial' 'TCP' 'Previous'";
117 Eigen::Vector3f targetPosition = referencePosition + positionOffset;
119 out.setTcpPosition(targetPositionPtr);
124 Eigen::Matrix3f targetOrientation = referenceOrientation * orientationOffset;
126 out.setTcpOrientation(targetOrientationPtr);
129 emitPositionControl();