CartesianNaturalPositionController.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 Raphael Grimm (raphael dot grimm 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 <Eigen/Dense>
29
30#include <VirtualRobot/Robot.h>
31
32#include <RobotAPI/interface/core/CartesianNaturalPositionControllerConfig.h>
35
37
38namespace Eigen
39{
41}
42
43namespace armarx
44{
45 class CartesianNaturalPositionController;
47 std::shared_ptr<CartesianNaturalPositionController>;
48
50 {
51 public:
52 CartesianNaturalPositionController(const VirtualRobot::RobotNodeSetPtr& rns,
53 const VirtualRobot::RobotNodePtr& elbow,
54 float maxPositionAcceleration,
55 float maxOrientationAcceleration,
56 float maxNullspaceAcceleration,
57 const VirtualRobot::RobotNodePtr& tcp = nullptr);
58
59
60 static Eigen::VectorXf LimitInfNormTo(const Eigen::VectorXf& vec,
61 const std::vector<float>& maxValue);
62 const Eigen::VectorXf calculateNullspaceTargetDifference();
63 const Eigen::VectorXf
64 calculate(float dt,
65 VirtualRobot::IKSolver::CartesianSelection mode = VirtualRobot::IKSolver::All);
66
67 void setTarget(const Eigen::Matrix4f& tcpTarget, const Eigen::Vector3f& elbowTarget);
69 void setFeedForwardVelocity(const Eigen::Vector3f& feedForwardVelocityPos,
70 const Eigen::Vector3f& feedForwardVelocityOri);
71 void setNullspaceTarget(const Eigen::VectorXf& nullspaceTarget);
72 void setNullspaceTarget(const std::vector<float>& nullspaceTarget);
75
76 float getPositionError() const;
77
78 float getOrientationError() const;
79
80 bool isTargetReached() const;
81 bool isTargetNear() const;
82
83
84 const Eigen::Matrix4f& getCurrentTarget() const;
85 const Eigen::Vector3f getCurrentTargetPosition() const;
86 const Eigen::Vector3f& getCurrentElbowTarget() const;
87 const Eigen::VectorXf& getCurrentNullspaceTarget() const;
88 bool hasNullspaceTarget() const;
89
90 void setNullSpaceControl(bool enabled);
91
92 std::string getStatusText();
93
94 void setConfig(const CartesianNaturalPositionControllerConfig& cfg);
95
96 Eigen::VectorXf actualTcpVel(const Eigen::VectorXf& jointVel);
97 Eigen::VectorXf actualElbVel(const Eigen::VectorXf& jointVel);
98
103 Eigen::VectorXf lastJointVelocity;
104
105 Eigen::Matrix4f tcpTarget;
106 Eigen::Vector3f elbowTarget;
107 Eigen::VectorXf nullspaceTarget = Eigen::VectorXf(0);
108
113
114 std::vector<float> maxJointVelocity;
115 std::vector<float> maxNullspaceVelocity;
116
117
118 Eigen::Vector6f feedForwardVelocity = Eigen::Vector6f::Zero();
119 Eigen::Vector6f cartesianVelocity = Eigen::Vector6f::Zero();
121
122
127
128 private:
129 VirtualRobot::RobotNodeSetPtr rns;
130 };
131} // namespace armarx
constexpr T dt
void setNullspaceTarget(const Eigen::VectorXf &nullspaceTarget)
const Eigen::VectorXf calculate(float dt, VirtualRobot::IKSolver::CartesianSelection mode=VirtualRobot::IKSolver::All)
static Eigen::VectorXf LimitInfNormTo(const Eigen::VectorXf &vec, const std::vector< float > &maxValue)
Eigen::VectorXf actualElbVel(const Eigen::VectorXf &jointVel)
void setConfig(const CartesianNaturalPositionControllerConfig &cfg)
CartesianNaturalPositionController(const VirtualRobot::RobotNodeSetPtr &rns, const VirtualRobot::RobotNodePtr &elbow, float maxPositionAcceleration, float maxOrientationAcceleration, float maxNullspaceAcceleration, const VirtualRobot::RobotNodePtr &tcp=nullptr)
Eigen::VectorXf actualTcpVel(const Eigen::VectorXf &jointVel)
void setFeedForwardVelocity(const Eigen::Vector6f &feedForwardVelocity)
void setTarget(const Eigen::Matrix4f &tcpTarget, const Eigen::Vector3f &elbowTarget)
Matrix< float, 6, 1 > Vector6f
This file offers overloads of toIce() and fromIce() functions for STL container types.
std::shared_ptr< CartesianNaturalPositionController > CartesianNaturalPositionControllerPtr