AdmittanceController.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 2021
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
29
33#include <armarx/control/njoint_controller/task_space/ControllerInterface.h>
34
36{
37 namespace law = armarx::control::common::control_law;
38
39 /**
40 * @defgroup Library-NJointTaskspaceAdmittanceController NJointTaskspaceAdmittanceController
41 * @ingroup Library-RobotUnit-NJointControllers
42 * A description of the library NJointTaskspaceAdmittanceController.
43 *
44 * @class NJointTaskspaceAdmittanceController
45 * @ingroup Library-NJointTaskspaceAdmittanceController
46 * @brief Brief description of class NJointTaskspaceAdmittanceController.
47 *
48 * Detailed description of class NJointTaskspaceAdmittanceController.
49 */
51 virtual public NJointController,
53 {
54 public:
55 using ConfigPtrT = ConfigurableNJointControllerConfigPtr;
56 using Config = law::TaskspaceAdmittanceController::Config;
57 using ConfigDict = law::TaskspaceAdmittanceController::ConfigDict;
58
60 using PoseFrameMode = armarx::control::common::arondto::PoseFrameMode;
61
62 struct ArmData
63 {
64 /// devices
66 std::vector<ControlTarget1DoFActuatorTorque*> targets;
67
68 /// names
69 std::string kinematicChainName;
70 std::vector<std::string> jointNames;
71
72 /// controller (maths)
73 law::TaskspaceAdmittanceController controller;
74
75 /// set data containers and buffers
76 double nonRTAccumulateTime = 0.0;
77 double nonRTDeltaT = 0.0;
78
85
91
92 /// flags
93 std::atomic_bool rtFirstRun{true};
94 std::atomic_bool rtReady{false};
95 std::atomic_bool reInitPreActivate{false};
96
97 /// robot
99 };
100
101 using ArmPtr = std::unique_ptr<ArmData>;
102
104 const NJointControllerConfigPtr& config,
106
107 std::string getClassName(const Ice::Current& = Ice::emptyCurrent) const override;
108
109 void rtRun(const IceUtil::Time& sensorValuesTimestamp,
110 const IceUtil::Time& timeSinceLastIteration) override;
111
112 /// NJointController interface
113 void updateConfig(const ::armarx::aron::data::dto::DictPtr& dto,
114 const Ice::Current& iceCurrent = Ice::emptyCurrent) override;
115 bool updateTargetPose(const TargetPoseMap& targetPoseMap,
116 const TargetNullspaceMap& targetNullspaceMap,
117 const Ice::Current& = Ice::emptyCurrent) override;
119 getConfig(const Ice::Current& iceCurrent = Ice::emptyCurrent) override;
120
121 Ice::FloatSeq getTCPVel(const std::string& rns,
122 const Ice::Current& iceCurrent = Ice::emptyCurrent) override;
123
124 /// ft sensor
125 void toggleGravityCompensation(const bool toggle, const Ice::Current&) override;
126 void calibrateFTSensor(const Ice::Current&) override;
127 void
128 enableSafeGuardForceTorque(const std::string& nodeSetName,
129 const bool forceGuard,
130 const bool torqueGuard,
131 const Ice::Current& iceCurrent = Ice::emptyCurrent) override;
132 bool isSafeForceTorque(const std::string& nodeSetName,
133 const Ice::Current& iceCurrent = Ice::emptyCurrent) override;
134
135 public:
138 const std::map<std::string, ConstControlDevicePtr>&,
139 const std::map<std::string, ConstSensorDevicePtr>&);
140
142
143 protected:
144 virtual void additionalTask();
147 void validateConfigData(Config& config, ArmPtr& arm);
148 void onPublish(const SensorAndControl&,
150 const DebugObserverInterfacePrx&) override;
151
152 void limbInit(const std::string nodeSetName,
153 ArmPtr& arm,
154 Config& cfg,
155 VirtualRobot::RobotPtr& nonRtRobotPtr);
156 void limbNonRT(ArmPtr& arm);
157 void limbRT(ArmPtr& arm, const double deltaT);
158 void limbRTUpdateStatus(ArmPtr& arm, const double deltaT);
159 void limbRTSetTarget(ArmPtr& arm, const Eigen::VectorXf& targetTorque);
160 void limbPublish(ArmPtr& arm, const DebugObserverInterfacePrx& debugObs);
161 void limbReInit(ArmPtr& arm);
163
164 protected:
165 std::map<std::string, ArmPtr> limb;
170 std::map<std::string, VirtualRobot::RobotNodeSetPtr> controllableNodeSets;
171
172 protected:
173 /// NJointControllerBase interface
174 void onInitNJointController() override;
175 void rtPreActivateController() override;
176 void rtPostDeactivateController() override;
177 };
178} // namespace armarx::control::njoint_controller::task_space
A simple triple buffer for lockfree comunication between a single writer and a single reader.
std::string getClassName(const Ice::Current &=Ice::emptyCurrent) const override
void onPublish(const SensorAndControl &, const DebugDrawerInterfacePrx &, const DebugObserverInterfacePrx &) override
static WidgetDescription::WidgetPtr GenerateConfigDescription(const VirtualRobot::RobotPtr &, const std::map< std::string, ConstControlDevicePtr > &, const std::map< std::string, ConstSensorDevicePtr > &)
--------------------------------— GUI Widget ------------------------------------------—
::armarx::aron::data::dto::DictPtr getConfig(const Ice::Current &iceCurrent=Ice::emptyCurrent) override
Ice::FloatSeq getTCPVel(const std::string &rns, const Ice::Current &iceCurrent=Ice::emptyCurrent) override
bool isSafeForceTorque(const std::string &nodeSetName, const Ice::Current &iceCurrent=Ice::emptyCurrent) override
-----------------------------— Other interaces ----------------------------------------—
void enableSafeGuardForceTorque(const std::string &nodeSetName, const bool forceGuard, const bool torqueGuard, const Ice::Current &iceCurrent=Ice::emptyCurrent) override
void rtPostDeactivateController() override
This function is called after the controller is deactivated.
void rtRun(const IceUtil::Time &sensorValuesTimestamp, const IceUtil::Time &timeSinceLastIteration) override
TODO make protected and use attorneys.
void limbInit(const std::string nodeSetName, ArmPtr &arm, Config &cfg, VirtualRobot::RobotPtr &nonRtRobotPtr)
void updateConfig(const ::armarx::aron::data::dto::DictPtr &dto, const Ice::Current &iceCurrent=Ice::emptyCurrent) override
NJointController interface.
bool updateTargetPose(const TargetPoseMap &targetPoseMap, const TargetNullspaceMap &targetNullspaceMap, const Ice::Current &=Ice::emptyCurrent) override
NJointTaskspaceAdmittanceController(const RobotUnitPtr &robotUnit, const NJointControllerConfigPtr &config, const VirtualRobot::RobotPtr &)
void limbPublish(ArmPtr &arm, const DebugObserverInterfacePrx &debugObs)
void rtPreActivateController() override
This function is called before the controller is activated.
void limbRTUpdateStatus(ArmPtr &arm, const double deltaT)
-----------------------------— Real time cotnrol --------------------------------------—
void toggleGravityCompensation(const bool toggle, const Ice::Current &) override
ft sensor
std::shared_ptr< class Robot > RobotPtr
Definition Bus.h:19
::IceInternal::Handle<::armarx::WidgetDescription::Widget > WidgetPtr
::IceInternal::Handle< Dict > DictPtr
std::shared_ptr< HandControlBase > HandControlPtr
dictionary< string, Ice::FloatSeq > TargetNullspaceMap
dictionary< string, FloatSeqSeq > TargetPoseMap
::IceInternal::ProxyHandle<::IceProxy::armarx::DebugObserverInterface > DebugObserverInterfacePrx
std::map< std::string, VariantBasePtr > StringVariantBaseMap
SynchronousNJointController NJointController
IceUtil::Handle< class RobotUnit > RobotUnitPtr
Definition FTSensor.h:34
::IceInternal::ProxyHandle<::IceProxy::armarx::DebugDrawerInterface > DebugDrawerInterfacePrx
detail::ControlThreadOutputBufferEntry SensorAndControl