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 
34 #include <RobotAPI/interface/core/CartesianNaturalPositionControllerConfig.h>
35 
37 
38 namespace Eigen
39 {
41 }
42 
43 
44 namespace armarx
45 {
46  class CartesianNaturalPositionController;
47  using CartesianNaturalPositionControllerPtr = 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 
61  static Eigen::VectorXf LimitInfNormTo(const Eigen::VectorXf& vec, const std::vector<float>& maxValue);
62  const Eigen::VectorXf calculateNullspaceTargetDifference();
63  const Eigen::VectorXf calculate(float dt, VirtualRobot::IKSolver::CartesianSelection mode = VirtualRobot::IKSolver::All);
64 
65  void setTarget(const Eigen::Matrix4f& tcpTarget, const Eigen::Vector3f& elbowTarget);
67  void setFeedForwardVelocity(const Eigen::Vector3f& feedForwardVelocityPos, const Eigen::Vector3f& feedForwardVelocityOri);
68  void setNullspaceTarget(const Eigen::VectorXf& nullspaceTarget);
69  void setNullspaceTarget(const std::vector<float>& nullspaceTarget);
70  void clearNullspaceTarget();
72 
73  float getPositionError() const;
74 
75  float getOrientationError() const;
76 
77  bool isTargetReached() const;
78  bool isTargetNear() const;
79 
80 
81  const Eigen::Matrix4f& getCurrentTarget() const;
82  const Eigen::Vector3f getCurrentTargetPosition() const;
83  const Eigen::Vector3f& getCurrentElbowTarget() const;
84  const Eigen::VectorXf& getCurrentNullspaceTarget() const;
85  bool hasNullspaceTarget() const;
86 
87  void setNullSpaceControl(bool enabled);
88 
89  std::string getStatusText();
90 
91  void setConfig(const CartesianNaturalPositionControllerConfig& cfg);
92 
93  Eigen::VectorXf actualTcpVel(const Eigen::VectorXf& jointVel);
94  Eigen::VectorXf actualElbVel(const Eigen::VectorXf& jointVel);
95 
100  Eigen::VectorXf lastJointVelocity;
101 
103  Eigen::Vector3f elbowTarget;
104  Eigen::VectorXf nullspaceTarget = Eigen::VectorXf(0);
105 
110 
111  std::vector<float> maxJointVelocity;
112  std::vector<float> maxNullspaceVelocity;
113 
114 
115  Eigen::Vector6f feedForwardVelocity = Eigen::Vector6f::Zero();
116  Eigen::Vector6f cartesianVelocity = Eigen::Vector6f::Zero();
117  bool autoClearFeedForward = true;
118 
119 
123  float nullspaceTargetKp = 0;
124 
125  private:
126  VirtualRobot::RobotNodeSetPtr rns;
127  };
128 }
armarx::CartesianNaturalPositionController::maxNullspaceVelocity
std::vector< float > maxNullspaceVelocity
Definition: CartesianNaturalPositionController.h:112
Eigen
Definition: Elements.h:36
armarx::CartesianNaturalPositionControllerPtr
std::shared_ptr< CartesianNaturalPositionController > CartesianNaturalPositionControllerPtr
Definition: CartesianNaturalPositionController.h:47
armarx::CartesianNaturalPositionController::clearFeedForwardVelocity
void clearFeedForwardVelocity()
Definition: CartesianNaturalPositionController.cpp:200
armarx::CartesianNaturalPositionController::clearNullspaceTarget
void clearNullspaceTarget()
Definition: CartesianNaturalPositionController.cpp:195
armarx::CartesianNaturalPositionController::autoClearFeedForward
bool autoClearFeedForward
Definition: CartesianNaturalPositionController.h:117
armarx::CartesianNaturalPositionController::pcElb
CartesianPositionController pcElb
Definition: CartesianNaturalPositionController.h:99
armarx::CartesianNaturalPositionController
Definition: CartesianNaturalPositionController.h:49
armarx::CartesianNaturalPositionController::calculate
const Eigen::VectorXf calculate(float dt, VirtualRobot::IKSolver::CartesianSelection mode=VirtualRobot::IKSolver::All)
Definition: CartesianNaturalPositionController.cpp:104
armarx::CartesianNaturalPositionController::setNullspaceTarget
void setNullspaceTarget(const Eigen::VectorXf &nullspaceTarget)
Definition: CartesianNaturalPositionController.cpp:181
armarx::CartesianNaturalPositionController::calculateNullspaceTargetDifference
const Eigen::VectorXf calculateNullspaceTargetDifference()
Definition: CartesianNaturalPositionController.cpp:82
Pose.h
armarx::CartesianNaturalPositionController::pcTcp
CartesianPositionController pcTcp
Definition: CartesianNaturalPositionController.h:97
armarx::CartesianNaturalPositionController::nullspaceTargetKp
float nullspaceTargetKp
Definition: CartesianNaturalPositionController.h:123
armarx::CartesianNaturalPositionController::jointLimitAvoidanceKp
float jointLimitAvoidanceKp
Definition: CartesianNaturalPositionController.h:122
armarx::CartesianNaturalPositionController::thresholdPositionNear
float thresholdPositionNear
Definition: CartesianNaturalPositionController.h:108
armarx::CartesianNaturalPositionController::elbowTarget
Eigen::Vector3f elbowTarget
Definition: CartesianNaturalPositionController.h:103
armarx::CartesianNaturalPositionController::getCurrentTarget
const Eigen::Matrix4f & getCurrentTarget() const
Definition: CartesianNaturalPositionController.cpp:225
armarx::CartesianVelocityController
Definition: CartesianVelocityController.h:36
CartesianVelocityControllerWithRamp.h
armarx::CartesianNaturalPositionController::setConfig
void setConfig(const CartesianNaturalPositionControllerConfig &cfg)
Definition: CartesianNaturalPositionController.cpp:270
armarx::CartesianNaturalPositionController::getCurrentElbowTarget
const Eigen::Vector3f & getCurrentElbowTarget() const
Definition: CartesianNaturalPositionController.cpp:235
armarx::CartesianNaturalPositionController::thresholdOrientationNear
float thresholdOrientationNear
Definition: CartesianNaturalPositionController.h:109
armarx::CartesianNaturalPositionController::setNullSpaceControl
void setNullSpaceControl(bool enabled)
Definition: CartesianNaturalPositionController.cpp:257
armarx::CartesianNaturalPositionController::LimitInfNormTo
static Eigen::VectorXf LimitInfNormTo(const Eigen::VectorXf &vec, const std::vector< float > &maxValue)
Definition: CartesianNaturalPositionController.cpp:60
armarx::CartesianNaturalPositionController::setTarget
void setTarget(const Eigen::Matrix4f &tcpTarget, const Eigen::Vector3f &elbowTarget)
Definition: CartesianNaturalPositionController.cpp:164
armarx::CartesianNaturalPositionController::cartesianVelocity
Eigen::Vector6f cartesianVelocity
Definition: CartesianNaturalPositionController.h:116
armarx::CartesianNaturalPositionController::actualElbVel
Eigen::VectorXf actualElbVel(const Eigen::VectorXf &jointVel)
Definition: CartesianNaturalPositionController.cpp:307
armarx::CartesianNaturalPositionController::feedForwardVelocity
Eigen::Vector6f feedForwardVelocity
Definition: CartesianNaturalPositionController.h:115
armarx::CartesianNaturalPositionController::isTargetReached
bool isTargetReached() const
Definition: CartesianNaturalPositionController.cpp:215
armarx::CartesianNaturalPositionController::vcElb
CartesianVelocityController vcElb
Definition: CartesianNaturalPositionController.h:98
armarx::CartesianNaturalPositionController::isTargetNear
bool isTargetNear() const
Definition: CartesianNaturalPositionController.cpp:220
armarx::NJointTaskSpaceDMPControllerMode::CartesianSelection
CartesianSelection
Definition: ControllerInterface.ice:34
enabled
std::atomic< bool > * enabled
Definition: RemoteGuiWidgetController.cpp:75
armarx::CartesianNaturalPositionController::maxJointVelocity
std::vector< float > maxJointVelocity
Definition: CartesianNaturalPositionController.h:111
armarx::CartesianNaturalPositionController::getCurrentNullspaceTarget
const Eigen::VectorXf & getCurrentNullspaceTarget() const
Definition: CartesianNaturalPositionController.cpp:240
armarx::CartesianNaturalPositionController::getOrientationError
float getOrientationError() const
Definition: CartesianNaturalPositionController.cpp:210
armarx::CartesianNaturalPositionController::thresholdOrientationReached
float thresholdOrientationReached
Definition: CartesianNaturalPositionController.h:107
armarx::CartesianNaturalPositionController::vcTcp
CartesianVelocityControllerWithRamp vcTcp
Definition: CartesianNaturalPositionController.h:96
armarx::CartesianNaturalPositionController::jointLimitAvoidanceScale
float jointLimitAvoidanceScale
Definition: CartesianNaturalPositionController.h:121
armarx::CartesianNaturalPositionController::getCurrentTargetPosition
const Eigen::Vector3f getCurrentTargetPosition() const
Definition: CartesianNaturalPositionController.cpp:230
CartesianPositionController.h
armarx::CartesianNaturalPositionController::tcpTarget
Eigen::Matrix4f tcpTarget
Definition: CartesianNaturalPositionController.h:102
armarx::CartesianNaturalPositionController::lastJointVelocity
Eigen::VectorXf lastJointVelocity
Definition: CartesianNaturalPositionController.h:100
GfxTL::Matrix4f
MatrixXX< 4, 4, float > Matrix4f
Definition: MatrixXX.h:601
armarx::CartesianNaturalPositionController::hasNullspaceTarget
bool hasNullspaceTarget() const
Definition: CartesianNaturalPositionController.cpp:245
armarx::CartesianNaturalPositionController::getStatusText
std::string getStatusText()
Definition: CartesianNaturalPositionController.cpp:262
armarx::CartesianNaturalPositionController::getPositionError
float getPositionError() const
Definition: CartesianNaturalPositionController.cpp:205
armarx::CartesianNaturalPositionController::thresholdPositionReached
float thresholdPositionReached
Definition: CartesianNaturalPositionController.h:106
armarx::CartesianNaturalPositionController::CartesianNaturalPositionController
CartesianNaturalPositionController(const VirtualRobot::RobotNodeSetPtr &rns, const VirtualRobot::RobotNodePtr &elbow, float maxPositionAcceleration, float maxOrientationAcceleration, float maxNullspaceAcceleration, const VirtualRobot::RobotNodePtr &tcp=nullptr)
Definition: CartesianNaturalPositionController.cpp:37
armarx::CartesianPositionController
Definition: CartesianPositionController.h:41
armarx::CartesianNaturalPositionController::setFeedForwardVelocity
void setFeedForwardVelocity(const Eigen::Vector6f &feedForwardVelocity)
Definition: CartesianNaturalPositionController.cpp:170
Eigen::Matrix< float, 6, 1 >
armarx::CartesianVelocityControllerWithRamp
Definition: CartesianVelocityControllerWithRamp.h:42
armarx::CartesianNaturalPositionController::actualTcpVel
Eigen::VectorXf actualTcpVel(const Eigen::VectorXf &jointVel)
Definition: CartesianNaturalPositionController.cpp:302
armarx::CartesianNaturalPositionController::nullSpaceControlEnabled
bool nullSpaceControlEnabled
Definition: CartesianNaturalPositionController.h:120
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
dt
constexpr T dt
Definition: UnscentedKalmanFilterTest.cpp:42
armarx::CartesianNaturalPositionController::nullspaceTarget
Eigen::VectorXf nullspaceTarget
Definition: CartesianNaturalPositionController.h:104