BiKAC.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  * @package ...
17  * @author Jianfeng Gao ( jianfeng dot gao at kit dot edu )
18  * @date 2023
19  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20  * GNU General Public License
21  */
22 
23 #pragma once
24 
29 #include <armarx/control/njoint_mp_controller/task_space/ControllerInterface.h>
30 
32 {
34  using namespace armarx::control::common;
35 
36  struct Constraint
37  {
38  int idx;
39  std::string type;
40  std::string mpName;
41 
42  std::string rnsKpt;
43  std::string rnsFrame;
44 
47 
48  Eigen::Vector3f pcaMeanLocal;
50 
56 
59  Eigen::Vector3f trackingForceLocal;
60  Eigen::Vector3f trackingForceRoot;
61 
62  Eigen::Vector3f kptKp;
63  Eigen::Vector3f kptKd;
64 
69  int p2pIdx;
70  };
71 
73  {
78  std::vector<int> constraintIdxList;
79  };
80 
81  struct BiKACConfig
82  {
86  std::map<std::string, AdmittanceData> admittanceData;
87  // std::map<std::string, std::vector<int>> rnsToConstraintIdxMap;
88  // std::map<std::string, Eigen::Vector6f> rnsToForceTorqueMap;
89  std::vector<Constraint> cList;
90  };
91 
92  /**
93  * @defgroup Library-NJointBiKAC NJointBiKAC
94  * @ingroup Library-RobotUnit-NJointControllers
95  * A description of the library NJointBiKAC.
96  *
97  * @class NJointBiKAC
98  * @ingroup Library-NJointBiKAC
99  * @brief Brief description of class NJointBiKAC.
100  *
101  * Detailed description of class NJointBiKAC.
102  */
103  class NJointBiKAC :
104  virtual public NJointTaskspaceImpedanceController,
105  virtual public mp::MPPool,
106  virtual public NJointBiKACInterface
107  {
108  public:
109  using MPListConfig = common::mp::arondto::MPListConfig;
110 
111  NJointBiKAC(const RobotUnitPtr& robotUnit,
112  const NJointControllerConfigPtr& config,
113  const VirtualRobot::RobotPtr&);
114 
115  std::string getClassName(const Ice::Current& = Ice::emptyCurrent) const override;
116 
117  void updateMPConfig(const ::armarx::aron::data::dto::DictPtr& dto,
118  const Ice::Current& iceCurrent = Ice::emptyCurrent) override;
120  getMPConfig(const Ice::Current& iceCurrent = Ice::emptyCurrent) override;
121  void updateBiKACConfig(const ::armarx::aron::data::dto::DictPtr& dto,
122  const Ice::Current& iceCurrent = Ice::emptyCurrent) override;
124  getBiKACConfig(const Ice::Current& iceCurrent = Ice::emptyCurrent) override;
125 
126  void additionalTask() override;
127 
128  protected:
129  /// this variable is only needed when constructing the MP instances, therefore you don't
130  /// need to use triple buffers
133 
134  protected:
135  // void reInitMPInputOutputData();
136  void limbNonRT(ArmPtr& arm);
137  void updateConstraintStatus(const bool rtSafe);
138 
139  void onPublish(const SensorAndControl&,
141  const DebugObserverInterfacePrx&) override;
142 
145 
146  private:
147  // std::atomic<bool> isMPReady{false};
148  std::atomic<bool> isConstraintReady{false};
149  };
150 } // namespace armarx::control::njoint_mp_controller::task_space
armarx::control::njoint_mp_controller::task_space::Constraint::kptKp
Eigen::Vector3f kptKp
Definition: BiKAC.h:62
armarx::control::njoint_mp_controller::task_space::BiKACConfig::kdAdmittance
Eigen::Vector6f kdAdmittance
Definition: BiKAC.h:84
armarx::control::njoint_controller::task_space::NJointTaskspaceImpedanceController
Brief description of class NJointTaskspaceImpedanceController.
Definition: ImpedanceController.h:50
armarx::control::njoint_mp_controller::task_space::Constraint::poseDiffKptLocal
Eigen::Matrix4f poseDiffKptLocal
Definition: BiKAC.h:45
armarx::control::njoint_mp_controller::task_space::Constraint::trackingForceLocal
Eigen::Vector3f trackingForceLocal
Definition: BiKAC.h:59
armarx::control::njoint_mp_controller::task_space::NJointBiKAC::mpConfig
MPListConfig mpConfig
this variable is only needed when constructing the MP instances, therefore you don't need to use trip...
Definition: BiKAC.h:131
armarx::control::njoint_mp_controller::task_space::Constraint::kptKd
Eigen::Vector3f kptKd
Definition: BiKAC.h:63
armarx::control::njoint_mp_controller::task_space::NJointBiKAC::biKacConfig
BiKACConfig biKacConfig
Definition: BiKAC.h:132
TSMP.h
armarx::control::njoint_mp_controller::task_space::Constraint::currentKptVelocityRoot
Eigen::Vector6f currentKptVelocityRoot
Definition: BiKAC.h:54
armarx::control::njoint_mp_controller::task_space::BiKACConfig
Definition: BiKAC.h:81
armarx::control::NJointBiKACInterface
Definition: ControllerInterface.ice:112
armarx::control::njoint_mp_controller::task_space::Constraint::currentKptPoseLocal
Eigen::Matrix4f currentKptPoseLocal
Definition: BiKAC.h:53
armarx::control::njoint_mp_controller::task_space::Constraint::p2pIdx
int p2pIdx
Definition: BiKAC.h:69
JSMP.h
armarx::control::njoint_controller::task_space
Definition: AdmittanceController.cpp:33
armarx::control::njoint_mp_controller::task_space::BiKACConfig::cList
std::vector< Constraint > cList
Definition: BiKAC.h:89
armarx::control::njoint_mp_controller::task_space::AdmittanceData::desiredAcc
Eigen::Vector6f desiredAcc
Definition: BiKAC.h:76
armarx::control::njoint_mp_controller::task_space::Constraint::keypointForceFilter
float keypointForceFilter
Definition: BiKAC.h:68
armarx::control::njoint_mp_controller::task_space::Constraint::mpName
std::string mpName
Definition: BiKAC.h:40
armarx::control::njoint_mp_controller::task_space::NJointBiKAC::bufferBiKACConfig
TripleBuffer< BiKACConfig > bufferBiKACConfig
Definition: BiKAC.h:143
armarx::control::common
This file is part of ArmarX.
Definition: aron_conversions.cpp:29
armarx::control::njoint_mp_controller::task_space::Constraint::priorityFactor
float priorityFactor
Definition: BiKAC.h:65
armarx::control::njoint_mp_controller::task_space::Constraint::trackingForceRoot
Eigen::Vector3f trackingForceRoot
Definition: BiKAC.h:60
armarx::control::njoint_mp_controller::task_space::BiKACConfig::kmAdmittance
Eigen::Vector6f kmAdmittance
Definition: BiKAC.h:85
armarx::detail::ControlThreadOutputBufferEntry
Definition: ControlThreadOutputBuffer.h:177
armarx::control::njoint_controller::task_space::NJointTaskspaceImpedanceController::ArmPtr
std::unique_ptr< ArmData > ArmPtr
Definition: ImpedanceController.h:96
armarx::control::njoint_mp_controller::task_space::BiKACConfig::admittanceData
std::map< std::string, AdmittanceData > admittanceData
Definition: BiKAC.h:86
armarx::control::njoint_mp_controller::task_space::Constraint::currentKptVelocityLocal
Eigen::Vector6f currentKptVelocityLocal
Definition: BiKAC.h:55
armarx::control::njoint_mp_controller::task_space::AdmittanceData::desiredPose
Eigen::Matrix4f desiredPose
Definition: BiKAC.h:74
armarx::control::njoint_mp_controller::task_space::AdmittanceData::desiredVel
Eigen::Vector6f desiredVel
Definition: BiKAC.h:75
armarx::control::njoint_mp_controller::task_space::Constraint::idx
int idx
Definition: BiKAC.h:38
armarx::control::njoint_mp_controller::task_space::Constraint
Definition: BiKAC.h:36
armarx::control::njoint_mp_controller::task_space::Constraint::targetKptPoseRoot
Eigen::Matrix4f targetKptPoseRoot
Definition: BiKAC.h:58
armarx::control::njoint_mp_controller::task_space::Constraint::pcaMeanLocal
Eigen::Vector3f pcaMeanLocal
Definition: BiKAC.h:48
armarx::control::njoint_mp_controller::task_space::Constraint::keypointPositionFilter
float keypointPositionFilter
Definition: BiKAC.h:66
armarx::control::njoint_mp_controller::task_space::Constraint::keypointVelocityFilter
float keypointVelocityFilter
Definition: BiKAC.h:67
armarx::control::njoint_mp_controller::task_space::Constraint::rnsKpt
std::string rnsKpt
Definition: BiKAC.h:42
armarx::control::njoint_mp_controller::task_space
This file is part of ArmarX.
Definition: AdmittanceController.cpp:26
armarx::control::njoint_mp_controller::task_space::AdmittanceData::forceTorque
Eigen::Vector6f forceTorque
Definition: BiKAC.h:77
armarx::aron::data::DictPtr
std::shared_ptr< Dict > DictPtr
Definition: Dict.h:41
armarx::control::njoint_mp_controller::task_space::Constraint::rnsFrame
std::string rnsFrame
Definition: BiKAC.h:43
GfxTL::Matrix3f
MatrixXX< 3, 3, float > Matrix3f
Definition: MatrixXX.h:600
GfxTL::Matrix4f
MatrixXX< 4, 4, float > Matrix4f
Definition: MatrixXX.h:601
armarx::control::njoint_mp_controller::task_space::Constraint::currentFrameRoot
Eigen::Matrix4f currentFrameRoot
Definition: BiKAC.h:51
IceInternal::ProxyHandle<::IceProxy::armarx::DebugDrawerInterface >
armarx::control::njoint_mp_controller::task_space::Constraint::pcaComponentsLocal
Eigen::Matrix3f pcaComponentsLocal
Definition: BiKAC.h:49
armarx::control::common::mp::MPPool
Definition: MPPool.h:46
ImpedanceController.h
Eigen::Matrix< float, 6, 1 >
armarx::control::njoint_mp_controller::task_space::BiKACConfig::kpAdmittance
Eigen::Vector6f kpAdmittance
Definition: BiKAC.h:83
armarx::control::njoint_mp_controller::task_space::Constraint::currentKptPoseRoot
Eigen::Matrix4f currentKptPoseRoot
Definition: BiKAC.h:52
MPPool.h
armarx::control::njoint_mp_controller::task_space::NJointBiKAC::biKacConfigForDebug
BiKACConfig biKacConfigForDebug
Definition: BiKAC.h:144
armarx::control::njoint_mp_controller::task_space::Constraint::poseDiffFrameLocal
Eigen::Matrix4f poseDiffFrameLocal
Definition: BiKAC.h:46
armarx::control::njoint_mp_controller::task_space::Constraint::targetKptPoseLocal
Eigen::Matrix4f targetKptPoseLocal
Definition: BiKAC.h:57
armarx::control::njoint_mp_controller::task_space::Constraint::type
std::string type
Definition: BiKAC.h:39
armarx::control::njoint_mp_controller::task_space::AdmittanceData::constraintIdxList
std::vector< int > constraintIdxList
Definition: BiKAC.h:78
armarx::control::njoint_mp_controller::task_space::AdmittanceData
Definition: BiKAC.h:72
VirtualRobot::RobotPtr
std::shared_ptr< class Robot > RobotPtr
Definition: Bus.h:18
armarx::control::njoint_mp_controller::task_space::NJointBiKAC::MPListConfig
common::mp::arondto::MPListConfig MPListConfig
Definition: BiKAC.h:109
armarx::TripleBuffer
A simple triple buffer for lockfree comunication between a single writer and a single reader.
Definition: TripleBuffer.h:71
armarx::control::njoint_mp_controller::task_space::NJointBiKAC
Brief description of class NJointBiKAC.
Definition: BiKAC.h:103