6 SimpleGridReachability::Result SimpleGridReachability::calculateDiffIK(
const Eigen::Matrix4f targetPose,
const Parameters& params)
8 VirtualRobot::RobotNodePtr rns = params.nodeSet;
9 VirtualRobot::RobotNodeSetPtr tcp = params.tcp ? params.tcp : rns->getTCP();
10 CartesianVelocityController velocityController(rns);
11 CartesianPositionController positionController(tcp);
13 Eigen::VectorXf initialJV = rns->getJointValuesEigen();
14 for (
size_t i = 0; i <= params.stepsInitial + params.stepsFineTune; i++)
16 Eigen::Vector3f posDiff = positionController.getPositionDiff(targetPose);
17 Eigen::Vector3f oriDiff = positionController.getOrientationDiff(targetPose);
21 Eigen::VectorXf cartesialVel(6);
22 cartesialVel << posDiff(0), posDiff(1), posDiff(2), oriDiff(0), oriDiff(1), oriDiff(2);
23 Eigen::VectorXf jnv = params.jointLimitAvoidanceKp * velocityController.calculateJointLimitAvoidance();
24 Eigen::VectorXf jv = velocityController.calculate(cartesialVel, jnv, VirtualRobot::IKSolver::All);
27 float stepLength = i < params.stepsInitial ? params.ikStepLengthInitial : params.ikStepLengthFineTune;
30 for (
size_t n = 0; n < rns->getSize(); n++)
32 rns->getNode(n)->setJointValue(rns->getNode(n)->getJointValue() + jv(n));
37 result.jointValues = rns->getJointValuesEigen();
38 result.posError = positionController.getPositionDiff(targetPose);
39 result.oriError = positionController.getOrientationError(targetPose);
40 result.reached = result.posError < params.maxPosError && result.oriError < params.maxOriError;