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