common.h
Go to the documentation of this file.
1/**
2 * This file is part of ArmarX.
3 *
4 * ArmarX is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * ArmarX is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * @author Jianfeng Gao ( jianfeng dot gao at kit dot edu )
17 * @date 2022
18 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
19 * GNU General Public License
20 */
21
22#pragma once
23
24#include <cstddef>
25#include <vector>
26
27#include <Eigen/Core>
28#include <Eigen/Geometry>
29
30#include <ArmarXCore/interface/serialization/Eigen.h>
31
33{
34
36 {
37 Eigen::VectorXf jointPosition;
38 Eigen::VectorXf jointVelocity;
39 Eigen::VectorXf jointTorque;
40
41 double deltaT = 0;
42 double accumulateTime = 0.0;
43 size_t nDoF = 0;
44 size_t nDoFTorque = 0;
45 size_t nDoFVelocity = 0;
46
47 std::vector<size_t> jointIDTorqueMode;
48 std::vector<size_t> jointIDVelocityMode;
49
50 Eigen::Matrix4f globalPose;
51
52 virtual ~RobotStatus() = default;
53 virtual void reset(size_t nJoints,
54 const std::vector<size_t>& jointIDTorqueCtrlMode,
55 const std::vector<size_t>& jointIDVelocityCtrlMode);
56 };
57
59 {
60
61
62 /// targets
63 Eigen::VectorXf desiredJointTorque;
64 Eigen::VectorXf desiredJointVelocity;
65 Eigen::VectorXf desiredJointPosition;
66 Eigen::VectorXf nullspaceTorque;
67 Eigen::VectorXf nullspaceVelocity;
68
69 /// force torque
72
73 /// task space variables (command in operation space)
74 Eigen::Vector6f forceImpedance; /// for impedance control
75 Eigen::Vector6f cartesianVelTarget; /// for velocity control
76
77 /// current status
78 Eigen::VectorXf qvelFiltered;
79 Eigen::Matrix4f currentPose;
81 Eigen::Matrix4f desiredPose;
82 Eigen::Matrix4f desiredPoseUnsafe;
83
84 /// intermediate results
85 Eigen::Matrix3f poseDiffMatImp;
87 Eigen::AngleAxisf oriDiffAngleAxis;
88
89 /// intermediate results for admittance controller
90 Eigen::Matrix3f poseDiffMatAdm;
92
93 Eigen::Matrix4f virtualPose;
99
100 /// inertia
101 /// Note, the inertia variables are only used for collision avoidance controllers, as the
102 /// inertia is obtained from the simox robot that exists only in collision avoidance controllers
103 /// TODO, use simox to obtain inertia
104 Eigen::MatrixXd inertia;
105 Eigen::MatrixXf inertiaInv;
106 Eigen::MatrixXd inertiaVelCtrlJoints;
107 Eigen::MatrixXf inertiaInvVelCtrlJoints;
108 Eigen::MatrixXf IVelCtrlJoint;
109 Eigen::VectorXf qdPos;
110 Eigen::VectorXf qdVel;
111 Eigen::VectorXf qdAcc;
112 Eigen::VectorXf qTemp;
113
114 /// others
115 /// jacobi matrix [6, nDoF]
116 Eigen::MatrixXf jacobi;
117 /// pseudo inverse of the jacobi transpose [6, nDoF], for torque control
118 Eigen::MatrixXf jtpinv;
119
120 /// pseudo inverse of the jacobi [nDoF, 6], for vel control
121 Eigen::MatrixXf jpinv;
122
123 /// for computing nullspace projection
124 Eigen::MatrixXf I;
125
126 /// damping term for pseudo inverse of jacobian
127 float lambda = 2.0f;
128
129 bool rtSafe = false;
130 bool rtTargetSafe = false;
131 bool forceTorqueSafe = false;
132
133 void reset(size_t numDoF,
134 const std::vector<size_t>& jointIDTorqueMode,
135 const std::vector<size_t>& jointIDVelocityMode) override;
136 void rtPreActivate(const Eigen::Matrix4f& currentTCPPose);
137 };
138
139 struct VirtualRobotStatus /// TODO remove, not used anywhere
140 {
141 Eigen::Matrix4f globalPose;
142 std::vector<float> jointValuesFullRobot;
143 };
144
145 struct ControlTarget /// TODO remove, only used by keypoint controllers
146 {
147 std::vector<float> targets;
148 };
149
150 Eigen::MatrixXf
151 computeJointLimitWeightMatrix(const Eigen::Ref<const Eigen::VectorXf>& jointAngles,
152 const Eigen::Ref<const Eigen::VectorXf>& jointLimitsLow,
153 const Eigen::Ref<const Eigen::VectorXf>& jointLimitsHigh,
154 Eigen::VectorXf& jointAngleLimitGradient);
155
156
157} // namespace armarx::control::common::control_law
Matrix< float, 6, 1 > Vector6f
Eigen::MatrixXf computeJointLimitWeightMatrix(const Eigen::Ref< const Eigen::VectorXf > &jointAngles, const Eigen::Ref< const Eigen::VectorXf > &jointLimitsLow, const Eigen::Ref< const Eigen::VectorXf > &jointLimitsHigh, Eigen::VectorXf &jointAngleLimitGradient)
Definition common.cpp:110
TODO remove, only used by keypoint controllers.
Definition common.h:146
Eigen::Vector6f cartesianVelTarget
for impedance control
Definition common.h:75
Eigen::Matrix3f poseDiffMatAdm
intermediate results for admittance controller
Definition common.h:90
Eigen::MatrixXf jtpinv
pseudo inverse of the jacobi transpose [6, nDoF], for torque control
Definition common.h:118
Eigen::MatrixXf I
for computing nullspace projection
Definition common.h:124
Eigen::MatrixXf jpinv
pseudo inverse of the jacobi [nDoF, 6], for vel control
Definition common.h:121
Eigen::MatrixXf jacobi
others jacobi matrix [6, nDoF]
Definition common.h:116
Eigen::Matrix3f poseDiffMatImp
intermediate results
Definition common.h:85
Eigen::VectorXf qvelFiltered
for velocity control
Definition common.h:78
Eigen::MatrixXd inertia
inertia Note, the inertia variables are only used for collision avoidance controllers,...
Definition common.h:104
float lambda
damping term for pseudo inverse of jacobian
Definition common.h:127
Eigen::Vector6f forceImpedance
task space variables (command in operation space)
Definition common.h:74
Eigen::Vector6f currentForceTorque
force torque
Definition common.h:70
void rtPreActivate(const Eigen::Matrix4f &currentTCPPose)
Definition common.cpp:100