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/VirtualRobot.h>
26
27#include <ArmarXCore/interface/observers/ObserverInterface.h>
29
31
32#include <armarx/control/common/control_law/aron/HandStatus.aron.generated.h>
33#include <armarx/control/interface/HandShapeControllerInterface.h>
34
36{
37 namespace law = armarx::control::common::control_law;
38
39 /**
40 * @defgroup Library-HandControlBase HandControlBase
41 * @ingroup Library-RobotUnit-NJointControllers
42 * A description of the library HandControlBase.
43 *
44 * @class HandControlBase
45 * @ingroup Library-HandControlBase
46 * @brief Brief description of class HandControlBase.
47 *
48 * Detailed description of class HandControlBase.
49 */
51 {
52
53 public:
54 using HandConfig = law::arondto::HandStatus;
55 using HandConfigDict = std::map<std::string, HandConfig>;
56
57 struct HandData
58 {
59 /// names
60 std::string kinematicChainName;
61 std::vector<std::string> jointNames;
62 size_t nJoints;
63 std::map<std::string, float> desiredJointPositionMap;
64
65 hand::HandShapeControllerInterfacePrx ctrl;
66
68 {
69 public:
70 double deltaT = 0.0;
71 double accumulateTime = 0.0;
72 };
73
74 Eigen::VectorXf jointLimMin;
75 Eigen::VectorXf jointLimMax;
76
80
83
84 double nonRTAccumulateTime = 0.0;
85 double nonRTDeltaT = 0.0;
90
91 void validate();
92 void setTarget();
93 bool isTargetChanged();
94
95 HandData(const RobotUnitPtr& robotUnit,
96 const VirtualRobot::RobotNodeSetPtr& robotNodeSet,
97 const HandConfig& cfg);
98 void rtPreActivate();
99 };
100
101 using HandPtr = std::unique_ptr<HandData>;
102
103 HandControlBase(const RobotUnitPtr& robotUnit,
104 const VirtualRobot::RobotPtr& rtRobot,
105 const HandConfigDict& cfg);
107
108 void nonRTSetTarget();
109 void updateRTStatus(double deltaT);
110 void nonRTUpdateStatus();
111 void updateConfig(const HandConfigDict& cfg);
112 void getConfig(HandConfigDict& cfgToUpdate);
113 void reinitBuffer(HandConfigDict& cfgToUpdate);
115 void rtPreActivate();
116 void rtPostDeactivate(HandConfigDict& cfgToUpdate);
117 void limbPublish(HandPtr& hand, const DebugObserverInterfacePrx& debugObs);
118 void onPublish(const DebugObserverInterfacePrx& debugObs);
119
120 std::map<std::string, HandPtr> hands;
121 };
122
123 using HandControlPtr = std::shared_ptr<HandControlBase>;
124} // namespace armarx::control::njoint_controller::core
A simple triple buffer for lockfree comunication between a single writer and a single reader.
void onPublish(const DebugObserverInterfacePrx &debugObs)
void limbPublish(HandPtr &hand, const DebugObserverInterfacePrx &debugObs)
HandControlBase(const RobotUnitPtr &robotUnit, const VirtualRobot::RobotPtr &rtRobot, const HandConfigDict &cfg)
std::shared_ptr< class Robot > RobotPtr
Definition Bus.h:19
std::shared_ptr< HandControlBase > HandControlPtr
::IceInternal::ProxyHandle<::IceProxy::armarx::DebugObserverInterface > DebugObserverInterfacePrx
IceUtil::Handle< class RobotUnit > RobotUnitPtr
Definition FTSensor.h:34
void validate()
----------------------------------— HandData ------------------------------------------—
HandData(const RobotUnitPtr &robotUnit, const VirtualRobot::RobotNodeSetPtr &robotNodeSet, const HandConfig &cfg)