VelocityController.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 
28 
32 #include <armarx/control/njoint_controller/task_space/ControllerInterface.h>
33 
35 {
37 
38  /**
39  * @defgroup Library-NJointTaskspaceVelocityController NJointTaskspaceVelocityController
40  * @ingroup Library-RobotUnit-NJointControllers
41  * A description of the library NJointTaskspaceVelocityController.
42  *
43  * @class NJointTaskspaceVelocityController
44  * @ingroup Library-NJointTaskspaceVelocityController
45  * @brief Brief description of class NJointTaskspaceVelocityController.
46  *
47  * Detailed description of class NJointTaskspaceVelocityController.
48  */
50  virtual public NJointController,
52  {
53  public:
54  using ConfigPtrT = ConfigurableNJointControllerConfigPtr;
57  using RtStatus = law::TaskspaceVelocityController::RtStatus;
58 
59  struct ArmData
60  {
61  /// devices
63  std::vector<ControlTarget1DoFActuatorVelocity*> targetsVel;
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 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& targetVelocity);
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;
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::njoint_controller::task_space::NJointTaskspaceVelocityController::isSafeForceTorque
bool isSafeForceTorque(const std::string &nodeSetName, const Ice::Current &iceCurrent=Ice::emptyCurrent) override
-----------------------------— Other interaces ----------------------------------------—
Definition: VelocityController.cpp:406
HandControlBase.h
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::updateConfig
void updateConfig(const ::armarx::aron::data::dto::DictPtr &dto, const Ice::Current &iceCurrent=Ice::emptyCurrent) override
NJointController interface.
Definition: VelocityController.cpp:334
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::ConfigDict
law::TaskspaceVelocityController::ConfigDict ConfigDict
Definition: VelocityController.h:56
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::handleRTNotSafeInNonRT
void handleRTNotSafeInNonRT()
Definition: VelocityController.cpp:215
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::updateTargetPose
bool updateTargetPose(const TargetPoseMap &targetPoseMap, const TargetNullspaceMap &targetNullspaceMap, const Ice::Current &=Ice::emptyCurrent) override
Definition: VelocityController.cpp:437
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::ArmData::bufferRtStatusToOnPublish
TripleBuffer< RtStatus > bufferRtStatusToOnPublish
Definition: VelocityController.h:85
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::limbReInit
void limbReInit(ArmPtr &arm)
Definition: VelocityController.cpp:560
armarx::control::njoint_controller::core::HandControlPtr
std::shared_ptr< HandControlBase > HandControlPtr
Definition: HandControlBase.h:127
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::limbRTUpdateStatus
void limbRTUpdateStatus(ArmPtr &arm, const double deltaT)
-----------------------------— Real time cotnrol --------------------------------------—
Definition: VelocityController.cpp:237
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::ArmData::bufferConfigNonRtToRt
TripleBuffer< Config > bufferConfigNonRtToRt
Definition: VelocityController.h:79
armarx::StringVariantBaseMap
std::map< std::string, VariantBasePtr > StringVariantBaseMap
Definition: ManagedIceObject.h:110
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::onInitNJointController
void onInitNJointController() override
NJointControllerBase interface.
Definition: VelocityController.cpp:139
NJointControllerBase.h
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::limbNonRT
void limbNonRT(ArmPtr &arm)
Definition: VelocityController.cpp:165
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::ArmData::bufferConfigUserToNonRt
TripleBuffer< Config > bufferConfigUserToNonRt
Definition: VelocityController.h:78
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::ArmData::sensorDevices
common::SensorDevicesForNJointTorqueController sensorDevices
devices
Definition: VelocityController.h:62
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::ArmData::rtStatus
RtStatus rtStatus
Definition: VelocityController.h:84
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::additionalTaskUpdateStatus
bool additionalTaskUpdateStatus()
Definition: VelocityController.cpp:183
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::ArmData::bufferRtStatusToNonRt
TripleBuffer< RtStatus > bufferRtStatusToNonRt
Definition: VelocityController.h:87
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::rtPostDeactivateController
void rtPostDeactivateController() override
This function is called after the controller is deactivated.
Definition: VelocityController.cpp:619
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::limbRTSetTarget
void limbRTSetTarget(ArmPtr &arm, const Eigen::VectorXf &targetVelocity)
Definition: VelocityController.cpp:259
armarx::SynchronousNJointController
Definition: NJointControllerBase.h:1146
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::ArmData::reInitPreActivate
std::atomic_bool reInitPreActivate
Definition: VelocityController.h:92
armarx::control::njoint_controller::task_space
Definition: AdmittanceController.cpp:43
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::additionalTaskSetTarget
void additionalTaskSetTarget()
Definition: VelocityController.cpp:202
armarx::control::common::SensorDevicesForNJointTorqueController
Definition: device.h:12
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::enableSafeGuardForceTorque
void enableSafeGuardForceTorque(const std::string &nodeSetName, const bool forceGuard, const bool torqueGuard, const Ice::Current &iceCurrent=Ice::emptyCurrent) override
Definition: VelocityController.cpp:380
ProsthesisInterface.values
values
Definition: ProsthesisInterface.py:190
armarx::NJointControllerBase::ConfigPtrT
NJointControllerConfigPtr ConfigPtrT
Definition: NJointControllerBase.h:587
armarx::control::common::control_law::TaskspaceVelocityController
Definition: TaskspaceVelocityController.h:37
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::ArmData::rtReady
std::atomic_bool rtReady
Definition: VelocityController.h:91
device.h
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::NJointTaskspaceVelocityController
NJointTaskspaceVelocityController(const RobotUnitPtr &robotUnit, const NJointControllerConfigPtr &config, const VirtualRobot::RobotPtr &)
Definition: VelocityController.cpp:90
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::ArmData::rtFirstRun
std::atomic_bool rtFirstRun
flags
Definition: VelocityController.h:90
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::robotUnit
RobotUnitPtr robotUnit
Definition: VelocityController.h:163
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::rtPreActivateController
void rtPreActivateController() override
This function is called before the controller is activated.
Definition: VelocityController.cpp:604
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::ArmPtr
std::unique_ptr< ArmData > ArmPtr
Definition: VelocityController.h:98
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::limbInit
void limbInit(const std::string nodeSetName, ArmPtr &arm, Config &cfg, VirtualRobot::RobotPtr &nonRtRobotPtr)
Definition: VelocityController.cpp:49
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::ArmData::jointNames
std::vector< std::string > jointNames
Definition: VelocityController.h:67
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::limbRT
void limbRT(ArmPtr &arm, const double deltaT)
Definition: VelocityController.cpp:287
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::GenerateConfigDescription
static WidgetDescription::WidgetPtr GenerateConfigDescription(const VirtualRobot::RobotPtr &, const std::map< std::string, ConstControlDevicePtr > &, const std::map< std::string, ConstSensorDevicePtr > &)
--------------------------------— GUI Widget ------------------------------------------—
Definition: VelocityController.cpp:629
IceInternal::Handle
Definition: forward_declarations.h:8
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::ArmData::nonRTAccumulateTime
double nonRTAccumulateTime
set data containers and buffers
Definition: VelocityController.h:73
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::NJointTaskspaceVelocityController::ArmData::nonRtConfig
Config nonRtConfig
Definition: VelocityController.h:76
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::userConfig
ConfigDict userConfig
Definition: VelocityController.h:164
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::ArmData::kinematicChainName
std::string kinematicChainName
names
Definition: VelocityController.h:66
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::rtRun
void rtRun(const IceUtil::Time &sensorValuesTimestamp, const IceUtil::Time &timeSinceLastIteration) override
TODO make protected and use attorneys.
Definition: VelocityController.cpp:317
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::ArmData
Definition: VelocityController.h:59
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController
Brief description of class NJointTaskspaceVelocityController.
Definition: VelocityController.h:49
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::onPublish
void onPublish(const SensorAndControl &, const DebugDrawerInterfacePrx &, const DebugObserverInterfacePrx &) override
Definition: VelocityController.cpp:538
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::ArmData::targetsVel
std::vector< ControlTarget1DoFActuatorVelocity * > targetsVel
Definition: VelocityController.h:63
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::ArmData::nonRTDeltaT
double nonRTDeltaT
Definition: VelocityController.h:74
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::nonRtRobot
VirtualRobot::RobotPtr nonRtRobot
Definition: VelocityController.h:162
armarx::control::common::control_law
This file is part of ArmarX.
Definition: aron_conversions.cpp:68
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::ArmData::rtConfig
Config rtConfig
Definition: VelocityController.h:77
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::limbPublish
void limbPublish(ArmPtr &arm, const DebugObserverInterfacePrx &debugObs)
Definition: VelocityController.cpp:513
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::ArmData::bufferConfigRtToOnPublish
TripleBuffer< Config > bufferConfigRtToOnPublish
Definition: VelocityController.h:80
armarx::armem::Time
armarx::core::time::DateTime Time
Definition: forward_declarations.h:13
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::GenerateConfigFromVariants
static ConfigPtrT GenerateConfigFromVariants(const StringVariantBaseMap &values)
Definition: VelocityController.cpp:662
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::getTCPVel
Ice::FloatSeq getTCPVel(const std::string &rns, const Ice::Current &iceCurrent=Ice::emptyCurrent) override
Definition: VelocityController.cpp:423
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::ArmData::bufferConfigRtToUser
TripleBuffer< Config > bufferConfigRtToUser
Definition: VelocityController.h:81
armarx::control::common::control_law::TaskspaceVelocityController::ConfigDict
common::control_law::arondto::TaskspaceVelocityControllerConfigDict ConfigDict
Definition: TaskspaceVelocityController.h:42
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::additionalTask
virtual void additionalTask()
Definition: VelocityController.cpp:172
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::getClassName
std::string getClassName(const Ice::Current &=Ice::emptyCurrent) const override
Definition: VelocityController.cpp:133
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::getConfig
::armarx::aron::data::dto::DictPtr getConfig(const Ice::Current &iceCurrent=Ice::emptyCurrent) override
Definition: VelocityController.cpp:365
armarx::aron::data::DictPtr
std::shared_ptr< Dict > DictPtr
Definition: Dict.h:41
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::ArmData::bufferRtStatusToUser
TripleBuffer< RtStatus > bufferRtStatusToUser
Definition: VelocityController.h:86
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::Config
law::TaskspaceVelocityController::Config Config
Definition: VelocityController.h:55
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::ArmData::rtStatusInNonRT
RtStatus rtStatusInNonRT
Definition: VelocityController.h:83
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::limb
std::map< std::string, ArmPtr > limb
Definition: VelocityController.h:161
armarx::control::NJointTaskspaceVelocityControllerInterface
Definition: ControllerInterface.ice:93
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::RtStatus
law::TaskspaceVelocityController::RtStatus RtStatus
Definition: VelocityController.h:57
IceUtil::Handle< class RobotUnit >
IceInternal::ProxyHandle<::IceProxy::armarx::DebugDrawerInterface >
armarx::control::TargetPoseMap
dictionary< string, FloatSeqSeq > TargetPoseMap
Definition: ControllerInterface.ice:39
armarx::control::NJointTaskspaceVelocityControllerInterface::calibrateFTSensor
void calibrateFTSensor()
ft sensor
TaskspaceVelocityController.h
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::hands
core::HandControlPtr hands
Definition: VelocityController.h:165
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::controllableNodeSets
std::map< std::string, VirtualRobot::RobotNodeSetPtr > controllableNodeSets
Definition: VelocityController.h:166
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::ArmData::controller
law::TaskspaceVelocityController controller
controller (maths)
Definition: VelocityController.h:70
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::validateConfigData
void validateConfigData(Config &config, ArmPtr &arm)
Definition: VelocityController.cpp:469
armarx::control::common::control_law::TaskspaceVelocityController::Config
common::control_law::arondto::TaskspaceVelocityControllerConfig Config
Definition: TaskspaceVelocityController.h:41
VirtualRobot::RobotPtr
std::shared_ptr< class Robot > RobotPtr
Definition: Bus.h:19
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::ArmData::nonRtRobot
VirtualRobot::RobotPtr nonRtRobot
robot
Definition: VelocityController.h:95
armarx::TripleBuffer< Config >