NaturalDiffIK.h
Go to the documentation of this file.
1 /*
2  * This file is part of ArmarX.
3  *
4  * Copyright (C) 2012-2016, High Performance Humanoid Technologies (H2T),
5  * Karlsruhe Institute of Technology (KIT), all rights reserved.
6  *
7  * ArmarX is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License version 2 as
9  * published by the Free Software Foundation.
10  *
11  * ArmarX is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18  *
19  * @author Simon Ottenhaus (simon dot ottenhaus at kit dot edu)
20  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
21  * GNU General Public License
22  */
23 
24 #pragma once
25 
26 #include <VirtualRobot/Nodes/RobotNode.h>
27 #include <VirtualRobot/RobotNodeSet.h>
28 #include <VirtualRobot/IK/DifferentialIK.h>
29 
30 
31 namespace armarx
32 {
34  {
35  public:
36  enum class Mode {Position, All};
37  struct Parameters
38  {
40  // IK params
41  float ikStepLengthInitial = 0.2f;
42  float ikStepLengthFineTune = 0.5f;
43  size_t stepsInitial = 25;
44  size_t stepsFineTune = 10;
45  float maxPosError = 10.f;
46  float maxOriError = 0.05f;
47  float jointLimitAvoidanceKp = 0.f;
48  float elbowKp = 1.0f;
49  float maxJointAngleStep = 0.1f;
50  bool resetRnsValues = true;
51  bool returnIKSteps = false;
52  };
53  struct IKStep
54  {
55  Eigen::VectorXf jointValues;
56  Eigen::Vector3f pdTcp;
57  Eigen::Vector3f odTcp;
58  Eigen::Vector3f pdElb;
61  Eigen::VectorXf cartesianVel;
62  Eigen::VectorXf cartesianVelElb;
63  Eigen::VectorXf jvElb;
64  Eigen::VectorXf jvLA;
65  Eigen::VectorXf jv;
66  Eigen::VectorXf jvClamped;
67  };
68 
69  struct Result
70  {
71  Eigen::VectorXf jointValues;
72  Eigen::Vector3f posDiff;
73  Eigen::Vector3f posDiffElbow;
74  Eigen::Vector3f oriDiff;
75  float posError;
77  float oriError;
78  bool reached;
79  Eigen::VectorXf jointLimitMargins;
81  Eigen::Vector3f elbowPosDiff;
82  std::vector<IKStep> ikSteps;
83  };
84 
85  static Eigen::VectorXf LimitInfNormTo(Eigen::VectorXf vec, float maxValue);
86  static Result CalculateDiffIK(const Eigen::Matrix4f& targetPose, const Eigen::Vector3f& elbowTarget, VirtualRobot::RobotNodeSetPtr rns, VirtualRobot::RobotNodePtr tcp, VirtualRobot::RobotNodePtr elbow, Mode setOri, Parameters params = Parameters());
88  };
89 }
armarx::NaturalDiffIK::Parameters::stepsInitial
size_t stepsInitial
Definition: NaturalDiffIK.h:43
armarx::NaturalDiffIK::Parameters::maxJointAngleStep
float maxJointAngleStep
Definition: NaturalDiffIK.h:49
armarx::NaturalDiffIK::Mode::All
@ All
armarx::NaturalDiffIK::Mode::Position
@ Position
armarx::NaturalDiffIK::LimitInfNormTo
static Eigen::VectorXf LimitInfNormTo(Eigen::VectorXf vec, float maxValue)
Definition: NaturalDiffIK.cpp:34
armarx::NaturalDiffIK::IKStep::elbPose
Eigen::Matrix4f elbPose
Definition: NaturalDiffIK.h:60
armarx::NaturalDiffIK::IKStep::pdTcp
Eigen::Vector3f pdTcp
Definition: NaturalDiffIK.h:56
armarx::NaturalDiffIK::IKStep::tcpPose
Eigen::Matrix4f tcpPose
Definition: NaturalDiffIK.h:59
armarx::NaturalDiffIK::Mode
Mode
Definition: NaturalDiffIK.h:36
armarx::NaturalDiffIK::Result::elbowPosDiff
Eigen::Vector3f elbowPosDiff
Definition: NaturalDiffIK.h:81
armarx::NaturalDiffIK::Result::reached
bool reached
Definition: NaturalDiffIK.h:78
armarx::NaturalDiffIK::IKStep::cartesianVelElb
Eigen::VectorXf cartesianVelElb
Definition: NaturalDiffIK.h:62
armarx::NaturalDiffIK
Definition: NaturalDiffIK.h:33
armarx::NaturalDiffIK::IKStep::odTcp
Eigen::Vector3f odTcp
Definition: NaturalDiffIK.h:57
armarx::NaturalDiffIK::Result::posDiffElbow
Eigen::Vector3f posDiffElbow
Definition: NaturalDiffIK.h:73
armarx::NaturalDiffIK::Result::oriError
float oriError
Definition: NaturalDiffIK.h:77
armarx::NaturalDiffIK::IKStep::jv
Eigen::VectorXf jv
Definition: NaturalDiffIK.h:65
armarx::NaturalDiffIK::Parameters::maxOriError
float maxOriError
Definition: NaturalDiffIK.h:46
armarx::NaturalDiffIK::Parameters::maxPosError
float maxPosError
Definition: NaturalDiffIK.h:45
armarx::NaturalDiffIK::Result::posError
float posError
Definition: NaturalDiffIK.h:75
armarx::NaturalDiffIK::Result::posErrorElbow
float posErrorElbow
Definition: NaturalDiffIK.h:76
armarx::NaturalDiffIK::Result::oriDiff
Eigen::Vector3f oriDiff
Definition: NaturalDiffIK.h:74
armarx::NJointTaskSpaceDMPControllerMode::CartesianSelection
CartesianSelection
Definition: ControllerInterface.ice:34
armarx::NaturalDiffIK::Result::posDiff
Eigen::Vector3f posDiff
Definition: NaturalDiffIK.h:72
armarx::NaturalDiffIK::Result::jointValues
Eigen::VectorXf jointValues
Definition: NaturalDiffIK.h:71
armarx::NaturalDiffIK::Parameters::resetRnsValues
bool resetRnsValues
Definition: NaturalDiffIK.h:50
armarx::NaturalDiffIK::Parameters::ikStepLengthFineTune
float ikStepLengthFineTune
Definition: NaturalDiffIK.h:42
armarx::NaturalDiffIK::Parameters::stepsFineTune
size_t stepsFineTune
Definition: NaturalDiffIK.h:44
armarx::NaturalDiffIK::IKStep::pdElb
Eigen::Vector3f pdElb
Definition: NaturalDiffIK.h:58
armarx::NaturalDiffIK::Parameters::Parameters
Parameters()
Definition: NaturalDiffIK.h:39
GfxTL::Matrix4f
MatrixXX< 4, 4, float > Matrix4f
Definition: MatrixXX.h:601
armarx::NaturalDiffIK::ModeToCartesianSelection
static VirtualRobot::IKSolver::CartesianSelection ModeToCartesianSelection(Mode mode)
Definition: NaturalDiffIK.cpp:186
armarx::NaturalDiffIK::IKStep::jvElb
Eigen::VectorXf jvElb
Definition: NaturalDiffIK.h:63
armarx::NaturalDiffIK::IKStep::cartesianVel
Eigen::VectorXf cartesianVel
Definition: NaturalDiffIK.h:61
armarx::NaturalDiffIK::Parameters::jointLimitAvoidanceKp
float jointLimitAvoidanceKp
Definition: NaturalDiffIK.h:47
armarx::NaturalDiffIK::CalculateDiffIK
static Result CalculateDiffIK(const Eigen::Matrix4f &targetPose, const Eigen::Vector3f &elbowTarget, VirtualRobot::RobotNodeSetPtr rns, VirtualRobot::RobotNodePtr tcp, VirtualRobot::RobotNodePtr elbow, Mode setOri, Parameters params=Parameters())
Definition: NaturalDiffIK.cpp:44
armarx::NaturalDiffIK::Parameters
Definition: NaturalDiffIK.h:37
armarx::NaturalDiffIK::Result
Definition: NaturalDiffIK.h:69
armarx::NaturalDiffIK::IKStep::jointValues
Eigen::VectorXf jointValues
Definition: NaturalDiffIK.h:55
armarx::NaturalDiffIK::Parameters::returnIKSteps
bool returnIKSteps
Definition: NaturalDiffIK.h:51
armarx::NaturalDiffIK::IKStep
Definition: NaturalDiffIK.h:53
armarx::NaturalDiffIK::Parameters::ikStepLengthInitial
float ikStepLengthInitial
Definition: NaturalDiffIK.h:41
armarx::NaturalDiffIK::Result::ikSteps
std::vector< IKStep > ikSteps
Definition: NaturalDiffIK.h:82
armarx::NaturalDiffIK::Parameters::elbowKp
float elbowKp
Definition: NaturalDiffIK.h:48
armarx::NaturalDiffIK::IKStep::jvLA
Eigen::VectorXf jvLA
Definition: NaturalDiffIK.h:64
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
armarx::NaturalDiffIK::Result::minimumJointLimitMargin
float minimumJointLimitMargin
Definition: NaturalDiffIK.h:80
armarx::NaturalDiffIK::IKStep::jvClamped
Eigen::VectorXf jvClamped
Definition: NaturalDiffIK.h:66
armarx::NaturalDiffIK::Result::jointLimitMargins
Eigen::VectorXf jointLimitMargins
Definition: NaturalDiffIK.h:79