HandControlBase.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 2024
19  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20  * GNU General Public License
21  */
22 
23 #pragma once
24 
25 #include <VirtualRobot/Robot.h>
26 #include <VirtualRobot/RobotNodeSet.h>
27 #include <VirtualRobot/VirtualRobot.h>
28 
30 
32 
33 #include <armarx/control/common/control_law/aron/HandStatus.aron.generated.h>
35 
37 {
38 
40 
41  /**
42  * @defgroup Library-HandControlBase HandControlBase
43  * @ingroup Library-RobotUnit-NJointControllers
44  * A description of the library HandControlBase.
45  *
46  * @class HandControlBase
47  * @ingroup Library-HandControlBase
48  * @brief Brief description of class HandControlBase.
49  *
50  * Detailed description of class HandControlBase.
51  */
53  {
54 
55  public:
56  using HandConfig = law::arondto::HandStatus;
57  using HandConfigDict = std::map<std::string, HandConfig>;
58 
59  struct HandData
60  {
61  /// names
62  std::string kinematicChainName;
63  std::vector<std::string> jointNames;
64  size_t nJoints;
65 
66  /// devices
68  std::vector<ControlTarget1DoFActuatorPosition*> targets;
69 
70  class RTStatus : public HandConfig
71  {
72  public:
73  double deltaT = 0.0;
74  };
75 
76  Eigen::VectorXf jointLimMin;
77  Eigen::VectorXf jointLimMax;
78 
82 
87 
88  void validate();
89  void setTarget();
90 
91  HandData(const VirtualRobot::RobotNodeSetPtr& robotNodeSet, const HandConfig& cfg);
92  void rtPreActivate();
93  };
94 
95  using HandPtr = std::unique_ptr<HandData>;
96 
97  HandControlBase(const VirtualRobot::RobotPtr& rtRobot, const HandConfigDict& cfg);
99 
100 
101  void appendDevice(const std::string& handNodeSet,
102  const SensorValueBase* sv,
103  ControlTargetBase* ct,
104  const std::string& jointName);
105 
106  public:
107  void nonRTSetTarget();
108  void setTargets();
109  void updateRTStatus(const double deltaT);
110  void nonRTUpdateStatus();
111  void updateConfig(const HandConfigDict& cfg);
112  void getConfig(HandConfigDict& cfgToUpdate);
113  void reinitBuffer(HandConfigDict& cfgToUpdate);
114  void rtPreActivate();
115  void rtPostDeactivate();
116 
117  public:
118  std::map<std::string, HandPtr> hands;
119  };
120 
121  using HandControlPtr = std::shared_ptr<HandControlBase>;
122 } // namespace armarx::control::njoint_controller::core
armarx::control::njoint_controller::core::HandControlBase::setTargets
void setTargets()
Definition: HandControlBase.cpp:65
armarx::control::njoint_controller::core::HandControlBase::HandData::kinematicChainName
std::string kinematicChainName
names
Definition: HandControlBase.h:62
armarx::control::njoint_controller::core::HandControlPtr
std::shared_ptr< HandControlBase > HandControlPtr
Definition: HandControlBase.h:121
armarx::control::njoint_controller::core::HandControlBase::HandData::bufferRTToUser
TripleBuffer< HandConfig > bufferRTToUser
Definition: HandControlBase.h:86
armarx::SensorValueBase
The SensorValueBase class.
Definition: SensorValueBase.h:40
armarx::control::njoint_controller::core::HandControlBase::nonRTUpdateStatus
void nonRTUpdateStatus()
Definition: HandControlBase.cpp:43
armarx::ControlTargetBase
Brief description of class JointControlTargetBase.
Definition: ControlTargetBase.h:47
armarx::control::njoint_controller::core::HandControlBase::HandData::rtPreActivate
void rtPreActivate()
Definition: HandControlBase.cpp:163
armarx::control::common::SensorDevicesForNJointTorqueController
Definition: device.h:12
armarx::control::njoint_controller::core
This file is part of ArmarX.
Definition: CollisionAvoidanceCore.cpp:3
device.h
armarx::control::njoint_controller::core::HandControlBase::HandData::RTStatus
Definition: HandControlBase.h:70
armarx::control::njoint_controller::core::HandControlBase::nonRTSetTarget
void nonRTSetTarget()
Definition: HandControlBase.cpp:32
armarx::control::njoint_controller::core::HandControlBase::hands
std::map< std::string, HandPtr > hands
Definition: HandControlBase.h:118
armarx::control::njoint_controller::core::HandControlBase::rtPreActivate
void rtPreActivate()
Definition: HandControlBase.cpp:108
armarx::control::njoint_controller::core::HandControlBase::HandData::bufferRTToNonRT
TripleBuffer< RTStatus > bufferRTToNonRT
Definition: HandControlBase.h:84
armarx::control::njoint_controller::core::HandControlBase::HandData::bufferNonRTToRT
TripleBuffer< HandConfig > bufferNonRTToRT
Definition: HandControlBase.h:83
armarx::control::njoint_controller::core::HandControlBase::HandData::jointNames
std::vector< std::string > jointNames
Definition: HandControlBase.h:63
armarx::control::njoint_controller::core::HandControlBase::HandControlBase
HandControlBase(const VirtualRobot::RobotPtr &rtRobot, const HandConfigDict &cfg)
Definition: HandControlBase.cpp:6
armarx::control::njoint_controller::core::HandControlBase::HandData::jointLimMax
Eigen::VectorXf jointLimMax
Definition: HandControlBase.h:77
armarx::control::njoint_controller::core::HandControlBase::~HandControlBase
~HandControlBase()
Definition: HandControlBase.h:98
armarx::control::njoint_controller::core::HandControlBase::HandPtr
std::unique_ptr< HandData > HandPtr
Definition: HandControlBase.h:95
armarx::control::njoint_controller::core::HandControlBase::HandData::validate
void validate()
----------------------------------— HandData ------------------------------------------—
Definition: HandControlBase.cpp:124
armarx::control::njoint_controller::core::HandControlBase::rtPostDeactivate
void rtPostDeactivate()
Definition: HandControlBase.cpp:118
armarx::control::njoint_controller::core::HandControlBase::HandData::bufferUserToNonRT
TripleBuffer< HandConfig > bufferUserToNonRT
Definition: HandControlBase.h:85
armarx::control::njoint_controller::core::HandControlBase::HandData::setTarget
void setTarget()
Definition: HandControlBase.cpp:133
armarx::control::njoint_controller::core::HandControlBase::HandData::HandData
HandData(const VirtualRobot::RobotNodeSetPtr &robotNodeSet, const HandConfig &cfg)
Definition: HandControlBase.cpp:146
armarx::control::common::control_law
This file is part of ArmarX.
Definition: aron_conversions.cpp:68
ControlTarget1DoFActuator.h
armarx::control::njoint_controller::core::HandControlBase
Brief description of class HandControlBase.
Definition: HandControlBase.h:52
armarx::control::njoint_controller::core::HandControlBase::HandData::sensorDevices
common::SensorDevicesForNJointTorqueController sensorDevices
devices
Definition: HandControlBase.h:67
armarx::control::njoint_controller::core::HandControlBase::HandData::rts
RTStatus rts
Definition: HandControlBase.h:81
armarx::control::njoint_controller::core::HandControlBase::HandData::nJoints
size_t nJoints
Definition: HandControlBase.h:64
armarx::control::njoint_controller::core::HandControlBase::updateConfig
void updateConfig(const HandConfigDict &cfg)
Definition: HandControlBase.cpp:74
armarx::control::njoint_controller::core::HandControlBase::HandData::targetNonRT
HandConfig targetNonRT
Definition: HandControlBase.h:80
armarx::control::njoint_controller::core::HandControlBase::appendDevice
void appendDevice(const std::string &handNodeSet, const SensorValueBase *sv, ControlTargetBase *ct, const std::string &jointName)
Definition: HandControlBase.cpp:17
armarx::control::njoint_controller::core::HandControlBase::HandData::targetRT
HandConfig targetRT
Definition: HandControlBase.h:79
TripleBuffer.h
armarx::control::njoint_controller::core::HandControlBase::HandData::jointLimMin
Eigen::VectorXf jointLimMin
Definition: HandControlBase.h:76
armarx::control::njoint_controller::core::HandControlBase::HandData::targets
std::vector< ControlTarget1DoFActuatorPosition * > targets
Definition: HandControlBase.h:68
armarx::control::njoint_controller::core::HandControlBase::HandData::RTStatus::deltaT
double deltaT
Definition: HandControlBase.h:73
armarx::control::njoint_controller::core::HandControlBase::HandData
Definition: HandControlBase.h:59
armarx::control::njoint_controller::core::HandControlBase::HandConfigDict
std::map< std::string, HandConfig > HandConfigDict
Definition: HandControlBase.h:57
armarx::control::njoint_controller::core::HandControlBase::updateRTStatus
void updateRTStatus(const double deltaT)
Definition: HandControlBase.cpp:53
armarx::control::njoint_controller::core::HandControlBase::getConfig
void getConfig(HandConfigDict &cfgToUpdate)
Definition: HandControlBase.cpp:88
armarx::control::njoint_controller::core::HandControlBase::HandConfig
law::arondto::HandStatus HandConfig
Definition: HandControlBase.h:56
armarx::control::njoint_controller::core::HandControlBase::reinitBuffer
void reinitBuffer(HandConfigDict &cfgToUpdate)
Definition: HandControlBase.cpp:97
VirtualRobot::RobotPtr
std::shared_ptr< class Robot > RobotPtr
Definition: Bus.h:18
armarx::TripleBuffer< HandConfig >