TaskspaceVelocityController.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/IK/DifferentialIK.h>
25 #include <VirtualRobot/Robot.h>
26 
28 
31 
32 #include <armarx/control/common/control_law/aron/TaskspaceVelocityControllerConfig.aron.generated.h>
35 #include <armarx/control/common/ft/aron/FTConfig.aron.generated.h>
36 
38 {
39 
41  {
42  public:
43  using FTConfig = common::ft::arondto::FTConfig;
44  using Config =
45  common::control_law::arondto::TaskspaceVelocityControllerConfig;
46  using ConfigDict =
47  common::control_law::arondto::TaskspaceVelocityControllerConfigDict;
48 
49  /// internal status of the controller, containing intermediate variables, mutable targets
50  struct RtStatus : public RobotStatus
51  {
52  /// targets
53  // Eigen::VectorXf desiredJointTorques;
54  Eigen::VectorXf desiredJointVelocity;
55  // Eigen::VectorXf nullspaceTorque;
56  Eigen::VectorXf nullspaceVelocity;
57 
58  /// force torque
60 
61  /// task space variables
62  // Eigen::Vector6f forceImpedance;
64 
65  /// current status
66  // Eigen::VectorXf qpos;
67  // Eigen::VectorXf qvel;
68  Eigen::VectorXf qvelFiltered;
72 
73  /// intermediate results
76  Eigen::AngleAxisf oriDiffAngleAxis;
77 
78  /// others
79  Eigen::MatrixXf jacobi;
80  // Eigen::MatrixXf jtpinv;
81  Eigen::MatrixXf jpinv;
82  bool rtSafe;
83  bool rtTargetSafe = true;
84 
85  // size_t nDoFTorque;
86  // size_t nDoFVelocity;
87 
88  void
89  reset(const unsigned int nDoF);
91  };
92 
93  unsigned int numOfJoints; // for nonRT use case
94  // size_t nDoFTorque;
95  size_t nDoFVelocity;
96 
97  private:
98  std::atomic_bool enablePreactivateInit{false};
99 
100  Eigen::MatrixXf I;
101 
102  VirtualRobot::DifferentialIKPtr ik;
103 
104  const float lambda = 2.0f;
105 
106  public:
107  VirtualRobot::RobotNodePtr tcp;
108  VirtualRobot::RobotNodePtr rtTCP;
110 
111  // std::vector<size_t> jointIDTorqueMode;
112  // std::vector<size_t> jointIDVelocityMode;
113 
114  // bool isControlModeValid(const std::vector<std::string>& nameList,
115  // const std::map<std::string, std::string>& jointControlModeMap);
116  // void updateFT(const FTConfig& c, RtStatus& rtStatus);
117  void initialize(const VirtualRobot::RobotNodeSetPtr& rns,
118  const VirtualRobot::RobotNodeSetPtr& rtRns);
119  void preactivateInit(const VirtualRobot::RobotNodeSetPtr& rns);
120 
121  void run(Config& c, RtStatus& robotStatus);
122  void firstRun();
123  };
124 } // namespace armarx::control::common::control_law
armarx::control::common::control_law::TaskspaceVelocityController::RtStatus::poseDiffMatImp
Eigen::Matrix3f poseDiffMatImp
intermediate results
Definition: TaskspaceVelocityController.h:74
armarx::control::common::control_law::TaskspaceVelocityController::RtStatus::reset
void reset(const unsigned int nDoF)
Definition: TaskspaceVelocityController.cpp:205
armarx::control::common::control_law::TaskspaceVelocityController::initialize
void initialize(const VirtualRobot::RobotNodeSetPtr &rns, const VirtualRobot::RobotNodeSetPtr &rtRns)
Definition: TaskspaceVelocityController.cpp:16
armarx::control::common::control_law::TaskspaceVelocityController::nDoFVelocity
size_t nDoFVelocity
Definition: TaskspaceVelocityController.h:95
armarx::control::common::control_law::TaskspaceVelocityController::RtStatus::currentPose
Eigen::Matrix4f currentPose
Definition: TaskspaceVelocityController.h:69
armarx::control::common::control_law::TaskspaceVelocityController::RtStatus::currentTwist
Eigen::Vector6f currentTwist
Definition: TaskspaceVelocityController.h:70
common.h
FTSensor.h
armarx::control::common::control_law::TaskspaceVelocityController::RtStatus::rtPreActivate
void rtPreActivate(const Eigen::Matrix4f &currentPose)
Definition: TaskspaceVelocityController.cpp:248
armarx::control::common::control_law::TaskspaceVelocityController::RtStatus::rtSafe
bool rtSafe
Definition: TaskspaceVelocityController.h:82
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:43
armarx::control::common::control_law::TaskspaceVelocityController::firstRun
void firstRun()
Definition: TaskspaceVelocityController.cpp:39
armarx::control::common::control_law::TaskspaceVelocityController
Definition: TaskspaceVelocityController.h:40
armarx::control::common::control_law::TaskspaceVelocityController::preactivateInit
void preactivateInit(const VirtualRobot::RobotNodeSetPtr &rns)
Definition: TaskspaceVelocityController.cpp:33
armarx::control::common::control_law::TaskspaceVelocityController::RtStatus::jacobi
Eigen::MatrixXf jacobi
others
Definition: TaskspaceVelocityController.h:79
armarx::control::common::control_law::TaskspaceVelocityController::RtStatus::nullspaceVelocity
Eigen::VectorXf nullspaceVelocity
Definition: TaskspaceVelocityController.h:56
armarx::control::common::control_law::TaskspaceVelocityController::rtTCP
VirtualRobot::RobotNodePtr rtTCP
Definition: TaskspaceVelocityController.h:108
armarx::control::common::control_law::RobotStatus
Definition: common.h:29
armarx::control::common::control_law
This file is part of ArmarX.
Definition: aron_conversions.cpp:68
armarx::control::common::control_law::TaskspaceVelocityController::numOfJoints
unsigned int numOfJoints
Definition: TaskspaceVelocityController.h:93
ControlTarget1DoFActuator.h
armarx::control::common::control_law::TaskspaceVelocityController::FTConfig
common::ft::arondto::FTConfig FTConfig
Definition: TaskspaceVelocityController.h:43
armarx::control::common::control_law::TaskspaceVelocityController::tcp
VirtualRobot::RobotNodePtr tcp
Definition: TaskspaceVelocityController.h:107
armarx::control::common::control_law::TaskspaceVelocityController::RtStatus::desiredPose
Eigen::Matrix4f desiredPose
Definition: TaskspaceVelocityController.h:71
armarx::control::common::control_law::TaskspaceVelocityController::ConfigDict
common::control_law::arondto::TaskspaceVelocityControllerConfigDict ConfigDict
Definition: TaskspaceVelocityController.h:47
armarx::control::common::control_law::TaskspaceVelocityController::run
void run(Config &c, RtStatus &robotStatus)
Definition: TaskspaceVelocityController.cpp:97
TripleBuffer.h
GfxTL::Matrix3f
MatrixXX< 3, 3, float > Matrix3f
Definition: MatrixXX.h:600
GfxTL::Matrix4f
MatrixXX< 4, 4, float > Matrix4f
Definition: MatrixXX.h:601
armarx::control::common::control_law::TaskspaceVelocityController::RtStatus::oriDiffAngleAxis
Eigen::AngleAxisf oriDiffAngleAxis
Definition: TaskspaceVelocityController.h:76
armarx::control::common::control_law::TaskspaceVelocityController::RtStatus::qvelFiltered
Eigen::VectorXf qvelFiltered
current status
Definition: TaskspaceVelocityController.h:68
armarx::control::common::control_law::TaskspaceVelocityController::RtStatus
internal status of the controller, containing intermediate variables, mutable targets
Definition: TaskspaceVelocityController.h:50
armarx::control::common::control_law::TaskspaceVelocityController::RtStatus::desiredJointVelocity
Eigen::VectorXf desiredJointVelocity
targets
Definition: TaskspaceVelocityController.h:54
armarx::control::common::control_law::TaskspaceVelocityController::RtStatus::cartesianVelTarget
Eigen::Vector6f cartesianVelTarget
task space variables
Definition: TaskspaceVelocityController.h:63
Eigen::Matrix< float, 6, 1 >
armarx::control::common::control_law::TaskspaceVelocityController::ftsensor
common::ft::FTSensor ftsensor
Definition: TaskspaceVelocityController.h:109
armarx::control::common::control_law::TaskspaceVelocityController::RtStatus::jpinv
Eigen::MatrixXf jpinv
Definition: TaskspaceVelocityController.h:81
armarx::control::common::control_law::TaskspaceVelocityController::RtStatus::rtTargetSafe
bool rtTargetSafe
Definition: TaskspaceVelocityController.h:83
armarx::control::common::ft::FTSensor
Definition: FTSensor.h:45
armarx::control::common::control_law::TaskspaceVelocityController::Config
common::control_law::arondto::TaskspaceVelocityControllerConfig Config
Definition: TaskspaceVelocityController.h:45
armarx::control::common::control_law::TaskspaceVelocityController::RtStatus::poseErrorImp
Eigen::Vector6f poseErrorImp
Definition: TaskspaceVelocityController.h:75
SensorValue1DoFActuator.h
armarx::control::common::control_law::TaskspaceVelocityController::RtStatus::currentForceTorque
Eigen::Vector6f currentForceTorque
force torque
Definition: TaskspaceVelocityController.h:59