SimpleDiffIK.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 <memory>
27
28#include <VirtualRobot/VirtualRobot.h>
29
30#include "DiffIKProvider.h"
31
32namespace armarx
33{
34 using SimpleDiffIKPtr = std::shared_ptr<class SimpleDiffIK>;
35
37 {
38 public:
40 {
42 {
43 }
44
45 // IK params
46 float ikStepLengthInitial = 0.2f;
48 size_t stepsInitial = 25;
49 size_t stepsFineTune = 10;
50 float maxPosError = 10.f;
51 float maxOriError = 0.05f;
53 float maxJointAngleStep = 0.1f;
54 bool returnIKSteps = false;
55 bool resetRnsValues = true;
56 };
57
58 struct IKStep
59 {
60 Eigen::VectorXf jointValues;
61 Eigen::Vector3f posDiff;
62 Eigen::Vector3f oriDiff;
63 Eigen::VectorXf cartesianVel;
64 Eigen::VectorXf jnv;
65 Eigen::VectorXf jv;
66 float infNorm;
67 Eigen::VectorXf jvClamped;
68 };
69
70 struct Result
71 {
72 Eigen::VectorXf jointValues;
73 Eigen::Vector3f posDiff;
74 Eigen::Vector3f oriDiff;
75 float posError;
76 float oriError;
77 bool reached;
78 Eigen::VectorXf jointLimitMargins;
80 std::vector<IKStep> ikSteps;
81 };
82
84 {
85
86 bool reachable = true;
88 Eigen::VectorXf jointLimitMargins;
89 float maxPosError = 0;
90 float maxOriError = 0;
91 std::vector<Result> ikResults;
92
93 void aggregate(const Result& result);
94 };
95
96 static Result CalculateDiffIK(const Eigen::Matrix4f targetPose,
97 VirtualRobot::RobotNodeSetPtr rns,
98 VirtualRobot::RobotNodePtr tcp = VirtualRobot::RobotNodePtr(),
99 Parameters params = Parameters());
100
101 ///@brief Use this to check a trajectory of waypoints
102 static Reachability
103 CalculateReachability(const std::vector<Eigen::Matrix4f> targets,
104 const Eigen::VectorXf& initialJV,
105 VirtualRobot::RobotNodeSetPtr rns,
106 VirtualRobot::RobotNodePtr tcp = VirtualRobot::RobotNodePtr(),
107 Parameters params = Parameters());
108 };
109
111 {
112 public:
113 SimpleDiffIKProvider(VirtualRobot::RobotNodeSetPtr rns,
114 VirtualRobot::RobotNodePtr tcp = VirtualRobot::RobotNodePtr(),
116 DiffIKResult SolveAbsolute(const Eigen::Matrix4f& targetPose);
117 DiffIKResult SolveRelative(const Eigen::Matrix4f& targetPose,
118 const Eigen::VectorXf& startJointValues);
119
120 private:
121 VirtualRobot::RobotNodeSetPtr rns;
122 VirtualRobot::RobotNodePtr tcp;
124 };
125} // namespace armarx
#define M_PI
Definition MathTools.h:17
DiffIKResult SolveAbsolute(const Eigen::Matrix4f &targetPose)
SimpleDiffIKProvider(VirtualRobot::RobotNodeSetPtr rns, VirtualRobot::RobotNodePtr tcp=VirtualRobot::RobotNodePtr(), SimpleDiffIK::Parameters params=SimpleDiffIK::Parameters())
DiffIKResult SolveRelative(const Eigen::Matrix4f &targetPose, const Eigen::VectorXf &startJointValues)
static Reachability CalculateReachability(const std::vector< Eigen::Matrix4f > targets, const Eigen::VectorXf &initialJV, VirtualRobot::RobotNodeSetPtr rns, VirtualRobot::RobotNodePtr tcp=VirtualRobot::RobotNodePtr(), Parameters params=Parameters())
Use this to check a trajectory of waypoints.
static Result CalculateDiffIK(const Eigen::Matrix4f targetPose, VirtualRobot::RobotNodeSetPtr rns, VirtualRobot::RobotNodePtr tcp=VirtualRobot::RobotNodePtr(), Parameters params=Parameters())
Brief description of class targets.
Definition targets.h:39
This file offers overloads of toIce() and fromIce() functions for STL container types.
std::shared_ptr< class SimpleDiffIK > SimpleDiffIKPtr
std::vector< Result > ikResults
void aggregate(const Result &result)
Eigen::VectorXf jointLimitMargins
std::vector< IKStep > ikSteps