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/Robot.h>
26 
30 
34 #include <armarx/control/njoint_controller/task_space/ControllerInterface.h>
35 
37 {
39 
40  /**
41  * @defgroup Library-NJointTaskspaceVelocityController NJointTaskspaceVelocityController
42  * @ingroup Library-RobotUnit-NJointControllers
43  * A description of the library NJointTaskspaceVelocityController.
44  *
45  * @class NJointTaskspaceVelocityController
46  * @ingroup Library-NJointTaskspaceVelocityController
47  * @brief Brief description of class NJointTaskspaceVelocityController.
48  *
49  * Detailed description of class NJointTaskspaceVelocityController.
50  */
52  virtual public NJointController,
54  {
55  public:
56  using ConfigPtrT = ConfigurableNJointControllerConfigPtr;
59  using RtStatus = law::TaskspaceVelocityController::RtStatus;
60 
61  struct ArmData
62  {
63  /// devices
65  std::vector<ControlTarget1DoFActuatorVelocity*> targetsVel;
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 
99  NJointTaskspaceVelocityController(const RobotUnitPtr& robotUnit,
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 calibrateFTSensor(const Ice::Current&) override;
122  void
123  enableSafeGuardForceTorque(const std::string& nodeSetName,
124  const bool forceGuard,
125  const bool torqueGuard,
126  const Ice::Current& iceCurrent = Ice::emptyCurrent) override;
127  bool isSafeForceTorque(const std::string& nodeSetName,
128  const Ice::Current& iceCurrent = Ice::emptyCurrent) override;
129 
130  public:
133  const std::map<std::string, ConstControlDevicePtr>&,
134  const std::map<std::string, ConstSensorDevicePtr>&);
135 
137 
138  protected:
139  virtual void additionalTask();
142  void validateConfigData(Config& config, ArmPtr& arm);
143  void onPublish(const SensorAndControl&,
145  const DebugObserverInterfacePrx&) override;
146 
147  void limbInit(const std::string nodeSetName,
148  ArmPtr& arm,
149  Config& cfg,
150  VirtualRobot::RobotPtr& nonRtRobotPtr);
151  void limbNonRT(ArmPtr& arm);
152  void limbRT(ArmPtr& arm, const double deltaT);
153  void limbRTUpdateStatus(ArmPtr& arm, const double deltaT);
154  void limbRTSetTarget(ArmPtr& arm, const Eigen::VectorXf& targetVelocity);
155  void limbPublish(ArmPtr& arm, const DebugObserverInterfacePrx& debugObs);
156  void limbReInit(ArmPtr& arm);
157  void handleRTNotSafeInNonRT();
158 
159  protected:
160  std::map<std::string, ArmPtr> limb;
162  RobotUnitPtr robotUnit;
165  std::map<std::string, VirtualRobot::RobotNodeSetPtr> controllableNodeSets;
166 
167  protected:
168  /// NJointControllerBase interface
169  void onInitNJointController() override;
170  void rtPreActivateController() override;
171  void rtPostDeactivateController() override;
172  };
173 } // 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:401
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:329
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::ConfigDict
law::TaskspaceVelocityController::ConfigDict ConfigDict
Definition: VelocityController.h:58
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::handleRTNotSafeInNonRT
void handleRTNotSafeInNonRT()
Definition: VelocityController.cpp:210
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:433
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::ArmData::bufferRtStatusToOnPublish
TripleBuffer< RtStatus > bufferRtStatusToOnPublish
Definition: VelocityController.h:84
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::limbReInit
void limbReInit(ArmPtr &arm)
Definition: VelocityController.cpp:557
armarx::control::njoint_controller::core::HandControlPtr
std::shared_ptr< HandControlBase > HandControlPtr
Definition: HandControlBase.h:121
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::limbRTUpdateStatus
void limbRTUpdateStatus(ArmPtr &arm, const double deltaT)
-----------------------------— Real time cotnrol --------------------------------------—
Definition: VelocityController.cpp:231
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::ArmData::bufferConfigNonRtToRt
TripleBuffer< Config > bufferConfigNonRtToRt
Definition: VelocityController.h:78
armarx::StringVariantBaseMap
std::map< std::string, VariantBasePtr > StringVariantBaseMap
Definition: ManagedIceObject.h:111
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::onInitNJointController
void onInitNJointController() override
NJointControllerBase interface.
Definition: VelocityController.cpp:134
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::limbNonRT
void limbNonRT(ArmPtr &arm)
Definition: VelocityController.cpp:160
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::ArmData::bufferConfigUserToNonRt
TripleBuffer< Config > bufferConfigUserToNonRt
Definition: VelocityController.h:77
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::ArmData::sensorDevices
common::SensorDevicesForNJointTorqueController sensorDevices
devices
Definition: VelocityController.h:64
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::ArmData::rtStatus
RtStatus rtStatus
Definition: VelocityController.h:83
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::additionalTaskUpdateStatus
bool additionalTaskUpdateStatus()
Definition: VelocityController.cpp:178
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::ArmData::bufferRtStatusToNonRt
TripleBuffer< RtStatus > bufferRtStatusToNonRt
Definition: VelocityController.h:86
RobotUnit.h
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::rtPostDeactivateController
void rtPostDeactivateController() override
This function is called after the controller is deactivated.
Definition: VelocityController.cpp:616
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::limbRTSetTarget
void limbRTSetTarget(ArmPtr &arm, const Eigen::VectorXf &targetVelocity)
Definition: VelocityController.cpp:252
armarx::SynchronousNJointController
Definition: NJointControllerBase.h:1145
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::ArmData::reInitPreActivate
std::atomic_bool reInitPreActivate
Definition: VelocityController.h:91
armarx::control::njoint_controller::task_space
Definition: AdmittanceController.cpp:37
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::additionalTaskSetTarget
void additionalTaskSetTarget()
Definition: VelocityController.cpp:197
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:374
ProsthesisInterface.values
values
Definition: ProsthesisInterface.py:190
armarx::NJointControllerBase::ConfigPtrT
NJointControllerConfigPtr ConfigPtrT
Definition: NJointControllerBase.h:586
armarx::control::common::control_law::TaskspaceVelocityController
Definition: TaskspaceVelocityController.h:40
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::ArmData::rtReady
std::atomic_bool rtReady
Definition: VelocityController.h:90
device.h
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::NJointTaskspaceVelocityController
NJointTaskspaceVelocityController(const RobotUnitPtr &robotUnit, const NJointControllerConfigPtr &config, const VirtualRobot::RobotPtr &)
Definition: VelocityController.cpp:86
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::ArmData::rtFirstRun
std::atomic_bool rtFirstRun
flags
Definition: VelocityController.h:89
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::robotUnit
RobotUnitPtr robotUnit
Definition: VelocityController.h:162
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::rtPreActivateController
void rtPreActivateController() override
This function is called before the controller is activated.
Definition: VelocityController.cpp:601
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::ArmPtr
std::unique_ptr< ArmData > ArmPtr
Definition: VelocityController.h:97
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::limbInit
void limbInit(const std::string nodeSetName, ArmPtr &arm, Config &cfg, VirtualRobot::RobotPtr &nonRtRobotPtr)
Definition: VelocityController.cpp:44
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::ArmData::jointNames
std::vector< std::string > jointNames
Definition: VelocityController.h:69
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::limbRT
void limbRT(ArmPtr &arm, const double deltaT)
Definition: VelocityController.cpp:281
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:626
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::NJointTaskspaceVelocityController::ArmData::nonRtConfig
Config nonRtConfig
set data containers and buffers
Definition: VelocityController.h:75
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::userConfig
ConfigDict userConfig
Definition: VelocityController.h:163
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::ArmData::kinematicChainName
std::string kinematicChainName
names
Definition: VelocityController.h:68
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:311
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::ArmData
Definition: VelocityController.h:61
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController
Brief description of class NJointTaskspaceVelocityController.
Definition: VelocityController.h:51
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::onPublish
void onPublish(const SensorAndControl &, const DebugDrawerInterfacePrx &, const DebugObserverInterfacePrx &) override
Definition: VelocityController.cpp:534
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::ArmData::targetsVel
std::vector< ControlTarget1DoFActuatorVelocity * > targetsVel
Definition: VelocityController.h:65
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::nonRtRobot
VirtualRobot::RobotPtr nonRtRobot
Definition: VelocityController.h:161
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:76
ControlTarget1DoFActuator.h
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::limbPublish
void limbPublish(ArmPtr &arm, const DebugObserverInterfacePrx &debugObs)
Definition: VelocityController.cpp:510
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::ArmData::bufferConfigRtToOnPublish
TripleBuffer< Config > bufferConfigRtToOnPublish
Definition: VelocityController.h:79
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:659
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:419
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::ArmData::bufferConfigRtToUser
TripleBuffer< Config > bufferConfigRtToUser
Definition: VelocityController.h:80
armarx::control::common::control_law::TaskspaceVelocityController::ConfigDict
common::control_law::arondto::TaskspaceVelocityControllerConfigDict ConfigDict
Definition: TaskspaceVelocityController.h:47
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::additionalTask
virtual void additionalTask()
Definition: VelocityController.cpp:167
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::getClassName
std::string getClassName(const Ice::Current &=Ice::emptyCurrent) const override
Definition: VelocityController.cpp:128
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::getConfig
::armarx::aron::data::dto::DictPtr getConfig(const Ice::Current &iceCurrent=Ice::emptyCurrent) override
Definition: VelocityController.cpp:359
NJointController.h
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:85
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::Config
law::TaskspaceVelocityController::Config Config
Definition: VelocityController.h:57
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::ArmData::rtStatusInNonRT
RtStatus rtStatusInNonRT
Definition: VelocityController.h:82
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::limb
std::map< std::string, ArmPtr > limb
Definition: VelocityController.h:160
armarx::control::NJointTaskspaceVelocityControllerInterface
Definition: ControllerInterface.ice:92
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::RtStatus
law::TaskspaceVelocityController::RtStatus RtStatus
Definition: VelocityController.h:59
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:164
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::controllableNodeSets
std::map< std::string, VirtualRobot::RobotNodeSetPtr > controllableNodeSets
Definition: VelocityController.h:165
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::ArmData::controller
law::TaskspaceVelocityController controller
controller (maths)
Definition: VelocityController.h:72
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::validateConfigData
void validateConfigData(Config &config, ArmPtr &arm)
Definition: VelocityController.cpp:465
armarx::control::common::control_law::TaskspaceVelocityController::Config
common::control_law::arondto::TaskspaceVelocityControllerConfig Config
Definition: TaskspaceVelocityController.h:45
VirtualRobot::RobotPtr
std::shared_ptr< class Robot > RobotPtr
Definition: Bus.h:18
armarx::control::njoint_controller::task_space::NJointTaskspaceVelocityController::ArmData::nonRtRobot
VirtualRobot::RobotPtr nonRtRobot
robot
Definition: VelocityController.h:94
armarx::TripleBuffer< Config >