MixedImpedanceVelocityController.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 
30 
34 #include <armarx/control/njoint_controller/task_space/ControllerInterface.h>
35 
37 {
39 
40  /**
41  * @defgroup Library-NJointTaskspaceMixedImpedanceVelocityController NJointTaskspaceMixedImpedanceVelocityController
42  * @ingroup Library-RobotUnit-NJointControllers
43  * A description of the library NJointTaskspaceMixedImpedanceVelocityController.
44  *
45  * @class NJointTaskspaceMixedImpedanceVelocityController
46  * @ingroup Library-NJointTaskspaceMixedImpedanceVelocityController
47  * @brief Brief description of class NJointTaskspaceMixedImpedanceVelocityController.
48  *
49  * Detailed description of class NJointTaskspaceMixedImpedanceVelocityController.
50  */
52  virtual public NJointController,
54  {
55  public:
56  using ConfigPtrT = ConfigurableNJointControllerConfigPtr;
59  using RtStatus = law::TaskspaceMixedImpedanceVelocityController::RtStatus;
60 
61  struct ArmData
62  {
63  /// devices
65  std::vector<ControlTarget1DoFActuatorTorque*> targetsTorque;
66  std::vector<ControlTarget1DoFActuatorVelocity*> targetsVel;
67 
68  std::vector<size_t> torqueControlledIndex;
69  std::vector<size_t> velocityControlledIndex;
70 
71  /// names
72  std::string kinematicChainName;
73  std::vector<std::string> jointNames;
74 
75  /// controller (maths)
77 
78  /// set data containers and buffers
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,
105  const VirtualRobot::RobotPtr&);
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
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 calibrateFTSensor(const Ice::Current&) override;
126  void
127  enableSafeGuardForceTorque(const std::string& nodeSetName,
128  const bool forceGuard,
129  const bool torqueGuard,
130  const Ice::Current& iceCurrent = Ice::emptyCurrent) override;
131  bool isSafeForceTorque(const std::string& nodeSetName,
132  const Ice::Current& iceCurrent = Ice::emptyCurrent) override;
133 
134  public:
137  const std::map<std::string, ConstControlDevicePtr>&,
138  const std::map<std::string, ConstSensorDevicePtr>&);
139 
141 
142  protected:
143  virtual void additionalTask();
146  void validateConfigData(Config& config, ArmPtr& arm);
147  void onPublish(const SensorAndControl&,
149  const DebugObserverInterfacePrx&) override;
150 
151  void limbInit(const std::string nodeSetName,
152  ArmPtr& arm,
153  Config& cfg,
154  VirtualRobot::RobotPtr& nonRtRobotPtr);
155  void limbNonRT(ArmPtr& arm);
156  void limbRT(ArmPtr& arm, const double deltaT);
157  void limbRTUpdateStatus(ArmPtr& arm, const double deltaT);
158  void limbRTSetTarget(ArmPtr& arm,
159  const size_t nDoFTorque,
160  const size_t nDoFVelocity,
161  const Eigen::VectorXf& targetTorque,
162  const Eigen::VectorXf& targetVelocity);
163  void limbPublish(ArmPtr& arm, const DebugObserverInterfacePrx& debugObs);
164  void limbReInit(ArmPtr& arm);
165  void handleRTNotSafeInNonRT();
166 
167  protected:
168  std::map<std::string, ArmPtr> limb;
170  RobotUnitPtr robotUnit;
173  std::map<std::string, VirtualRobot::RobotNodeSetPtr> controllableNodeSets;
174 
175  protected:
176  /// NJointControllerBase interface
177  void onInitNJointController() override;
178  void rtPreActivateController() override;
179  void rtPostDeactivateController() override;
180  };
181 } // namespace armarx::control::njoint_controller::task_space
armarx::control::njoint_controller::task_space::NJointTaskspaceMixedImpedanceVelocityController::userConfig
ConfigDict userConfig
Definition: MixedImpedanceVelocityController.h:171
armarx::control::njoint_controller::task_space::NJointTaskspaceMixedImpedanceVelocityController::rtPreActivateController
void rtPreActivateController() override
This function is called before the controller is activated.
Definition: MixedImpedanceVelocityController.cpp:661
TaskspaceMixedImpedanceVelocityController.h
HandControlBase.h
armarx::control::njoint_controller::core::HandControlPtr
std::shared_ptr< HandControlBase > HandControlPtr
Definition: HandControlBase.h:121
armarx::control::njoint_controller::task_space::NJointTaskspaceMixedImpedanceVelocityController::getClassName
std::string getClassName(const Ice::Current &=Ice::emptyCurrent) const override
Definition: MixedImpedanceVelocityController.cpp:165
armarx::control::njoint_controller::task_space::NJointTaskspaceMixedImpedanceVelocityController::rtRun
void rtRun(const IceUtil::Time &sensorValuesTimestamp, const IceUtil::Time &timeSinceLastIteration) override
TODO make protected and use attorneys.
Definition: MixedImpedanceVelocityController.cpp:367
armarx::control::njoint_controller::task_space::NJointTaskspaceMixedImpedanceVelocityController::onPublish
void onPublish(const SensorAndControl &, const DebugDrawerInterfacePrx &, const DebugObserverInterfacePrx &) override
Definition: MixedImpedanceVelocityController.cpp:594
armarx::StringVariantBaseMap
std::map< std::string, VariantBasePtr > StringVariantBaseMap
Definition: ManagedIceObject.h:111
armarx::control::njoint_controller::task_space::NJointTaskspaceMixedImpedanceVelocityController::limb
std::map< std::string, ArmPtr > limb
Definition: MixedImpedanceVelocityController.h:168
RobotUnit.h
armarx::control::njoint_controller::task_space::NJointTaskspaceMixedImpedanceVelocityController::handleRTNotSafeInNonRT
void handleRTNotSafeInNonRT()
Definition: MixedImpedanceVelocityController.cpp:247
armarx::SynchronousNJointController
Definition: NJointControllerBase.h:1145
armarx::control::njoint_controller::task_space::NJointTaskspaceMixedImpedanceVelocityController::controllableNodeSets
std::map< std::string, VirtualRobot::RobotNodeSetPtr > controllableNodeSets
Definition: MixedImpedanceVelocityController.h:173
armarx::control::njoint_controller::task_space::NJointTaskspaceMixedImpedanceVelocityController::ArmData::rtConfig
Config rtConfig
Definition: MixedImpedanceVelocityController.h:80
armarx::control::njoint_controller::task_space::NJointTaskspaceMixedImpedanceVelocityController::updateTargetPose
bool updateTargetPose(const TargetPoseMap &targetPoseMap, const TargetNullspaceMap &targetNullspaceMap, const Ice::Current &=Ice::emptyCurrent) override
Definition: MixedImpedanceVelocityController.cpp:489
armarx::control::njoint_controller::task_space
Definition: AdmittanceController.cpp:37
armarx::control::njoint_controller::task_space::NJointTaskspaceMixedImpedanceVelocityController::additionalTask
virtual void additionalTask()
Definition: MixedImpedanceVelocityController.cpp:204
armarx::control::common::SensorDevicesForNJointTorqueController
Definition: device.h:12
armarx::control::njoint_controller::task_space::NJointTaskspaceMixedImpedanceVelocityController::ArmData::nonRtConfig
Config nonRtConfig
set data containers and buffers
Definition: MixedImpedanceVelocityController.h:79
ProsthesisInterface.values
values
Definition: ProsthesisInterface.py:190
armarx::control::common::control_law::TaskspaceMixedImpedanceVelocityController::ConfigDict
common::control_law::arondto::TaskspaceMixedImpedanceVelocityControllerConfigDict ConfigDict
Definition: TaskspaceMixedImpedanceVelocityController.h:47
armarx::control::njoint_controller::task_space::NJointTaskspaceMixedImpedanceVelocityController::ArmData::reInitPreActivate
std::atomic_bool reInitPreActivate
Definition: MixedImpedanceVelocityController.h:95
armarx::NJointControllerBase::ConfigPtrT
NJointControllerConfigPtr ConfigPtrT
Definition: NJointControllerBase.h:586
armarx::control::njoint_controller::task_space::NJointTaskspaceMixedImpedanceVelocityController::ArmData::targetsVel
std::vector< ControlTarget1DoFActuatorVelocity * > targetsVel
Definition: MixedImpedanceVelocityController.h:66
armarx::control::njoint_controller::task_space::NJointTaskspaceMixedImpedanceVelocityController::ArmData::kinematicChainName
std::string kinematicChainName
names
Definition: MixedImpedanceVelocityController.h:72
armarx::control::njoint_controller::task_space::NJointTaskspaceMixedImpedanceVelocityController::ArmData::bufferRtStatusToUser
TripleBuffer< RtStatus > bufferRtStatusToUser
Definition: MixedImpedanceVelocityController.h:89
device.h
armarx::control::njoint_controller::task_space::NJointTaskspaceMixedImpedanceVelocityController::limbInit
void limbInit(const std::string nodeSetName, ArmPtr &arm, Config &cfg, VirtualRobot::RobotPtr &nonRtRobotPtr)
Definition: MixedImpedanceVelocityController.cpp:44
armarx::control::NJointTaskspaceMixedImpedanceVelocityControllerInterface
Definition: ControllerInterface.ice:79
armarx::control::njoint_controller::task_space::NJointTaskspaceMixedImpedanceVelocityController::validateConfigData
void validateConfigData(Config &config, ArmPtr &arm)
Definition: MixedImpedanceVelocityController.cpp:521
armarx::control::njoint_controller::task_space::NJointTaskspaceMixedImpedanceVelocityController::ArmData::bufferRtStatusToOnPublish
TripleBuffer< RtStatus > bufferRtStatusToOnPublish
Definition: MixedImpedanceVelocityController.h:88
armarx::control::njoint_controller::task_space::NJointTaskspaceMixedImpedanceVelocityController::getConfig
::armarx::aron::data::dto::DictPtr getConfig(const Ice::Current &iceCurrent=Ice::emptyCurrent) override
Definition: MixedImpedanceVelocityController.cpp:415
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::common::control_law::TaskspaceMixedImpedanceVelocityController
Definition: TaskspaceMixedImpedanceVelocityController.h:40
armarx::control::njoint_controller::task_space::NJointTaskspaceMixedImpedanceVelocityController::ArmData::torqueControlledIndex
std::vector< size_t > torqueControlledIndex
Definition: MixedImpedanceVelocityController.h:68
armarx::control::njoint_controller::task_space::NJointTaskspaceMixedImpedanceVelocityController::ArmData::bufferConfigUserToNonRt
TripleBuffer< Config > bufferConfigUserToNonRt
Definition: MixedImpedanceVelocityController.h:81
armarx::control::njoint_controller::task_space::NJointTaskspaceMixedImpedanceVelocityController
Brief description of class NJointTaskspaceMixedImpedanceVelocityController.
Definition: MixedImpedanceVelocityController.h:51
armarx::control::njoint_controller::task_space::NJointTaskspaceMixedImpedanceVelocityController::limbNonRT
void limbNonRT(ArmPtr &arm)
Definition: MixedImpedanceVelocityController.cpp:197
armarx::control::common::control_law::TaskspaceMixedImpedanceVelocityController::Config
common::control_law::arondto::TaskspaceMixedImpedanceVelocityControllerConfig Config
Definition: TaskspaceMixedImpedanceVelocityController.h:45
armarx::control::njoint_controller::task_space::NJointTaskspaceMixedImpedanceVelocityController::enableSafeGuardForceTorque
void enableSafeGuardForceTorque(const std::string &nodeSetName, const bool forceGuard, const bool torqueGuard, const Ice::Current &iceCurrent=Ice::emptyCurrent) override
Definition: MixedImpedanceVelocityController.cpp:430
armarx::control::njoint_controller::task_space::NJointTaskspaceMixedImpedanceVelocityController::ArmData::nonRtRobot
VirtualRobot::RobotPtr nonRtRobot
robot
Definition: MixedImpedanceVelocityController.h:98
armarx::control::njoint_controller::task_space::NJointTaskspaceMixedImpedanceVelocityController::ArmData::bufferConfigRtToOnPublish
TripleBuffer< Config > bufferConfigRtToOnPublish
Definition: MixedImpedanceVelocityController.h:83
armarx::control::njoint_controller::task_space::NJointTaskspaceMixedImpedanceVelocityController::NJointTaskspaceMixedImpedanceVelocityController
NJointTaskspaceMixedImpedanceVelocityController(const RobotUnitPtr &robotUnit, const NJointControllerConfigPtr &config, const VirtualRobot::RobotPtr &)
Definition: MixedImpedanceVelocityController.cpp:123
armarx::control::njoint_controller::task_space::NJointTaskspaceMixedImpedanceVelocityController::ArmData::bufferConfigNonRtToRt
TripleBuffer< Config > bufferConfigNonRtToRt
Definition: MixedImpedanceVelocityController.h:82
armarx::control::njoint_controller::task_space::NJointTaskspaceMixedImpedanceVelocityController::limbRTUpdateStatus
void limbRTUpdateStatus(ArmPtr &arm, const double deltaT)
-----------------------------— Real time cotnrol --------------------------------------—
Definition: MixedImpedanceVelocityController.cpp:268
armarx::control::njoint_controller::task_space::NJointTaskspaceMixedImpedanceVelocityController::isSafeForceTorque
bool isSafeForceTorque(const std::string &nodeSetName, const Ice::Current &iceCurrent=Ice::emptyCurrent) override
-----------------------------— Other interaces ----------------------------------------—
Definition: MixedImpedanceVelocityController.cpp:457
armarx::control::njoint_controller::task_space::NJointTaskspaceMixedImpedanceVelocityController::limbReInit
void limbReInit(ArmPtr &arm)
Definition: MixedImpedanceVelocityController.cpp:617
armarx::control::njoint_controller::task_space::NJointTaskspaceMixedImpedanceVelocityController::getTCPVel
Ice::FloatSeq getTCPVel(const std::string &rns, const Ice::Current &iceCurrent=Ice::emptyCurrent) override
Definition: MixedImpedanceVelocityController.cpp:475
armarx::control::common::control_law
This file is part of ArmarX.
Definition: aron_conversions.cpp:68
ControlTarget1DoFActuator.h
armarx::control::njoint_controller::task_space::NJointTaskspaceMixedImpedanceVelocityController::additionalTaskUpdateStatus
bool additionalTaskUpdateStatus()
Definition: MixedImpedanceVelocityController.cpp:215
armarx::control::njoint_controller::task_space::NJointTaskspaceMixedImpedanceVelocityController::ArmData::sensorDevices
common::SensorDevicesForNJointTorqueController sensorDevices
devices
Definition: MixedImpedanceVelocityController.h:64
armarx::control::njoint_controller::task_space::NJointTaskspaceMixedImpedanceVelocityController::nonRtRobot
VirtualRobot::RobotPtr nonRtRobot
Definition: MixedImpedanceVelocityController.h:169
armarx::control::njoint_controller::task_space::NJointTaskspaceMixedImpedanceVelocityController::ArmData::velocityControlledIndex
std::vector< size_t > velocityControlledIndex
Definition: MixedImpedanceVelocityController.h:69
armarx::armem::Time
armarx::core::time::DateTime Time
Definition: forward_declarations.h:13
armarx::control::njoint_controller::task_space::NJointTaskspaceMixedImpedanceVelocityController::limbRT
void limbRT(ArmPtr &arm, const double deltaT)
Definition: MixedImpedanceVelocityController.cpp:333
armarx::control::njoint_controller::task_space::NJointTaskspaceMixedImpedanceVelocityController::ArmData::controller
law::TaskspaceMixedImpedanceVelocityController controller
controller (maths)
Definition: MixedImpedanceVelocityController.h:76
armarx::control::NJointTaskspaceMixedImpedanceVelocityControllerInterface::calibrateFTSensor
void calibrateFTSensor()
ft sensor
armarx::control::njoint_controller::task_space::NJointTaskspaceMixedImpedanceVelocityController::onInitNJointController
void onInitNJointController() override
NJointControllerBase interface.
Definition: MixedImpedanceVelocityController.cpp:171
NJointController.h
armarx::aron::data::DictPtr
std::shared_ptr< Dict > DictPtr
Definition: Dict.h:41
armarx::control::njoint_controller::task_space::NJointTaskspaceMixedImpedanceVelocityController::rtPostDeactivateController
void rtPostDeactivateController() override
This function is called after the controller is deactivated.
Definition: MixedImpedanceVelocityController.cpp:676
armarx::control::njoint_controller::task_space::NJointTaskspaceMixedImpedanceVelocityController::limbRTSetTarget
void limbRTSetTarget(ArmPtr &arm, const size_t nDoFTorque, const size_t nDoFVelocity, const Eigen::VectorXf &targetTorque, const Eigen::VectorXf &targetVelocity)
Definition: MixedImpedanceVelocityController.cpp:290
armarx::control::njoint_controller::task_space::NJointTaskspaceMixedImpedanceVelocityController::updateConfig
void updateConfig(const ::armarx::aron::data::dto::DictPtr &dto, const Ice::Current &iceCurrent=Ice::emptyCurrent) override
NJointController interface.
Definition: MixedImpedanceVelocityController.cpp:385
armarx::control::njoint_controller::task_space::NJointTaskspaceMixedImpedanceVelocityController::ArmData::targetsTorque
std::vector< ControlTarget1DoFActuatorTorque * > targetsTorque
Definition: MixedImpedanceVelocityController.h:65
armarx::control::njoint_controller::task_space::NJointTaskspaceMixedImpedanceVelocityController::GenerateConfigDescription
static WidgetDescription::WidgetPtr GenerateConfigDescription(const VirtualRobot::RobotPtr &, const std::map< std::string, ConstControlDevicePtr > &, const std::map< std::string, ConstSensorDevicePtr > &)
--------------------------------— GUI Widget ------------------------------------------—
Definition: MixedImpedanceVelocityController.cpp:686
armarx::control::njoint_controller::task_space::NJointTaskspaceMixedImpedanceVelocityController::ArmData::rtFirstRun
std::atomic_bool rtFirstRun
flags
Definition: MixedImpedanceVelocityController.h:93
IceInternal::ProxyHandle<::IceProxy::armarx::DebugDrawerInterface >
armarx::control::njoint_controller::task_space::NJointTaskspaceMixedImpedanceVelocityController::hands
core::HandControlPtr hands
Definition: MixedImpedanceVelocityController.h:172
armarx::control::TargetPoseMap
dictionary< string, FloatSeqSeq > TargetPoseMap
Definition: ControllerInterface.ice:39
armarx::control::njoint_controller::task_space::NJointTaskspaceMixedImpedanceVelocityController::ArmData::jointNames
std::vector< std::string > jointNames
Definition: MixedImpedanceVelocityController.h:73
armarx::control::njoint_controller::task_space::NJointTaskspaceMixedImpedanceVelocityController::GenerateConfigFromVariants
static ConfigPtrT GenerateConfigFromVariants(const StringVariantBaseMap &values)
Definition: MixedImpedanceVelocityController.cpp:719
armarx::control::njoint_controller::task_space::NJointTaskspaceMixedImpedanceVelocityController::Config
law::TaskspaceMixedImpedanceVelocityController::Config Config
Definition: MixedImpedanceVelocityController.h:57
armarx::control::njoint_controller::task_space::NJointTaskspaceMixedImpedanceVelocityController::ArmData::bufferRtStatusToNonRt
TripleBuffer< RtStatus > bufferRtStatusToNonRt
Definition: MixedImpedanceVelocityController.h:90
armarx::control::njoint_controller::task_space::NJointTaskspaceMixedImpedanceVelocityController::RtStatus
law::TaskspaceMixedImpedanceVelocityController::RtStatus RtStatus
Definition: MixedImpedanceVelocityController.h:59
armarx::control::njoint_controller::task_space::NJointTaskspaceMixedImpedanceVelocityController::ArmData::rtStatusInNonRT
RtStatus rtStatusInNonRT
Definition: MixedImpedanceVelocityController.h:86
armarx::control::njoint_controller::task_space::NJointTaskspaceMixedImpedanceVelocityController::ArmData
Definition: MixedImpedanceVelocityController.h:61
armarx::control::njoint_controller::task_space::NJointTaskspaceMixedImpedanceVelocityController::limbPublish
void limbPublish(ArmPtr &arm, const DebugObserverInterfacePrx &debugObs)
Definition: MixedImpedanceVelocityController.cpp:570
armarx::control::njoint_controller::task_space::NJointTaskspaceMixedImpedanceVelocityController::ArmPtr
std::unique_ptr< ArmData > ArmPtr
Definition: MixedImpedanceVelocityController.h:101
armarx::control::njoint_controller::task_space::NJointTaskspaceMixedImpedanceVelocityController::additionalTaskSetTarget
void additionalTaskSetTarget()
Definition: MixedImpedanceVelocityController.cpp:234
armarx::control::njoint_controller::task_space::NJointTaskspaceMixedImpedanceVelocityController::ArmData::bufferConfigRtToUser
TripleBuffer< Config > bufferConfigRtToUser
Definition: MixedImpedanceVelocityController.h:84
armarx::control::njoint_controller::task_space::NJointTaskspaceMixedImpedanceVelocityController::robotUnit
RobotUnitPtr robotUnit
Definition: MixedImpedanceVelocityController.h:170
armarx::control::njoint_controller::task_space::NJointTaskspaceMixedImpedanceVelocityController::ConfigDict
law::TaskspaceMixedImpedanceVelocityController::ConfigDict ConfigDict
Definition: MixedImpedanceVelocityController.h:58
VirtualRobot::RobotPtr
std::shared_ptr< class Robot > RobotPtr
Definition: Bus.h:18
armarx::control::njoint_controller::task_space::NJointTaskspaceMixedImpedanceVelocityController::ArmData::rtReady
std::atomic_bool rtReady
Definition: MixedImpedanceVelocityController.h:94
armarx::TripleBuffer< Config >
armarx::control::njoint_controller::task_space::NJointTaskspaceMixedImpedanceVelocityController::ArmData::rtStatus
RtStatus rtStatus
Definition: MixedImpedanceVelocityController.h:87