CartesianVelocityController.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 ()
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/DifferentialIK.h>
27 #include <VirtualRobot/VirtualRobot.h>
28 
29 #include <Eigen/Core>
30 
31 namespace armarx
32 {
33  class CartesianVelocityController;
34  using CartesianVelocityControllerPtr = std::shared_ptr<CartesianVelocityController>;
35 
37  {
38  public:
39  CartesianVelocityController(const VirtualRobot::RobotNodeSetPtr& rns, const VirtualRobot::RobotNodePtr& tcp = nullptr,
40  const VirtualRobot::JacobiProvider::InverseJacobiMethod invJacMethod = VirtualRobot::JacobiProvider::eSVDDamped,
41  bool _considerJointLimits = true);
42 
45 
46  Eigen::VectorXf calculate(const Eigen::VectorXf& cartesianVel, VirtualRobot::IKSolver::CartesianSelection mode);
47  Eigen::VectorXf calculate(const Eigen::VectorXf& cartesianVel, float KpJointLimitAvoidanceScale, VirtualRobot::IKSolver::CartesianSelection mode);
48  Eigen::VectorXf calculate(const Eigen::VectorXf& cartesianVel, const Eigen::VectorXf& nullspaceVel, VirtualRobot::IKSolver::CartesianSelection mode);
49  Eigen::VectorXf calculateJointLimitAvoidance();
50  Eigen::VectorXf calculateJointLimitAvoidanceWithMargins(const Eigen::VectorXf& margins);
51  Eigen::VectorXf calculateNullspaceVelocity(const Eigen::VectorXf& cartesianVel, float KpScale, VirtualRobot::IKSolver::CartesianSelection mode);
52 
53  void setCartesianRegularization(float cartesianMMRegularization, float cartesianRadianRegularization);
54 
55  bool getConsiderJointLimits() const;
56  void setConsiderJointLimits(bool value);
57 
58  Eigen::MatrixXf jacobi;
59  VirtualRobot::RobotNodeSetPtr rns;
60  VirtualRobot::DifferentialIKPtr ik;
61  VirtualRobot::RobotNodePtr _tcp;
62  Eigen::VectorXf maximumJointVelocities;
63 
64  void setJointCosts(const std::vector<float>& _jointCosts);
66 
67  private:
68  void calculateJacobis(VirtualRobot::IKSolver::CartesianSelection mode);
69  Eigen::MatrixXf _jacobiWithCosts;
70  Eigen::MatrixXf _inv;
71  bool clampJacobiAtJointLimits(VirtualRobot::IKSolver::CartesianSelection mode, const Eigen::VectorXf& cartesianVel, Eigen::MatrixXf& jacobi, Eigen::MatrixXf& _inv, float jointLimitCheckAccuracy = 0.001f);
72  bool _considerJointLimits = true;
73  float _cartesianMMRegularization;
74  float _cartesianRadianRegularization;
75  Eigen::VectorXf _jointCosts;
76  };
77 }
78 
armarx::CartesianVelocityController::jacobi
Eigen::MatrixXf jacobi
Definition: CartesianVelocityController.h:58
armarx::CartesianVelocityController::calculate
Eigen::VectorXf calculate(const Eigen::VectorXf &cartesianVel, VirtualRobot::IKSolver::CartesianSelection mode)
Definition: CartesianVelocityController.cpp:71
armarx::CartesianVelocityController::calculateRegularization
Eigen::VectorXf calculateRegularization(VirtualRobot::IKSolver::CartesianSelection mode)
Definition: CartesianVelocityController.cpp:219
armarx::CartesianVelocityController::setCartesianRegularization
void setCartesianRegularization(float cartesianMMRegularization, float cartesianRadianRegularization)
Definition: CartesianVelocityController.cpp:213
armarx::CartesianVelocityController::maximumJointVelocities
Eigen::VectorXf maximumJointVelocities
Definition: CartesianVelocityController.h:62
armarx::CartesianVelocityController
Definition: CartesianVelocityController.h:36
armarx::CartesianVelocityControllerPtr
std::shared_ptr< CartesianVelocityController > CartesianVelocityControllerPtr
Definition: CartesianVelocityController.h:34
armarx::CartesianVelocityController::operator=
CartesianVelocityController & operator=(CartesianVelocityController &&)=default
cxxopts::value
std::shared_ptr< Value > value()
Definition: cxxopts.hpp:926
armarx::CartesianVelocityController::setConsiderJointLimits
void setConsiderJointLimits(bool value)
Definition: CartesianVelocityController.cpp:296
armarx::CartesianVelocityController::getConsiderJointLimits
bool getConsiderJointLimits() const
Definition: CartesianVelocityController.cpp:291
armarx::NJointTaskSpaceDMPControllerMode::CartesianSelection
CartesianSelection
Definition: ControllerInterface.ice:34
armarx::CartesianVelocityController::calculateJointLimitAvoidance
Eigen::VectorXf calculateJointLimitAvoidance()
Definition: CartesianVelocityController.cpp:152
armarx::CartesianVelocityController::calculateJointLimitAvoidanceWithMargins
Eigen::VectorXf calculateJointLimitAvoidanceWithMargins(const Eigen::VectorXf &margins)
CartesianVelocityController::calculateJointLimitAvoidanceWithMargins.
Definition: CartesianVelocityController.cpp:177
armarx::CartesianVelocityController::ik
VirtualRobot::DifferentialIKPtr ik
Definition: CartesianVelocityController.h:60
armarx::CartesianVelocityController::CartesianVelocityController
CartesianVelocityController(const VirtualRobot::RobotNodeSetPtr &rns, const VirtualRobot::RobotNodePtr &tcp=nullptr, const VirtualRobot::JacobiProvider::InverseJacobiMethod invJacMethod=VirtualRobot::JacobiProvider::eSVDDamped, bool _considerJointLimits=true)
Definition: CartesianVelocityController.cpp:38
armarx::CartesianVelocityController::setJointCosts
void setJointCosts(const std::vector< float > &_jointCosts)
Definition: CartesianVelocityController.cpp:301
armarx::CartesianVelocityController::_tcp
VirtualRobot::RobotNodePtr _tcp
Definition: CartesianVelocityController.h:61
armarx::CartesianVelocityController::calculateNullspaceVelocity
Eigen::VectorXf calculateNullspaceVelocity(const Eigen::VectorXf &cartesianVel, float KpScale, VirtualRobot::IKSolver::CartesianSelection mode)
Definition: CartesianVelocityController.cpp:201
armarx::CartesianVelocityController::rns
VirtualRobot::RobotNodeSetPtr rns
Definition: CartesianVelocityController.h:59
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28