SimpleGridReachability.cpp
Go to the documentation of this file.
3 
4 namespace armarx
5 {
6  SimpleGridReachability::Result SimpleGridReachability::calculateDiffIK(const Eigen::Matrix4f targetPose, const Parameters& params)
7  {
8  VirtualRobot::RobotNodePtr rns = params.nodeSet;
9  VirtualRobot::RobotNodeSetPtr tcp = params.tcp ? params.tcp : rns->getTCP();
10  CartesianVelocityController velocityController(rns);
11  CartesianPositionController positionController(tcp);
12 
13  Eigen::VectorXf initialJV = rns->getJointValuesEigen();
14  for (size_t i = 0; i <= params.stepsInitial + params.stepsFineTune; i++)
15  {
16  Eigen::Vector3f posDiff = positionController.getPositionDiff(targetPose);
17  Eigen::Vector3f oriDiff = positionController.getOrientationDiff(targetPose);
18 
19  //ARMARX_IMPORTANT << VAROUT(posDiff) << VAROUT(oriDiff);
20 
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);
25 
26 
27  float stepLength = i < params.stepsInitial ? params.ikStepLengthInitial : params.ikStepLengthFineTune;
28  jv = jv * stepLength;
29 
30  for (size_t n = 0; n < rns->getSize(); n++)
31  {
32  rns->getNode(n)->setJointValue(rns->getNode(n)->getJointValue() + jv(n));
33  }
34  }
35 
36  Result result;
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;
41 
42  return result;
43  }
44 }
SimpleGridReachability.h
CartesianVelocityController.h
GfxTL::Matrix4f
MatrixXX< 4, 4, float > Matrix4f
Definition: MatrixXX.h:601
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28