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/IK/IKSolver.h>
27#include <VirtualRobot/VirtualRobot.h>
28
29namespace armarx
30{
32 {
33 public:
34 enum class Mode
35 {
38 };
39
41 {
43 {
44 }
45
46 // IK params
47 float ikStepLengthInitial = 0.2f;
49 size_t stepsInitial = 25;
50 size_t stepsFineTune = 10;
51 float maxPosError = 10.f;
52 float maxOriError = 0.05f;
54 float elbowKp = 1.0f;
55 float maxJointAngleStep = 0.1f;
56 bool resetRnsValues = true;
57 bool returnIKSteps = false;
58 };
59
60 struct IKStep
61 {
62 Eigen::VectorXf jointValues;
63 Eigen::Vector3f pdTcp;
64 Eigen::Vector3f odTcp;
65 Eigen::Vector3f pdElb;
66 Eigen::Matrix4f tcpPose;
67 Eigen::Matrix4f elbPose;
68 Eigen::VectorXf cartesianVel;
69 Eigen::VectorXf cartesianVelElb;
70 Eigen::VectorXf jvElb;
71 Eigen::VectorXf jvLA;
72 Eigen::VectorXf jv;
73 Eigen::VectorXf jvClamped;
74 };
75
76 struct Result
77 {
78 Eigen::VectorXf jointValues;
79 Eigen::Vector3f posDiff;
80 Eigen::Vector3f posDiffElbow;
81 Eigen::Vector3f oriDiff;
82 float posError;
84 float oriError;
85 bool reached;
86 Eigen::VectorXf jointLimitMargins;
88 Eigen::Vector3f elbowPosDiff;
89 std::vector<IKStep> ikSteps;
90 };
91
92 static Eigen::VectorXf LimitInfNormTo(Eigen::VectorXf vec, float maxValue);
93 static Result CalculateDiffIK(const Eigen::Matrix4f& targetPose,
94 const Eigen::Vector3f& elbowTarget,
95 VirtualRobot::RobotNodeSetPtr rns,
96 VirtualRobot::RobotNodePtr tcp,
97 VirtualRobot::RobotNodePtr elbow,
98 Mode setOri,
99 Parameters params = Parameters());
100 static VirtualRobot::IKSolver::CartesianSelection ModeToCartesianSelection(Mode mode);
101 };
102} // namespace armarx
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())
static VirtualRobot::IKSolver::CartesianSelection ModeToCartesianSelection(Mode mode)
static Eigen::VectorXf LimitInfNormTo(Eigen::VectorXf vec, float maxValue)
This file offers overloads of toIce() and fromIce() functions for STL container types.
Eigen::VectorXf jointLimitMargins
std::vector< IKStep > ikSteps