KeypointsAdmittanceController.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 <atomic>
25
26#include <Eigen/Core>
27
28#include <IceUtil/Time.h>
29
30#include <VirtualRobot/VirtualRobot.h>
31
33
34namespace armarx
35{
36 class SensorValue1DoFActuatorTorque;
37 class SensorValue1DoFActuatorVelocity;
38 class SensorValue1DoFActuatorPosition;
39 class ControlTarget1DoFActuatorTorque;
40} // namespace armarx
41
43{
45 {
46 public:
47 /// you can set the following values from outside of the rt controller via Ice interfaces
82
83 /// internal status of the controller, containing intermediate variables, mutable targets
84 struct Status : Config
85 {
86 /// joint space variable
87 Eigen::VectorXf qpos;
88 Eigen::VectorXf qvel;
89
90 Eigen::VectorXf nullspaceTorque;
91 Eigen::VectorXf desiredJointTorques;
92
93 /// task spaace variables
94 Eigen::Matrix4f previousDesiredPose;
95 Eigen::Matrix4f desiredPose;
98
99 Eigen::Matrix4f currentPose;
102
103 Eigen::Matrix4f virtualPose;
106
110 Eigen::VectorXf currentKeypointVelocity;
111
112 /// others
113 Eigen::MatrixXf jacobi;
114 double deltaT;
115 };
116
117 private:
118 /// joint space variables
119 unsigned int numOfJoints;
120 std::atomic_bool enablePreactivateInit{false};
121
122 Eigen::MatrixXf I;
123
124 VirtualRobot::DifferentialIKPtr ik;
125
126 const float lambda = 2.0f;
127
128 public:
130 VirtualRobot::RobotNodePtr tcp;
131
132 void initialize(const VirtualRobot::RobotNodeSetPtr& rns,
133 const std::string& configFileName);
134 Config reconfigure(const std::string& configFileName);
135 void preactivateInit(const VirtualRobot::RobotNodeSetPtr& rns);
136 bool
137 updateControlStatus(const Config& cfg,
138 const IceUtil::Time& timeSinceLastIteration,
139 std::vector<const SensorValue1DoFActuatorTorque*> torqueSensors,
140 std::vector<const SensorValue1DoFActuatorVelocity*> velocitySensors,
141 std::vector<const SensorValue1DoFActuatorPosition*> positionSensors);
142
143 void run(bool rtReady, std::vector<ControlTarget1DoFActuatorTorque*> targets);
144 void firstRun();
145 bool validateTargetPose(Eigen::Matrix4f& targetPose);
146 };
147} // namespace armarx::control::common::control_law
bool updateControlStatus(const Config &cfg, const IceUtil::Time &timeSinceLastIteration, std::vector< const SensorValue1DoFActuatorTorque * > torqueSensors, std::vector< const SensorValue1DoFActuatorVelocity * > velocitySensors, std::vector< const SensorValue1DoFActuatorPosition * > positionSensors)
void initialize(const VirtualRobot::RobotNodeSetPtr &rns, const std::string &configFileName)
void run(bool rtReady, std::vector< ControlTarget1DoFActuatorTorque * > targets)
Brief description of class targets.
Definition targets.h:39
Matrix< float, 6, 1 > Vector6f
This file offers overloads of toIce() and fromIce() functions for STL container types.
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