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 <Eigen/Core>
27
28#include <VirtualRobot/IK/JacobiProvider.h>
29#include <VirtualRobot/VirtualRobot.h>
30
31namespace armarx
32{
34 using CartesianVelocityControllerPtr = std::shared_ptr<CartesianVelocityController>;
35
37 {
38 public:
39 CartesianVelocityController(const VirtualRobot::RobotNodeSetPtr& rns,
40 const VirtualRobot::RobotNodePtr& tcp = nullptr,
41 const VirtualRobot::JacobiProvider::InverseJacobiMethod
42 invJacMethod = VirtualRobot::JacobiProvider::eSVDDamped,
43 bool _considerJointLimits = true);
44
47
48 Eigen::VectorXf calculate(const Eigen::VectorXf& cartesianVel,
49 VirtualRobot::IKSolver::CartesianSelection mode);
50 Eigen::VectorXf calculate(const Eigen::VectorXf& cartesianVel,
51 float KpJointLimitAvoidanceScale,
52 VirtualRobot::IKSolver::CartesianSelection mode);
53 Eigen::VectorXf calculate(const Eigen::VectorXf& cartesianVel,
54 const Eigen::VectorXf& nullspaceVel,
55 VirtualRobot::IKSolver::CartesianSelection mode);
56 Eigen::VectorXf calculateJointLimitAvoidance();
57 Eigen::VectorXf calculateJointLimitAvoidanceWithMargins(const Eigen::VectorXf& margins);
58 Eigen::VectorXf calculateNullspaceVelocity(const Eigen::VectorXf& cartesianVel,
59 float KpScale,
60 VirtualRobot::IKSolver::CartesianSelection mode);
61
62 void setCartesianRegularization(float cartesianMMRegularization,
63 float cartesianRadianRegularization);
64
65 bool getConsiderJointLimits() const;
66 void setConsiderJointLimits(bool value);
67
68 Eigen::MatrixXf jacobi;
69 VirtualRobot::RobotNodeSetPtr rns;
70 VirtualRobot::DifferentialIKPtr ik;
71 VirtualRobot::RobotNodePtr _tcp;
72 Eigen::VectorXf maximumJointVelocities;
73
74 void setJointCosts(const std::vector<float>& _jointCosts);
75 Eigen::VectorXf calculateRegularization(VirtualRobot::IKSolver::CartesianSelection mode);
76
77 private:
78 void calculateJacobis(VirtualRobot::IKSolver::CartesianSelection mode);
79 Eigen::MatrixXf _jacobiWithCosts;
80 Eigen::MatrixXf _inv;
81 bool clampJacobiAtJointLimits(VirtualRobot::IKSolver::CartesianSelection mode,
82 const Eigen::VectorXf& cartesianVel,
83 Eigen::MatrixXf& jacobi,
84 Eigen::MatrixXf& _inv,
85 float jointLimitCheckAccuracy = 0.001f);
86 bool _considerJointLimits = true;
87 float _cartesianMMRegularization;
88 float _cartesianRadianRegularization;
89 Eigen::VectorXf _jointCosts;
90 };
91} // namespace armarx
Eigen::VectorXf calculateRegularization(VirtualRobot::IKSolver::CartesianSelection mode)
void setJointCosts(const std::vector< float > &_jointCosts)
Eigen::VectorXf calculateJointLimitAvoidanceWithMargins(const Eigen::VectorXf &margins)
CartesianVelocityController::calculateJointLimitAvoidanceWithMargins.
CartesianVelocityController & operator=(CartesianVelocityController &&)=default
Eigen::VectorXf calculate(const Eigen::VectorXf &cartesianVel, VirtualRobot::IKSolver::CartesianSelection mode)
CartesianVelocityController(const VirtualRobot::RobotNodeSetPtr &rns, const VirtualRobot::RobotNodePtr &tcp=nullptr, const VirtualRobot::JacobiProvider::InverseJacobiMethod invJacMethod=VirtualRobot::JacobiProvider::eSVDDamped, bool _considerJointLimits=true)
void setCartesianRegularization(float cartesianMMRegularization, float cartesianRadianRegularization)
Eigen::VectorXf calculateNullspaceVelocity(const Eigen::VectorXf &cartesianVel, float KpScale, VirtualRobot::IKSolver::CartesianSelection mode)
CartesianVelocityController(CartesianVelocityController &&)=default
This file offers overloads of toIce() and fromIce() functions for STL container types.
std::shared_ptr< CartesianVelocityController > CartesianVelocityControllerPtr