ZeroTorqueOrVelocityController.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 2024
18 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
19 * GNU General Public License
20 */
21
22#pragma once
23
24#include <VirtualRobot/VirtualRobot.h>
25
26#include <armarx/control/common/control_law/aron/ZeroTorqueOrVelocityControllerConfig.aron.generated.h>
29#include <armarx/control/common/ft/aron/FTConfig.aron.generated.h>
30
32{
33
35 {
36 public:
37 /// you can set the following values from outside of the rt controller via Ice interfaces
38 // struct Config
39 // {
40 // // torque controlled joint names
41 // std::vector<std::string> jointNameListTorque;
42 // std::vector<std::string> jointNameListVelocity;
43
44 // // parameters for velocity controller
45 // Eigen::Vector6f kpCartesianVel;
46 // Eigen::Vector6f kdCartesianVel;
47
48 // // std::map<std::string, std::string> jointControlModeMap;
49
50 // float torqueLimit;
51 // float velocityLimit;
52 // float qvelFilter;
53 // float cartesianLinearVelLimit;
54 // float cartesianAngularVelLimit;
55 // // bool useZeroVelocityModeForWrist;
56
57 // /// force torque sensor config
58 // common::ft::FTSensor::FTConfig ftConfig;
59 // };
60
61 using Config = arondto::ZeroTorqueOrVelocityControllerConfig;
62 using ConfigDict = arondto::ZeroTorqueOrVelocityControllerConfigDict;
63
64 // struct ConfigDict
65 // {
66 // std::map<std::string, Config> cfg;
67 // };
68
69 // /// internal status of the controller, containing intermediate variables, mutable targets
70 // struct RtStatus : public RobotStatus
71 // {
72 // /// targets
73 // Eigen::VectorXf desiredJointTorques;
74 // Eigen::VectorXf desiredJointVelocity;
75 //
76 // /// force torque
77 // Eigen::Vector6f currentForceTorque;
78 //
79 // /// task space variables
80 // Eigen::Vector6f cartesianVelTarget;
81 //
82 // /// current status
83 // Eigen::VectorXf qpos;
84 // Eigen::VectorXf qvel;
85 // Eigen::VectorXf qvelFiltered;
86 // Eigen::Vector6f currentTwist;
87 //
88 // /// others
89 // Eigen::MatrixXf jacobi;
90 // Eigen::MatrixXf jpinv;
91 // bool rtSafe;
92 //
93 // size_t nDoFTorque;
94 // size_t nDoFVelocity;
95 // };
96
97 // unsigned int numOfJoints; // for nonRT use case
98 // size_t nDoFTorque;
99 // size_t nDoFVelocity;
100
101 private:
102 // Eigen::MatrixXf I;
103
104 VirtualRobot::DifferentialIKPtr ik;
105
106 // const float lambda = 2.0f;
107
108 public:
109 VirtualRobot::RobotNodePtr tcp;
110 VirtualRobot::RobotNodePtr rtTCP;
112
113 std::vector<size_t> jointIDTorqueMode;
114 std::vector<size_t> jointIDVelocityMode;
115
116 // bool isControlModeValid(const std::vector<std::string>& nameList,
117 // const std::map<std::string, std::string>& jointControlModeMap);
118 // void updateFT(const common::ft::arondto::FTConfig& c, RtStatus& rtStatus);
119
120 void initialize(const VirtualRobot::RobotNodeSetPtr& rns,
121 const VirtualRobot::RobotNodeSetPtr& rtRns,
122 const std::vector<size_t>& torqueControlledIndex,
123 const std::vector<size_t>& velocityControlledIndex);
124 void preactivateInit(const VirtualRobot::RobotNodeSetPtr& rns);
125
126 void run(Config& c, TSCtrlRtStatus& robotStatus);
127 void firstRun();
128 };
129} // namespace armarx::control::common::control_law
constexpr T c
void initialize(const VirtualRobot::RobotNodeSetPtr &rns, const VirtualRobot::RobotNodeSetPtr &rtRns, const std::vector< size_t > &torqueControlledIndex, const std::vector< size_t > &velocityControlledIndex)
arondto::ZeroTorqueOrVelocityControllerConfig Config
you can set the following values from outside of the rt controller via Ice interfaces