KeypointsImpedanceController.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 <Eigen/Core>
25
26#include <VirtualRobot/VirtualRobot.h>
27
29
31
33
35{
37 {
38 public:
39 /// you can set the following values from outside of the rt controller via Ice interfaces
40 struct Config
41 {
42 std::string nodeSetName;
43
46
47 // Eigen::Vector6f kpAdmittance; /// might not be needed anymore
50
51 Eigen::VectorXf kpNullspaceTorque;
52 Eigen::VectorXf kdNullspaceTorque;
53
54 std::optional<Eigen::VectorXf> desiredNullspaceJointAngles;
55
58
59 /// keypoints related
61 Eigen::VectorXf keypointKp;
62 Eigen::VectorXf keypointKd;
63 Eigen::VectorXf fixedTranslation;
65 // Eigen::VectorXf currentKeypointPosition;
66 // Eigen::VectorXf desiredKeypointPosition;
67 // Eigen::VectorXf desiredKeypointVelocity;
68 // Eigen::VectorXf desiredDensityForce;
71
72 bool isRigid = false;
73 };
74
75 /// internal status of the controller, containing intermediate variables, mutable targets
76 struct RtStatus
77 {
78 /// targets
79 Eigen::VectorXf desiredJointTorques;
80
81 Eigen::Matrix4f desiredPose;
83
84 /// task space variables
86 Eigen::VectorXf nullspaceTorque;
87 };
88
90 {
91 /// joint space variable
92 Eigen::VectorXf qpos;
93 Eigen::VectorXf qvel;
94
95 /// task space variables
96 Eigen::Matrix4f currentPose;
98
99 Eigen::Matrix4f desiredPose;
102
103 /// others
104 Eigen::MatrixXf jacobi;
105 Eigen::MatrixXf jtpinv;
106
107 /// keypoint status
111
112 Eigen::VectorXf currentKeypointPosition;
113 Eigen::VectorXf currentKeypointVelocity;
114
115 Eigen::VectorXf desiredKeypointPosition;
116 Eigen::VectorXf desiredKeypointVelocity;
117 Eigen::VectorXf desiredDensityForce;
118 };
119
120 private:
121 /// joint space variables
122 unsigned int numOfJoints;
123 std::atomic_bool enablePreactivateInit{false};
124
125 Eigen::MatrixXf I;
126
127 VirtualRobot::DifferentialIKPtr ik;
128
129 const float lambda = 2.0f;
130
131 public:
133
136
137 VirtualRobot::RobotNodePtr tcp;
138
139 void initialize(const VirtualRobot::RobotNodeSetPtr& rns);
140 // Config reconfigure(const std::string &configFileName);
141 void preactivateInit(const VirtualRobot::RobotNodeSetPtr& rns, const Config& c);
142 bool updateControlStatus(const Config& cfg, const RobotStatus& robotStatus);
143 // bool updateControlStatus(
144 // const Config& cfg,
145 // const IceUtil::Time& timeSinceLastIteration,
146 // std::vector<const SensorValue1DoFActuatorTorque*> torqueSensors,
147 // std::vector<const SensorValue1DoFActuatorVelocity*> velocitySensors,
148 // std::vector<const SensorValue1DoFActuatorPosition*> positionSensors);
149
150 // void run(bool rtReady, std::vector<ControlTarget1DoFActuatorTorque*> targets);
151 void run(const Config& cfg, ControlTarget& targets);
152 void firstRun();
153
154 // bool validateTargetPose(Eigen::Matrix4f &targetPose);
155 std::atomic<bool> isInitialized{false};
156 };
157} // namespace armarx::control::common::control_law
constexpr T c
A simple triple buffer for lockfree comunication between a single writer and a single reader.
bool updateControlStatus(const Config &cfg, const RobotStatus &robotStatus)
void preactivateInit(const VirtualRobot::RobotNodeSetPtr &rns, const Config &c)
Brief description of class targets.
Definition targets.h:39
Matrix< float, 6, 1 > Vector6f
TODO remove, only used by keypoint controllers.
Definition common.h:146
you can set the following values from outside of the rt controller via Ice interfaces
internal status of the controller, containing intermediate variables, mutable targets