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/Robot.h>
26 
30 
34 #include <armarx/control/njoint_controller/task_space/ControllerInterface.h>
35 
37 {
39 
40  /**
41  * @defgroup Library-NJointTaskspaceAdmittanceController NJointTaskspaceAdmittanceController
42  * @ingroup Library-RobotUnit-NJointControllers
43  * A description of the library NJointTaskspaceAdmittanceController.
44  *
45  * @class NJointTaskspaceAdmittanceController
46  * @ingroup Library-NJointTaskspaceAdmittanceController
47  * @brief Brief description of class NJointTaskspaceAdmittanceController.
48  *
49  * Detailed description of class NJointTaskspaceAdmittanceController.
50  */
52  virtual public NJointController,
54  {
55  public:
56  using ConfigPtrT = ConfigurableNJointControllerConfigPtr;
59  using RtStatus = law::TaskspaceAdmittanceController::RtStatus;
60 
61  struct ArmData
62  {
63  /// devices
65  std::vector<ControlTarget1DoFActuatorTorque*> targets;
66 
67  /// names
68  std::string kinematicChainName;
69  std::vector<std::string> jointNames;
70 
71  /// controller (maths)
73 
74  /// set data containers and buffers
81 
87 
88  /// flags
89  std::atomic_bool rtFirstRun{true};
90  std::atomic_bool rtReady{false};
91  std::atomic_bool reInitPreActivate{false};
92 
93  /// robot
95  };
96 
97  using ArmPtr = std::unique_ptr<ArmData>;
98 
100  const NJointControllerConfigPtr& config,
101  const VirtualRobot::RobotPtr&);
102 
103  std::string getClassName(const Ice::Current& = Ice::emptyCurrent) const override;
104 
105  void rtRun(const IceUtil::Time& sensorValuesTimestamp,
106  const IceUtil::Time& timeSinceLastIteration) override;
107 
108  /// NJointController interface
110  const Ice::Current& iceCurrent = Ice::emptyCurrent) override;
111  bool updateTargetPose(const TargetPoseMap& targetPoseMap,
112  const TargetNullspaceMap& targetNullspaceMap,
113  const Ice::Current& = Ice::emptyCurrent) override;
115  getConfig(const Ice::Current& iceCurrent = Ice::emptyCurrent) override;
116 
117  Ice::FloatSeq getTCPVel(const std::string& rns,
118  const Ice::Current& iceCurrent = Ice::emptyCurrent) override;
119 
120  /// ft sensor
121  void toggleGravityCompensation(const bool toggle, const Ice::Current &) override;
122  void calibrateFTSensor(const Ice::Current&) override;
123  void
124  enableSafeGuardForceTorque(const std::string& nodeSetName,
125  const bool forceGuard,
126  const bool torqueGuard,
127  const Ice::Current& iceCurrent = Ice::emptyCurrent) override;
128  bool isSafeForceTorque(const std::string& nodeSetName,
129  const Ice::Current& iceCurrent = Ice::emptyCurrent) override;
130 
131  public:
134  const std::map<std::string, ConstControlDevicePtr>&,
135  const std::map<std::string, ConstSensorDevicePtr>&);
136 
138 
139  protected:
140  virtual void additionalTask();
143  void validateConfigData(Config& config, ArmPtr& arm);
144  void onPublish(const SensorAndControl&,
146  const DebugObserverInterfacePrx&) override;
147 
148  void limbInit(const std::string nodeSetName,
149  ArmPtr& arm,
150  Config& cfg,
151  VirtualRobot::RobotPtr& nonRtRobotPtr);
152  void limbNonRT(ArmPtr& arm);
153  void limbRT(ArmPtr& arm, const double deltaT);
154  void limbRTUpdateStatus(ArmPtr& arm, const double deltaT);
155  void limbRTSetTarget(ArmPtr& arm, const Eigen::VectorXf& targetTorque);
156  void limbPublish(ArmPtr& arm, const DebugObserverInterfacePrx& debugObs);
157  void limbReInit(ArmPtr& arm);
158  void handleRTNotSafeInNonRT();
159 
160  protected:
161  std::map<std::string, ArmPtr> limb;
163  RobotUnitPtr robotUnit;
166  std::map<std::string, VirtualRobot::RobotNodeSetPtr> controllableNodeSets;
167 
168  protected:
169  /// NJointControllerBase interface
170  void onInitNJointController() override;
171  void rtPreActivateController() override;
172  void rtPostDeactivateController() override;
173  };
174 } // namespace armarx::control::njoint_controller::task_space
armarx::control::common::control_law::TaskspaceAdmittanceController::Config
common::control_law::arondto::TaskspaceAdmittanceControllerConfig Config
Definition: TaskspaceAdmittanceController.h:44
HandControlBase.h
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::ArmData::jointNames
std::vector< std::string > jointNames
Definition: AdmittanceController.h:69
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::limb
std::map< std::string, ArmPtr > limb
Definition: AdmittanceController.h:161
armarx::control::njoint_controller::core::HandControlPtr
std::shared_ptr< HandControlBase > HandControlPtr
Definition: HandControlBase.h:121
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::toggleGravityCompensation
void toggleGravityCompensation(const bool toggle, const Ice::Current &) override
ft sensor
Definition: AdmittanceController.cpp:554
armarx::StringVariantBaseMap
std::map< std::string, VariantBasePtr > StringVariantBaseMap
Definition: ManagedIceObject.h:111
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::robotUnit
RobotUnitPtr robotUnit
Definition: AdmittanceController.h:163
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::limbNonRT
void limbNonRT(ArmPtr &arm)
Definition: AdmittanceController.cpp:160
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::rtPostDeactivateController
void rtPostDeactivateController() override
This function is called after the controller is deactivated.
Definition: AdmittanceController.cpp:623
armarx::control::common::control_law::TaskspaceAdmittanceController
Definition: TaskspaceAdmittanceController.h:40
RobotUnit.h
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::ArmData::bufferConfigRtToUser
TripleBuffer< Config > bufferConfigRtToUser
Definition: AdmittanceController.h:80
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::controllableNodeSets
std::map< std::string, VirtualRobot::RobotNodeSetPtr > controllableNodeSets
Definition: AdmittanceController.h:166
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::limbRTUpdateStatus
void limbRTUpdateStatus(ArmPtr &arm, const double deltaT)
-----------------------------— Real time cotnrol --------------------------------------—
Definition: AdmittanceController.cpp:231
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:400
armarx::SynchronousNJointController
Definition: NJointControllerBase.h:1145
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::limbInit
void limbInit(const std::string nodeSetName, ArmPtr &arm, Config &cfg, VirtualRobot::RobotPtr &nonRtRobotPtr)
Definition: AdmittanceController.cpp:44
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::ArmData::nonRtConfig
Config nonRtConfig
set data containers and buffers
Definition: AdmittanceController.h:75
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::onPublish
void onPublish(const SensorAndControl &, const DebugDrawerInterfacePrx &, const DebugObserverInterfacePrx &) override
Definition: AdmittanceController.cpp:532
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::additionalTaskSetTarget
void additionalTaskSetTarget()
Definition: AdmittanceController.cpp:197
armarx::control::njoint_controller::task_space
Definition: AdmittanceController.cpp:37
armarx::control::common::SensorDevicesForNJointTorqueController
Definition: device.h:12
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::userConfig
ConfigDict userConfig
Definition: AdmittanceController.h:164
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::ArmPtr
std::unique_ptr< ArmData > ArmPtr
Definition: AdmittanceController.h:97
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:374
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::ArmData::rtStatusInNonRT
RtStatus rtStatusInNonRT
Definition: AdmittanceController.h:82
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::nonRtRobot
VirtualRobot::RobotPtr nonRtRobot
Definition: AdmittanceController.h:162
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::ArmData::rtConfig
Config rtConfig
Definition: AdmittanceController.h:76
armarx::NJointControllerBase::ConfigPtrT
NJointControllerConfigPtr ConfigPtrT
Definition: NJointControllerBase.h:586
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:608
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::ArmData::bufferConfigNonRtToRt
TripleBuffer< Config > bufferConfigNonRtToRt
Definition: AdmittanceController.h:78
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:313
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::ArmData::bufferRtStatusToOnPublish
TripleBuffer< RtStatus > bufferRtStatusToOnPublish
Definition: AdmittanceController.h:84
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::ArmData::rtReady
std::atomic_bool rtReady
Definition: AdmittanceController.h:90
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::ArmData::targets
std::vector< ControlTarget1DoFActuatorTorque * > targets
Definition: AdmittanceController.h:65
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::ArmData::bufferRtStatusToUser
TripleBuffer< RtStatus > bufferRtStatusToUser
Definition: AdmittanceController.h:85
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::ArmData::bufferConfigRtToOnPublish
TripleBuffer< Config > bufferConfigRtToOnPublish
Definition: AdmittanceController.h:79
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::hands
core::HandControlPtr hands
Definition: AdmittanceController.h:165
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::ArmData::kinematicChainName
std::string kinematicChainName
names
Definition: AdmittanceController.h:68
IceInternal::Handle
Definition: forward_declarations.h:8
armarx::detail::ControlThreadOutputBufferEntry
Definition: ControlThreadOutputBuffer.h:177
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:167
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::limbRTSetTarget
void limbRTSetTarget(ArmPtr &arm, const Eigen::VectorXf &targetTorque)
Definition: AdmittanceController.cpp:255
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::ConfigDict
law::TaskspaceAdmittanceController::ConfigDict ConfigDict
Definition: AdmittanceController.h:58
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::ArmData::reInitPreActivate
std::atomic_bool reInitPreActivate
Definition: AdmittanceController.h:91
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController
Brief description of class NJointTaskspaceAdmittanceController.
Definition: AdmittanceController.h:51
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::ArmData::bufferRtStatusToNonRt
TripleBuffer< RtStatus > bufferRtStatusToNonRt
Definition: AdmittanceController.h:86
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::ArmData::rtStatus
RtStatus rtStatus
Definition: AdmittanceController.h:83
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::limbRT
void limbRT(ArmPtr &arm, const double deltaT)
Definition: AdmittanceController.cpp:283
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::limbPublish
void limbPublish(ArmPtr &arm, const DebugObserverInterfacePrx &debugObs)
Definition: AdmittanceController.cpp:507
armarx::control::common::control_law
This file is part of ArmarX.
Definition: aron_conversions.cpp:68
ControlTarget1DoFActuator.h
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::additionalTaskUpdateStatus
bool additionalTaskUpdateStatus()
Definition: AdmittanceController.cpp:178
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:633
TaskspaceAdmittanceController.h
armarx::control::NJointTaskspaceAdmittanceControllerInterface
Definition: ControllerInterface.ice:111
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:45
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::ArmData::rtFirstRun
std::atomic_bool rtFirstRun
flags
Definition: AdmittanceController.h:89
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::handleRTNotSafeInNonRT
void handleRTNotSafeInNonRT()
Definition: AdmittanceController.cpp:210
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::limbReInit
void limbReInit(ArmPtr &arm)
Definition: AdmittanceController.cpp:564
NJointController.h
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:72
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::getConfig
::armarx::aron::data::dto::DictPtr getConfig(const Ice::Current &iceCurrent=Ice::emptyCurrent) override
Definition: AdmittanceController.cpp:359
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:431
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:417
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::ArmData::sensorDevices
common::SensorDevicesForNJointTorqueController sensorDevices
devices
Definition: AdmittanceController.h:64
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::ArmData::nonRtRobot
VirtualRobot::RobotPtr nonRtRobot
robot
Definition: AdmittanceController.h:94
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:330
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::getClassName
std::string getClassName(const Ice::Current &=Ice::emptyCurrent) const override
Definition: AdmittanceController.cpp:128
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::validateConfigData
void validateConfigData(Config &config, ArmPtr &arm)
Definition: AdmittanceController.cpp:463
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:59
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::Config
law::TaskspaceAdmittanceController::Config Config
Definition: AdmittanceController.h:57
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::ArmData
Definition: AdmittanceController.h:61
armarx::control::NJointTaskspaceAdmittanceControllerInterface::calibrateFTSensor
void calibrateFTSensor()
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::ArmData::bufferConfigUserToNonRt
TripleBuffer< Config > bufferConfigUserToNonRt
Definition: AdmittanceController.h:77
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::onInitNJointController
void onInitNJointController() override
NJointControllerBase interface.
Definition: AdmittanceController.cpp:134
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::GenerateConfigFromVariants
static ConfigPtrT GenerateConfigFromVariants(const StringVariantBaseMap &values)
Definition: AdmittanceController.cpp:666
armarx::control::njoint_controller::task_space::NJointTaskspaceAdmittanceController::NJointTaskspaceAdmittanceController
NJointTaskspaceAdmittanceController(const RobotUnitPtr &robotUnit, const NJointControllerConfigPtr &config, const VirtualRobot::RobotPtr &)
Definition: AdmittanceController.cpp:85
VirtualRobot::RobotPtr
std::shared_ptr< class Robot > RobotPtr
Definition: Bus.h:18
armarx::TripleBuffer< Config >