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 <VirtualRobot/Robot.h>
25 #include <VirtualRobot/IK/DifferentialIK.h>
26 
29 
30 
32 {
34  {
35  public:
36  /// you can set the following values from outside of the rt controller via Ice interfaces
37  struct Config
38  {
39  std::string nodeSetName;
40 
43 
47 
48  Eigen::VectorXf kpNullspace;
49  Eigen::VectorXf kdNullspace;
50 
52  Eigen::VectorXf desiredNullspaceJointAngles;
53 
54  float torqueLimit;
55  float qvelFilter;
56 
57  /// keypoints related
58  int numPoints;
59  Eigen::VectorXf keypointKp;
60  Eigen::VectorXf keypointKd;
61 
62  Eigen::VectorXf currentKeypointPosition;
63  Eigen::VectorXf desiredKeypointPosition;
64  Eigen::VectorXf desiredKeypointVelocity;
65  float keypointPositionFilter = 1.0f;
66  float keypointVelocityFilter = 1.0f;
67 
68  bool isRigid = false;
69  Eigen::VectorXf fixedTranslation;
70  };
71 
72  /// internal status of the controller, containing intermediate variables, mutable targets
73  struct Status: Config
74  {
75  /// joint space variable
76  Eigen::VectorXf qpos;
77  Eigen::VectorXf qvel;
78 
79  Eigen::VectorXf nullspaceTorque;
80  Eigen::VectorXf desiredJointTorques;
81 
82  /// task spaace variables
87 
91 
95 
97  Eigen::VectorXf filteredKeypointPosition;
98  Eigen::VectorXf previousKeypointPosition;
99  Eigen::VectorXf currentKeypointVelocity;
100 
101  /// others
102  Eigen::MatrixXf jacobi;
103  double deltaT;
104  };
105 
106  private:
107  /// joint space variables
108  unsigned int numOfJoints;
109  std::atomic_bool enablePreactivateInit{false};
110 
111  Eigen::MatrixXf I;
112 
113  VirtualRobot::DifferentialIKPtr ik;
114 
115  const float lambda = 2.0f;
116  public:
118  VirtualRobot::RobotNodePtr tcp;
119 
120  void initialize(const VirtualRobot::RobotNodeSetPtr& rns, const std::string &configFileName);
121  Config reconfigure(const std::string &configFileName);
122  void preactivateInit(const VirtualRobot::RobotNodeSetPtr& rns);
123  bool updateControlStatus(
124  const Config& cfg,
125  const IceUtil::Time& timeSinceLastIteration,
126  std::vector<const SensorValue1DoFActuatorTorque*> torqueSensors,
127  std::vector<const SensorValue1DoFActuatorVelocity*> velocitySensors,
128  std::vector<const SensorValue1DoFActuatorPosition*> positionSensors);
129 
130  void run(bool rtReady, std::vector<ControlTarget1DoFActuatorTorque*> targets);
131  void firstRun();
132  bool validateTargetPose(Eigen::Matrix4f &targetPose);
133  };
134 } /// namespace armarx::control::common::control_law
armarx::control::common::control_law::KeypointsAdmittanceController::Status::currentKeypointVelocity
Eigen::VectorXf currentKeypointVelocity
Definition: KeypointsAdmittanceController.h:99
armarx::control::common::control_law::KeypointsAdmittanceController::Status::qpos
Eigen::VectorXf qpos
joint space variable
Definition: KeypointsAdmittanceController.h:76
armarx::control::common::control_law::KeypointsAdmittanceController::Status::desiredAcc
Eigen::Vector6f desiredAcc
Definition: KeypointsAdmittanceController.h:86
armarx::control::common::control_law::KeypointsAdmittanceController::Status::desiredJointTorques
Eigen::VectorXf desiredJointTorques
Definition: KeypointsAdmittanceController.h:80
armarx::control::common::control_law::KeypointsAdmittanceController::Config::nodeSetName
std::string nodeSetName
Definition: KeypointsAdmittanceController.h:39
armarx::control::common::control_law::KeypointsAdmittanceController::firstRun
void firstRun()
Definition: KeypointsAdmittanceController.cpp:194
armarx::control::common::control_law::KeypointsAdmittanceController::Status::virtualVel
Eigen::Vector6f virtualVel
Definition: KeypointsAdmittanceController.h:93
armarx::control::common::control_law::KeypointsAdmittanceController::Config::fixedTranslation
Eigen::VectorXf fixedTranslation
Definition: KeypointsAdmittanceController.h:69
armarx::control::common::control_law::KeypointsAdmittanceController::Config::kdAdmittance
Eigen::Vector6f kdAdmittance
Definition: KeypointsAdmittanceController.h:45
armarx::control::common::control_law::KeypointsAdmittanceController::Status::jacobi
Eigen::MatrixXf jacobi
others
Definition: KeypointsAdmittanceController.h:102
armarx::control::common::control_law::KeypointsAdmittanceController::Config::kmAdmittance
Eigen::Vector6f kmAdmittance
Definition: KeypointsAdmittanceController.h:46
armarx::control::common::control_law::KeypointsAdmittanceController
Definition: KeypointsAdmittanceController.h:33
armarx::control::common::control_law::KeypointsAdmittanceController::reconfigure
Config reconfigure(const std::string &configFileName)
Definition: KeypointsAdmittanceController.cpp:118
armarx::control::common::control_law::KeypointsAdmittanceController::Config::isRigid
bool isRigid
Definition: KeypointsAdmittanceController.h:68
armarx::control::common::control_law::KeypointsAdmittanceController::Config::currentKeypointPosition
Eigen::VectorXf currentKeypointPosition
Definition: KeypointsAdmittanceController.h:62
armarx::control::common::control_law::KeypointsAdmittanceController::Config::keypointPositionFilter
float keypointPositionFilter
Definition: KeypointsAdmittanceController.h:65
armarx::control::common::control_law::KeypointsAdmittanceController::Status::previousDesiredPose
Eigen::Matrix4f previousDesiredPose
task spaace variables
Definition: KeypointsAdmittanceController.h:83
armarx::control::common::control_law::KeypointsAdmittanceController::Config::keypointKp
Eigen::VectorXf keypointKp
Definition: KeypointsAdmittanceController.h:59
armarx::control::common::control_law::KeypointsAdmittanceController::Status::desiredVel
Eigen::Vector6f desiredVel
Definition: KeypointsAdmittanceController.h:85
armarx::control::common::control_law::KeypointsAdmittanceController::Config::kpImpedance
Eigen::Vector6f kpImpedance
Definition: KeypointsAdmittanceController.h:41
armarx::control::common::control_law::KeypointsAdmittanceController::s
Status s
Definition: KeypointsAdmittanceController.h:117
armarx::control::common::control_law::KeypointsAdmittanceController::preactivateInit
void preactivateInit(const VirtualRobot::RobotNodeSetPtr &rns)
Definition: KeypointsAdmittanceController.cpp:152
armarx::control::common::control_law::KeypointsAdmittanceController::updateControlStatus
bool updateControlStatus(const Config &cfg, const IceUtil::Time &timeSinceLastIteration, std::vector< const SensorValue1DoFActuatorTorque * > torqueSensors, std::vector< const SensorValue1DoFActuatorVelocity * > velocitySensors, std::vector< const SensorValue1DoFActuatorPosition * > positionSensors)
Definition: KeypointsAdmittanceController.cpp:224
armarx::control::common::control_law::KeypointsAdmittanceController::Config::desiredKeypointVelocity
Eigen::VectorXf desiredKeypointVelocity
Definition: KeypointsAdmittanceController.h:64
armarx::control::common::control_law::KeypointsAdmittanceController::run
void run(bool rtReady, std::vector< ControlTarget1DoFActuatorTorque * > targets)
Definition: KeypointsAdmittanceController.cpp:377
armarx::control::common::control_law::KeypointsAdmittanceController::Status::virtualAcc
Eigen::Vector6f virtualAcc
Definition: KeypointsAdmittanceController.h:94
armarx::control::common::control_law::KeypointsAdmittanceController::Config::currentForceTorque
Eigen::Vector6f currentForceTorque
Definition: KeypointsAdmittanceController.h:51
armarx::control::common::control_law::KeypointsAdmittanceController::Status::previousKeypointPosition
Eigen::VectorXf previousKeypointPosition
Definition: KeypointsAdmittanceController.h:98
armarx::control::common::control_law
This file is part of ArmarX.
Definition: aron_conversions.cpp:68
armarx::control::common::control_law::KeypointsAdmittanceController::Status
internal status of the controller, containing intermediate variables, mutable targets
Definition: KeypointsAdmittanceController.h:73
ControlTarget1DoFActuator.h
armarx::control::common::control_law::KeypointsAdmittanceController::Config::kdImpedance
Eigen::Vector6f kdImpedance
Definition: KeypointsAdmittanceController.h:42
armarx::control::common::control_law::KeypointsAdmittanceController::initialize
void initialize(const VirtualRobot::RobotNodeSetPtr &rns, const std::string &configFileName)
Definition: KeypointsAdmittanceController.cpp:22
armarx::control::common::control_law::KeypointsAdmittanceController::Config::keypointKd
Eigen::VectorXf keypointKd
Definition: KeypointsAdmittanceController.h:60
armarx::armem::Time
armarx::core::time::DateTime Time
Definition: forward_declarations.h:13
armarx::control::common::control_law::KeypointsAdmittanceController::Status::virtualPose
Eigen::Matrix4f virtualPose
Definition: KeypointsAdmittanceController.h:92
armarx::control::common::control_law::KeypointsAdmittanceController::Config::keypointVelocityFilter
float keypointVelocityFilter
Definition: KeypointsAdmittanceController.h:66
armarx::control::common::control_law::KeypointsAdmittanceController::Status::currentPose
Eigen::Matrix4f currentPose
Definition: KeypointsAdmittanceController.h:88
armarx::control::common::control_law::KeypointsAdmittanceController::Config::torqueLimit
float torqueLimit
Definition: KeypointsAdmittanceController.h:54
GfxTL::Matrix4f
MatrixXX< 4, 4, float > Matrix4f
Definition: MatrixXX.h:601
armarx::control::common::control_law::KeypointsAdmittanceController::Config::qvelFilter
float qvelFilter
Definition: KeypointsAdmittanceController.h:55
armarx::control::common::control_law::KeypointsAdmittanceController::Status::pointTrackingForce
Eigen::Vector6f pointTrackingForce
Definition: KeypointsAdmittanceController.h:96
armarx::control::common::control_law::KeypointsAdmittanceController::tcp
VirtualRobot::RobotNodePtr tcp
Definition: KeypointsAdmittanceController.h:118
armarx::control::common::control_law::KeypointsAdmittanceController::Status::currentTwist
Eigen::Vector6f currentTwist
Definition: KeypointsAdmittanceController.h:89
armarx::control::common::control_law::KeypointsAdmittanceController::Config
you can set the following values from outside of the rt controller via Ice interfaces
Definition: KeypointsAdmittanceController.h:37
armarx::control::common::control_law::KeypointsAdmittanceController::Config::kpAdmittance
Eigen::Vector6f kpAdmittance
Definition: KeypointsAdmittanceController.h:44
armarx::control::common::control_law::KeypointsAdmittanceController::Config::desiredNullspaceJointAngles
Eigen::VectorXf desiredNullspaceJointAngles
Definition: KeypointsAdmittanceController.h:52
Eigen::Matrix< float, 6, 1 >
armarx::control::common::control_law::KeypointsAdmittanceController::Status::desiredPose
Eigen::Matrix4f desiredPose
Definition: KeypointsAdmittanceController.h:84
armarx::control::common::control_law::KeypointsAdmittanceController::Status::forceImpedance
Eigen::Vector6f forceImpedance
Definition: KeypointsAdmittanceController.h:90
armarx::control::common::control_law::KeypointsAdmittanceController::Config::kpNullspace
Eigen::VectorXf kpNullspace
Definition: KeypointsAdmittanceController.h:48
armarx::control::common::control_law::KeypointsAdmittanceController::Status::nullspaceTorque
Eigen::VectorXf nullspaceTorque
Definition: KeypointsAdmittanceController.h:79
armarx::control::common::control_law::KeypointsAdmittanceController::Status::deltaT
double deltaT
Definition: KeypointsAdmittanceController.h:103
armarx::control::common::control_law::KeypointsAdmittanceController::Status::qvel
Eigen::VectorXf qvel
Definition: KeypointsAdmittanceController.h:77
armarx::control::common::control_law::KeypointsAdmittanceController::Config::kdNullspace
Eigen::VectorXf kdNullspace
Definition: KeypointsAdmittanceController.h:49
armarx::control::common::control_law::KeypointsAdmittanceController::Config::desiredKeypointPosition
Eigen::VectorXf desiredKeypointPosition
Definition: KeypointsAdmittanceController.h:63
SensorValue1DoFActuator.h
armarx::control::common::control_law::KeypointsAdmittanceController::Config::numPoints
int numPoints
keypoints related
Definition: KeypointsAdmittanceController.h:58
armarx::control::common::control_law::KeypointsAdmittanceController::Status::filteredKeypointPosition
Eigen::VectorXf filteredKeypointPosition
Definition: KeypointsAdmittanceController.h:97
armarx::control::common::control_law::KeypointsAdmittanceController::validateTargetPose
bool validateTargetPose(Eigen::Matrix4f &targetPose)
Definition: KeypointsAdmittanceController.cpp:206