TaskspaceAdmittanceController.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 
28 #include <armarx/control/common/control_law/aron/TaskspaceAdmittanceControllerConfig.aron.generated.h>
31 #include <armarx/control/common/ft/aron/FTConfig.aron.generated.h>
32 
34 {
35 
37  {
38  public:
39  using FTConfig = common::ft::arondto::FTConfig;
40  using Config = common::control_law::arondto::TaskspaceAdmittanceControllerConfig;
41  using ConfigDict = common::control_law::arondto::TaskspaceAdmittanceControllerConfigDict;
42 
43  /// internal status of the controller, containing intermediate variables, mutable targets
44  struct RtStatus : public RobotStatus
45  {
46  /// targets
47  Eigen::VectorXf desiredJointTorques;
48  Eigen::VectorXf nullspaceTorque;
49 
50  /// variables that need to be kept locally by the rt thread
54 
60 
61  /// force torque
63 
64  /// task space variables
66 
67  /// current status
68  Eigen::VectorXf qpos;
69  Eigen::VectorXf qvel;
70  Eigen::VectorXf qvelFiltered;
74 
75  /// intermediate results
78  Eigen::AngleAxisf oriDiffAngleAxis;
79 
80  /// others
81  Eigen::MatrixXf jacobi;
82  Eigen::MatrixXf jtpinv;
83  bool rtSafe;
84  bool rtTargetSafe = true;
85 
86  void reset(const unsigned int nDoF);
88  };
89 
90  unsigned int numOfJoints; // for nonRT use case
91  private:
92  std::atomic_bool enablePreactivateInit{false};
93 
94  Eigen::MatrixXf I;
95 
96  VirtualRobot::DifferentialIKPtr ik;
97 
98  const float lambda = 2.0f;
99 
100  public:
101  VirtualRobot::RobotNodePtr tcp;
102  VirtualRobot::RobotNodePtr rtTCP;
104 
105  // void updateFT(const FTConfig& c, RtStatus& rtStatus);
106  void initialize(const VirtualRobot::RobotNodeSetPtr& rns,
107  const VirtualRobot::RobotNodeSetPtr& rtRns);
108  void preactivateInit(const VirtualRobot::RobotNodeSetPtr& rns);
109 
110  void run(Config& c, RtStatus& robotStatus);
111  void firstRun();
112  };
113 } // namespace armarx::control::common::control_law
armarx::control::common::control_law::TaskspaceAdmittanceController::Config
common::control_law::arondto::TaskspaceAdmittanceControllerConfig Config
Definition: TaskspaceAdmittanceController.h:40
armarx::control::common::control_law::TaskspaceAdmittanceController::RtStatus
internal status of the controller, containing intermediate variables, mutable targets
Definition: TaskspaceAdmittanceController.h:44
armarx::control::common::control_law::TaskspaceAdmittanceController::rtTCP
VirtualRobot::RobotNodePtr rtTCP
Definition: TaskspaceAdmittanceController.h:102
armarx::control::common::control_law::TaskspaceAdmittanceController::FTConfig
common::ft::arondto::FTConfig FTConfig
Definition: TaskspaceAdmittanceController.h:39
armarx::control::common::control_law::TaskspaceAdmittanceController::RtStatus::rtPreActivate
void rtPreActivate(const Eigen::Matrix4f &currentPose)
Definition: TaskspaceAdmittanceController.cpp:254
armarx::control::common::control_law::TaskspaceAdmittanceController::firstRun
void firstRun()
Definition: TaskspaceAdmittanceController.cpp:43
armarx::control::common::control_law::TaskspaceAdmittanceController::RtStatus::virtualVel
Eigen::Vector6f virtualVel
Definition: TaskspaceAdmittanceController.h:52
armarx::control::common::control_law::TaskspaceAdmittanceController::RtStatus::nullspaceTorque
Eigen::VectorXf nullspaceTorque
Definition: TaskspaceAdmittanceController.h:48
armarx::control::common::control_law::TaskspaceAdmittanceController
Definition: TaskspaceAdmittanceController.h:36
GfxTL::Matrix4f
MatrixXX< 4, 4, float > Matrix4f
Definition: MatrixXX.h:650
armarx::control::common::control_law::TaskspaceAdmittanceController::RtStatus::reset
void reset(const unsigned int nDoF)
Definition: TaskspaceAdmittanceController.cpp:203
common.h
FTSensor.h
armarx::control::common::control_law::TaskspaceAdmittanceController::RtStatus::poseErrorAdm
Eigen::Vector6f poseErrorAdm
Definition: TaskspaceAdmittanceController.h:56
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:46
armarx::control::common::control_law::TaskspaceAdmittanceController::ftsensor
common::ft::FTSensor ftsensor
Definition: TaskspaceAdmittanceController.h:103
armarx::control::common::control_law::TaskspaceAdmittanceController::numOfJoints
unsigned int numOfJoints
Definition: TaskspaceAdmittanceController.h:90
armarx::control::common::control_law::TaskspaceAdmittanceController::RtStatus::currentPose
Eigen::Matrix4f currentPose
Definition: TaskspaceAdmittanceController.h:71
armarx::control::common::control_law::TaskspaceAdmittanceController::RtStatus::forceImpedance
Eigen::Vector6f forceImpedance
task space variables
Definition: TaskspaceAdmittanceController.h:65
armarx::control::common::control_law::TaskspaceAdmittanceController::RtStatus::currentTwist
Eigen::Vector6f currentTwist
Definition: TaskspaceAdmittanceController.h:72
armarx::control::common::control_law::TaskspaceAdmittanceController::RtStatus::jtpinv
Eigen::MatrixXf jtpinv
Definition: TaskspaceAdmittanceController.h:82
armarx::control::common::control_law::TaskspaceAdmittanceController::RtStatus::oriDiffAngleAxis
Eigen::AngleAxisf oriDiffAngleAxis
Definition: TaskspaceAdmittanceController.h:78
armarx::control::common::control_law::TaskspaceAdmittanceController::RtStatus::qpos
Eigen::VectorXf qpos
current status
Definition: TaskspaceAdmittanceController.h:68
armarx::control::common::control_law::TaskspaceAdmittanceController::preactivateInit
void preactivateInit(const VirtualRobot::RobotNodeSetPtr &rns)
Definition: TaskspaceAdmittanceController.cpp:38
armarx::control::common::control_law::RobotStatus
Definition: common.h:32
armarx::control::common::control_law::TaskspaceAdmittanceController::RtStatus::virtualPose
Eigen::Matrix4f virtualPose
variables that need to be kept locally by the rt thread
Definition: TaskspaceAdmittanceController.h:51
armarx::control::common::control_law::TaskspaceAdmittanceController::RtStatus::poseErrorImp
Eigen::Vector6f poseErrorImp
Definition: TaskspaceAdmittanceController.h:77
armarx::control::common::control_law::TaskspaceAdmittanceController::run
void run(Config &c, RtStatus &robotStatus)
Definition: TaskspaceAdmittanceController.cpp:73
armarx::control::common::control_law
This file is part of ArmarX.
Definition: aron_conversions.cpp:68
armarx::control::common::control_law::TaskspaceAdmittanceController::RtStatus::qvel
Eigen::VectorXf qvel
Definition: TaskspaceAdmittanceController.h:69
armarx::control::common::control_law::TaskspaceAdmittanceController::RtStatus::acc
Eigen::Vector6f acc
Definition: TaskspaceAdmittanceController.h:57
armarx::control::common::control_law::TaskspaceAdmittanceController::RtStatus::qvelFiltered
Eigen::VectorXf qvelFiltered
Definition: TaskspaceAdmittanceController.h:70
armarx::control::common::control_law::TaskspaceAdmittanceController::ConfigDict
common::control_law::arondto::TaskspaceAdmittanceControllerConfigDict ConfigDict
Definition: TaskspaceAdmittanceController.h:41
armarx::control::common::control_law::TaskspaceAdmittanceController::tcp
VirtualRobot::RobotNodePtr tcp
Definition: TaskspaceAdmittanceController.h:101
armarx::control::common::control_law::TaskspaceAdmittanceController::RtStatus::rtSafe
bool rtSafe
Definition: TaskspaceAdmittanceController.h:83
armarx::control::common::control_law::TaskspaceAdmittanceController::RtStatus::currentForceTorque
Eigen::Vector6f currentForceTorque
force torque
Definition: TaskspaceAdmittanceController.h:62
armarx::control::common::control_law::TaskspaceAdmittanceController::RtStatus::virtualAcc
Eigen::Vector6f virtualAcc
Definition: TaskspaceAdmittanceController.h:53
armarx::control::common::control_law::TaskspaceAdmittanceController::RtStatus::poseDiffMatAdm
Eigen::Matrix3f poseDiffMatAdm
Definition: TaskspaceAdmittanceController.h:55
armarx::control::common::control_law::TaskspaceAdmittanceController::RtStatus::pos
Eigen::Vector6f pos
Definition: TaskspaceAdmittanceController.h:59
Eigen::Matrix< float, 6, 1 >
armarx::control::common::control_law::TaskspaceAdmittanceController::RtStatus::poseDiffMatImp
Eigen::Matrix3f poseDiffMatImp
intermediate results
Definition: TaskspaceAdmittanceController.h:76
armarx::control::common::control_law::TaskspaceAdmittanceController::RtStatus::desiredJointTorques
Eigen::VectorXf desiredJointTorques
targets
Definition: TaskspaceAdmittanceController.h:47
GfxTL::Matrix3f
MatrixXX< 3, 3, float > Matrix3f
Definition: MatrixXX.h:649
armarx::control::common::control_law::TaskspaceAdmittanceController::initialize
void initialize(const VirtualRobot::RobotNodeSetPtr &rns, const VirtualRobot::RobotNodeSetPtr &rtRns)
Definition: TaskspaceAdmittanceController.cpp:23
armarx::control::common::control_law::TaskspaceAdmittanceController::RtStatus::desiredPose
Eigen::Matrix4f desiredPose
Definition: TaskspaceAdmittanceController.h:73
armarx::control::common::ft::FTSensor
Definition: FTSensor.h:51
armarx::control::common::control_law::TaskspaceAdmittanceController::RtStatus::rtTargetSafe
bool rtTargetSafe
Definition: TaskspaceAdmittanceController.h:84
armarx::control::common::control_law::TaskspaceAdmittanceController::RtStatus::vel
Eigen::Vector6f vel
Definition: TaskspaceAdmittanceController.h:58
armarx::control::common::control_law::TaskspaceAdmittanceController::RtStatus::jacobi
Eigen::MatrixXf jacobi
others
Definition: TaskspaceAdmittanceController.h:81