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 
28 
32 #include <armarx/control/njoint_controller/task_space/ControllerInterface.h>
33 
35 {
37 
38  /**
39  * @defgroup Library-NJointTaskspaceAdmittanceController NJointTaskspaceAdmittanceController
40  * @ingroup Library-RobotUnit-NJointControllers
41  * A description of the library NJointTaskspaceAdmittanceController.
42  *
43  * @class NJointTaskspaceAdmittanceController
44  * @ingroup Library-NJointTaskspaceAdmittanceController
45  * @brief Brief description of class NJointTaskspaceAdmittanceController.
46  *
47  * Detailed description of class NJointTaskspaceAdmittanceController.
48  */
50  virtual public NJointController,
52  {
53  public:
54  using ConfigPtrT = ConfigurableNJointControllerConfigPtr;
57  using RtStatus = law::TaskspaceAdmittanceController::RtStatus;
58 
59  struct ArmData
60  {
61  /// devices
63  std::vector<ControlTarget1DoFActuatorTorque*> targets;
64 
65  /// names
66  std::string kinematicChainName;
67  std::vector<std::string> jointNames;
68 
69  /// controller (maths)
71 
72  /// set data containers and buffers
73  double nonRTAccumulateTime = 0.0;
74  double nonRTDeltaT = 0.0;
75 
82 
88 
89  /// flags
90  std::atomic_bool rtFirstRun{true};
91  std::atomic_bool rtReady{false};
92  std::atomic_bool reInitPreActivate{false};
93 
94  /// robot
96  };
97 
98  using ArmPtr = std::unique_ptr<ArmData>;
99 
101  const NJointControllerConfigPtr& config,
102  const VirtualRobot::RobotPtr&);
103 
104  std::string getClassName(const Ice::Current& = Ice::emptyCurrent) const override;
105 
106  void rtRun(const IceUtil::Time& sensorValuesTimestamp,
107  const IceUtil::Time& timeSinceLastIteration) override;
108 
109  /// NJointController interface
111  const Ice::Current& iceCurrent = Ice::emptyCurrent) override;
112  bool updateTargetPose(const TargetPoseMap& targetPoseMap,
113  const TargetNullspaceMap& targetNullspaceMap,
114  const Ice::Current& = Ice::emptyCurrent) override;
116  getConfig(const Ice::Current& iceCurrent = Ice::emptyCurrent) override;
117 
118  Ice::FloatSeq getTCPVel(const std::string& rns,
119  const Ice::Current& iceCurrent = Ice::emptyCurrent) override;
120 
121  /// ft sensor
122  void toggleGravityCompensation(const bool toggle, const Ice::Current&) override;
123  void calibrateFTSensor(const Ice::Current&) override;
124  void
125  enableSafeGuardForceTorque(const std::string& nodeSetName,
126  const bool forceGuard,
127  const bool torqueGuard,
128  const Ice::Current& iceCurrent = Ice::emptyCurrent) override;
129  bool isSafeForceTorque(const std::string& nodeSetName,
130  const Ice::Current& iceCurrent = Ice::emptyCurrent) override;
131 
132  public:
135  const std::map<std::string, ConstControlDevicePtr>&,
136  const std::map<std::string, ConstSensorDevicePtr>&);
137 
139 
140  protected:
141  virtual void additionalTask();
144  void validateConfigData(Config& config, ArmPtr& arm);
145  void onPublish(const SensorAndControl&,
147  const DebugObserverInterfacePrx&) override;
148 
149  void limbInit(const std::string nodeSetName,
150  ArmPtr& arm,
151  Config& cfg,
152  VirtualRobot::RobotPtr& nonRtRobotPtr);
153  void limbNonRT(ArmPtr& arm);
154  void limbRT(ArmPtr& arm, const double deltaT);
155  void limbRTUpdateStatus(ArmPtr& arm, const double deltaT);
156  void limbRTSetTarget(ArmPtr& arm, const Eigen::VectorXf& targetTorque);
157  void limbPublish(ArmPtr& arm, const DebugObserverInterfacePrx& debugObs);
158  void limbReInit(ArmPtr& arm);
159  void handleRTNotSafeInNonRT();
160 
161  protected:
162  std::map<std::string, ArmPtr> limb;
167  std::map<std::string, VirtualRobot::RobotNodeSetPtr> controllableNodeSets;
168 
169  protected:
170  /// NJointControllerBase interface
171  void onInitNJointController() override;
172  void rtPreActivateController() override;
173  void rtPostDeactivateController() override;
174  };
175 } // namespace armarx::control::njoint_controller::task_space
armarx::control::common::control_law::TaskspaceAdmittanceController::Config
common::control_law::arondto::TaskspaceAdmittanceControllerConfig Config
Definition: TaskspaceAdmittanceController.h:40
HandControlBase.h
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::ArmData::jointNames
std::vector< std::string > jointNames
Definition: AdmittanceController.h:67
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::limb
std::map< std::string, ArmPtr > limb
Definition: AdmittanceController.h:162
armarx::control::njoint_controller::core::HandControlPtr
std::shared_ptr< HandControlBase > HandControlPtr
Definition: HandControlBase.h:127
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::ArmData::nonRTAccumulateTime
double nonRTAccumulateTime
set data containers and buffers
Definition: AdmittanceController.h:73
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::toggleGravityCompensation
void toggleGravityCompensation(const bool toggle, const Ice::Current &) override
ft sensor
Definition: AdmittanceController.cpp:566
armarx::StringVariantBaseMap
std::map< std::string, VariantBasePtr > StringVariantBaseMap
Definition: ManagedIceObject.h:110
NJointControllerBase.h
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::robotUnit
RobotUnitPtr robotUnit
Definition: AdmittanceController.h:164
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::limbNonRT
void limbNonRT(ArmPtr &arm)
Definition: AdmittanceController.cpp:166
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::rtPostDeactivateController
void rtPostDeactivateController() override
This function is called after the controller is deactivated.
Definition: AdmittanceController.cpp:637
armarx::control::common::control_law::TaskspaceAdmittanceController
Definition: TaskspaceAdmittanceController.h:36
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::ArmData::bufferConfigRtToUser
TripleBuffer< Config > bufferConfigRtToUser
Definition: AdmittanceController.h:81
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::controllableNodeSets
std::map< std::string, VirtualRobot::RobotNodeSetPtr > controllableNodeSets
Definition: AdmittanceController.h:167
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::limbRTUpdateStatus
void limbRTUpdateStatus(ArmPtr &arm, const double deltaT)
-----------------------------— Real time cotnrol --------------------------------------—
Definition: AdmittanceController.cpp:238
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::isSafeForceTorque
bool isSafeForceTorque(const std::string &nodeSetName, const Ice::Current &iceCurrent=Ice::emptyCurrent) override
-----------------------------— Other interaces ----------------------------------------—
Definition: AdmittanceController.cpp:412
armarx::SynchronousNJointController
Definition: NJointControllerBase.h:1146
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::limbInit
void limbInit(const std::string nodeSetName, ArmPtr &arm, Config &cfg, VirtualRobot::RobotPtr &nonRtRobotPtr)
Definition: AdmittanceController.cpp:50
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::ArmData::nonRtConfig
Config nonRtConfig
Definition: AdmittanceController.h:76
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::onPublish
void onPublish(const SensorAndControl &, const DebugDrawerInterfacePrx &, const DebugObserverInterfacePrx &) override
Definition: AdmittanceController.cpp:544
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::additionalTaskSetTarget
void additionalTaskSetTarget()
Definition: AdmittanceController.cpp:203
armarx::control::njoint_controller::task_space
Definition: AdmittanceController.cpp:43
armarx::control::common::SensorDevicesForNJointTorqueController
Definition: device.h:12
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::userConfig
ConfigDict userConfig
Definition: AdmittanceController.h:165
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::ArmPtr
std::unique_ptr< ArmData > ArmPtr
Definition: AdmittanceController.h:98
ProsthesisInterface.values
values
Definition: ProsthesisInterface.py:190
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::enableSafeGuardForceTorque
void enableSafeGuardForceTorque(const std::string &nodeSetName, const bool forceGuard, const bool torqueGuard, const Ice::Current &iceCurrent=Ice::emptyCurrent) override
Definition: AdmittanceController.cpp:386
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::ArmData::rtStatusInNonRT
RtStatus rtStatusInNonRT
Definition: AdmittanceController.h:83
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::nonRtRobot
VirtualRobot::RobotPtr nonRtRobot
Definition: AdmittanceController.h:163
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::ArmData::rtConfig
Config rtConfig
Definition: AdmittanceController.h:77
armarx::NJointControllerBase::ConfigPtrT
NJointControllerConfigPtr ConfigPtrT
Definition: NJointControllerBase.h:587
device.h
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::rtPreActivateController
void rtPreActivateController() override
This function is called before the controller is activated.
Definition: AdmittanceController.cpp:622
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::ArmData::bufferConfigNonRtToRt
TripleBuffer< Config > bufferConfigNonRtToRt
Definition: AdmittanceController.h:79
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::rtRun
void rtRun(const IceUtil::Time &sensorValuesTimestamp, const IceUtil::Time &timeSinceLastIteration) override
TODO make protected and use attorneys.
Definition: AdmittanceController.cpp:323
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::ArmData::bufferRtStatusToOnPublish
TripleBuffer< RtStatus > bufferRtStatusToOnPublish
Definition: AdmittanceController.h:85
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::ArmData::rtReady
std::atomic_bool rtReady
Definition: AdmittanceController.h:91
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::ArmData::targets
std::vector< ControlTarget1DoFActuatorTorque * > targets
Definition: AdmittanceController.h:63
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::ArmData::bufferRtStatusToUser
TripleBuffer< RtStatus > bufferRtStatusToUser
Definition: AdmittanceController.h:86
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::ArmData::bufferConfigRtToOnPublish
TripleBuffer< Config > bufferConfigRtToOnPublish
Definition: AdmittanceController.h:80
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::hands
core::HandControlPtr hands
Definition: AdmittanceController.h:166
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::ArmData::kinematicChainName
std::string kinematicChainName
names
Definition: AdmittanceController.h:66
IceInternal::Handle
Definition: forward_declarations.h:8
armarx::detail::ControlThreadOutputBufferEntry
Definition: ControlThreadOutputBuffer.h:182
armarx::control::TargetNullspaceMap
dictionary< string, Ice::FloatSeq > TargetNullspaceMap
Definition: ControllerInterface.ice:40
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::additionalTask
virtual void additionalTask()
Definition: AdmittanceController.cpp:173
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::limbRTSetTarget
void limbRTSetTarget(ArmPtr &arm, const Eigen::VectorXf &targetTorque)
Definition: AdmittanceController.cpp:265
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::ConfigDict
law::TaskspaceAdmittanceController::ConfigDict ConfigDict
Definition: AdmittanceController.h:56
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::ArmData::reInitPreActivate
std::atomic_bool reInitPreActivate
Definition: AdmittanceController.h:92
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController
Brief description of class NJointTaskspaceAdmittanceController.
Definition: AdmittanceController.h:49
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::ArmData::bufferRtStatusToNonRt
TripleBuffer< RtStatus > bufferRtStatusToNonRt
Definition: AdmittanceController.h:87
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::ArmData::nonRTDeltaT
double nonRTDeltaT
Definition: AdmittanceController.h:74
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::ArmData::rtStatus
RtStatus rtStatus
Definition: AdmittanceController.h:84
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::limbRT
void limbRT(ArmPtr &arm, const double deltaT)
Definition: AdmittanceController.cpp:293
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::limbPublish
void limbPublish(ArmPtr &arm, const DebugObserverInterfacePrx &debugObs)
Definition: AdmittanceController.cpp:519
armarx::control::common::control_law
This file is part of ArmarX.
Definition: aron_conversions.cpp:68
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::additionalTaskUpdateStatus
bool additionalTaskUpdateStatus()
Definition: AdmittanceController.cpp:184
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::GenerateConfigDescription
static WidgetDescription::WidgetPtr GenerateConfigDescription(const VirtualRobot::RobotPtr &, const std::map< std::string, ConstControlDevicePtr > &, const std::map< std::string, ConstSensorDevicePtr > &)
--------------------------------— GUI Widget ------------------------------------------—
Definition: AdmittanceController.cpp:647
TaskspaceAdmittanceController.h
armarx::control::NJointTaskspaceAdmittanceControllerInterface
Definition: ControllerInterface.ice:112
armarx::armem::Time
armarx::core::time::DateTime Time
Definition: forward_declarations.h:13
armarx::control::common::control_law::TaskspaceAdmittanceController::ConfigDict
common::control_law::arondto::TaskspaceAdmittanceControllerConfigDict ConfigDict
Definition: TaskspaceAdmittanceController.h:41
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::ArmData::rtFirstRun
std::atomic_bool rtFirstRun
flags
Definition: AdmittanceController.h:90
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::handleRTNotSafeInNonRT
void handleRTNotSafeInNonRT()
Definition: AdmittanceController.cpp:216
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::limbReInit
void limbReInit(ArmPtr &arm)
Definition: AdmittanceController.cpp:576
armarx::aron::data::DictPtr
std::shared_ptr< Dict > DictPtr
Definition: Dict.h:41
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::ArmData::controller
law::TaskspaceAdmittanceController controller
controller (maths)
Definition: AdmittanceController.h:70
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::getConfig
::armarx::aron::data::dto::DictPtr getConfig(const Ice::Current &iceCurrent=Ice::emptyCurrent) override
Definition: AdmittanceController.cpp:371
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::updateTargetPose
bool updateTargetPose(const TargetPoseMap &targetPoseMap, const TargetNullspaceMap &targetNullspaceMap, const Ice::Current &=Ice::emptyCurrent) override
Definition: AdmittanceController.cpp:443
IceUtil::Handle< class RobotUnit >
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::getTCPVel
Ice::FloatSeq getTCPVel(const std::string &rns, const Ice::Current &iceCurrent=Ice::emptyCurrent) override
Definition: AdmittanceController.cpp:429
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::ArmData::sensorDevices
common::SensorDevicesForNJointTorqueController sensorDevices
devices
Definition: AdmittanceController.h:62
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::ArmData::nonRtRobot
VirtualRobot::RobotPtr nonRtRobot
robot
Definition: AdmittanceController.h:95
IceInternal::ProxyHandle<::IceProxy::armarx::DebugDrawerInterface >
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::updateConfig
void updateConfig(const ::armarx::aron::data::dto::DictPtr &dto, const Ice::Current &iceCurrent=Ice::emptyCurrent) override
NJointController interface.
Definition: AdmittanceController.cpp:340
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::getClassName
std::string getClassName(const Ice::Current &=Ice::emptyCurrent) const override
Definition: AdmittanceController.cpp:134
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::validateConfigData
void validateConfigData(Config &config, ArmPtr &arm)
Definition: AdmittanceController.cpp:475
armarx::control::TargetPoseMap
dictionary< string, FloatSeqSeq > TargetPoseMap
Definition: ControllerInterface.ice:39
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::RtStatus
law::TaskspaceAdmittanceController::RtStatus RtStatus
Definition: AdmittanceController.h:57
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::Config
law::TaskspaceAdmittanceController::Config Config
Definition: AdmittanceController.h:55
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::ArmData
Definition: AdmittanceController.h:59
armarx::control::NJointTaskspaceAdmittanceControllerInterface::calibrateFTSensor
void calibrateFTSensor()
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::ArmData::bufferConfigUserToNonRt
TripleBuffer< Config > bufferConfigUserToNonRt
Definition: AdmittanceController.h:78
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::onInitNJointController
void onInitNJointController() override
NJointControllerBase interface.
Definition: AdmittanceController.cpp:140
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::GenerateConfigFromVariants
static ConfigPtrT GenerateConfigFromVariants(const StringVariantBaseMap &values)
Definition: AdmittanceController.cpp:680
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::NJointTaskspaceAdmittanceController
NJointTaskspaceAdmittanceController(const RobotUnitPtr &robotUnit, const NJointControllerConfigPtr &config, const VirtualRobot::RobotPtr &)
Definition: AdmittanceController.cpp:91
VirtualRobot::RobotPtr
std::shared_ptr< class Robot > RobotPtr
Definition: Bus.h:19
armarx::TripleBuffer< Config >