30 #include <VirtualRobot/Robot.h>
31 #include <VirtualRobot/XML/RobotIO.h>
32 #include <VirtualRobot/IK/GazeIK.h>
33 #include <VirtualRobot/LinkedCoordinate.h>
35 #include <Eigen/Eigen>
40 using namespace MotionControlGroup;
68 while (!isRunningTaskStopped())
79 VirtualRobot::RobotNodeSetPtr kinematicChain = robot->getRobotNodeSet(in.getKinematicChainName());
83 ARMARX_WARNING <<
"No kinematicChain with name " << in.getKinematicChainName();
89 if (in.isVirtualPrismaticJointNameSet())
91 tcpName = in.getVirtualPrismaticJointName();
95 tcpName = kinematicChain->getTCP()->getName();
98 VirtualRobot::RobotNodePrismaticPtr virtualJoint = std::dynamic_pointer_cast<VirtualRobot::RobotNodePrismatic>(robot->getRobotNode(tcpName));
102 ARMARX_WARNING <<
"No virtualJoint with name '" << tcpName <<
"'";
106 VirtualRobot::GazeIK ikSolver(kinematicChain, virtualJoint);
107 ikSolver.setup(30, 50, 30);
108 ikSolver.enableJointLimitAvoidance(
true);
116 Eigen::Vector3f targetPosRootFrame = goalInRoot.block<3, 1>(0, 3);
122 ARMARX_INFO <<
"Calculating IK for target position in root frame " << targetPosRootFrame;
124 if (!ikSolver.solve(globalPose.block<3, 1>(0, 3)))
132 std::map<std::string, float> targetJointValues;
134 for (
int i = 0; i < (
signed int)kinematicChain->getSize(); i++)
136 if (kinematicChain->getNode(i)->getName().compare(tcpName) != 0)
138 targetJointValues[kinematicChain->getNode(i)->getName()] = kinematicChain->getNode(i)->getJointValue();
139 ARMARX_INFO <<
" joint: " << kinematicChain->getNode(i)->getName() <<
" value: " << kinematicChain->getNode(i)->getJointValue();
143 ARMARX_INFO <<
"number of joints to be set: " << targetJointValues.size();
144 ARMARX_INFO <<
"setting output: targetJointValues";
145 out.setTargetJointValues(targetJointValues);
146 emitCalculationDone();