26 #include <VirtualRobot/IK/DifferentialIK.h>
27 #include <VirtualRobot/Nodes/RobotNode.h>
28 #include <VirtualRobot/Robot.h>
29 #include <VirtualRobot/RobotNodeSet.h>
38 const VirtualRobot::RobotNodePtr& tcp,
39 const VirtualRobot::RobotNodePtr& referenceFrame) :
40 tcp(tcp), referenceFrame(referenceFrame ? referenceFrame : tcp->getRobot()->getRootNode())
51 Eigen::VectorXf cartesianVel(posLen + oriLen);
56 Eigen::Vector3f targetPos = targetPose.block<3, 1>(0, 3);
57 Eigen::Vector3f currentPos = tcp->getPositionInFrame(referenceFrame);
58 Eigen::Vector3f errPos = targetPos - currentPos;
59 Eigen::Vector3f posVel = errPos *
KpPos;
64 cartesianVel.block<3, 1>(0, 0) = posVel;
71 Eigen::Matrix3f tcpOri = tcp->getPoseInFrame(referenceFrame).block<3, 3>(0, 0);
73 Eigen::AngleAxisf aa(oriDir);
74 Eigen::Vector3f errOri = aa.axis() * aa.angle();
75 Eigen::Vector3f oriVel = errOri *
KpOri;
81 cartesianVel.block<3, 1>(posLen, 0) = oriVel;
90 Eigen::VectorXf cartesianVel(3);
91 Eigen::Vector3f currentPos = tcp->getPositionInFrame(referenceFrame);
92 Eigen::Vector3f errPos = targetPos - currentPos;
93 Eigen::Vector3f posVel = errPos *
KpPos;
99 cartesianVel.block<3, 1>(0, 0) = posVel;
117 const VirtualRobot::RobotNodePtr& tcp,
118 const VirtualRobot::RobotNodePtr& referenceFrame)
121 Eigen::Vector3f targetPos = targetPose.block<3, 1>(0, 3);
122 Eigen::Vector3f tcpPos = referenceFrame ? tcp->getPositionInFrame(referenceFrame)
123 : tcp->getPositionInRootFrame();
124 Eigen::Vector3f errPos = targetPos - tcpPos;
125 return errPos.norm();
131 const VirtualRobot::RobotNodePtr& tcp,
132 const VirtualRobot::RobotNodePtr& referenceFrame)
137 referenceFrame ? tcp->getPoseInFrame(referenceFrame) : tcp->getPoseInRootFrame();
140 Eigen::AngleAxisf aa(oriDir);
146 const VirtualRobot::RobotNodePtr& tcp,
148 float thresholdPosReached,
149 float thresholdOriReached,
150 const VirtualRobot::RobotNodePtr& referenceFrame)
152 return GetPositionError(targetPose, tcp, referenceFrame) < thresholdPosReached &&
160 float thresholdPosReached,
161 float thresholdOriReached)
166 if (
GetPositionError(targetPose, tcp, referenceFrame) > thresholdPosReached)
185 Eigen::Vector3f targetPos = targetPose.block<3, 1>(0, 3);
186 return targetPos - tcp->getPositionInFrame(referenceFrame);
192 return targetPosition - tcp->getPositionInFrame(referenceFrame);
200 Eigen::Matrix3f tcpOri = tcp->getPoseInFrame(referenceFrame).block<3, 3>(0, 0);
202 Eigen::AngleAxisf aa(oriDir);
203 return aa.axis() * aa.angle();
206 VirtualRobot::RobotNodePtr
212 #define SS_OUT(x) ss << #x << " = " << x << "\n"
213 #define SET_FLT(x) obj->setFloat(#x, x)
214 #define GET_FLT(x) x = obj->getFloat(#x);
223 std::stringstream ss;
229 SS_OUT(thresholdOrientationNear);
230 SS_OUT(thresholdOrientationReached);
231 SS_OUT(thresholdPositionNear);
232 SS_OUT(thresholdPositionReached);
239 const Ice::Current&)
const
247 SET_FLT(thresholdOrientationNear);
248 SET_FLT(thresholdOrientationReached);
249 SET_FLT(thresholdPositionNear);
250 SET_FLT(thresholdPositionReached);
263 GET_FLT(thresholdOrientationNear);
264 GET_FLT(thresholdOrientationReached);
265 GET_FLT(thresholdPositionNear);
266 GET_FLT(thresholdPositionReached);