RobotUnitComponentPlugin.h
Go to the documentation of this file.
1 #pragma once
2 
4 
5 #include <RobotAPI/interface/units/RobotUnit/RobotUnitInterface.h>
7 
8 namespace armarx::plugins
9 {
10 
12  {
13  public:
14  using ComponentPlugin::ComponentPlugin;
15 
16  void preOnInitComponent() override;
17 
18  void preOnConnectComponent() override;
19  void postOnDisconnectComponent() override;
20 
21  void postCreatePropertyDefinitions(PropertyDefinitionsPtr& properties) override;
22 
24 
25  void setRobotUnitName(const std::string& name);
26  const std::string& getRobotUnitName() const;
27  bool hasRobotUnitName() const;
28 
29  void setRobotUnitAsOptionalDependency(bool isOptional = true);
30 
31  /**
32  * @brief Waits until the robot unit is running.
33  *
34  * Although the robot unit proxy might be initialized (\see getRobotUnit()), the robot unit might
35  * not be fully initialized.
36  *
37  * @param termCond Termination condition.
38  * If it evaluates to true, waitUntilRobotUnitIsRunning returns without waiting
39  * for the robot unit to become available.
40  */
41  void waitUntilRobotUnitIsRunning(const std::function<bool()>& termCond = []
42  { return false; });
43 
44  bool robotUnitIsRunning() const;
45 
46  //controllers
47  template <class PrxT>
48  PrxT
49  createNJointController(const std::string& className,
50  const std::string& instanceName,
51  const NJointControllerConfigPtr& config,
52  bool doManageController = true)
53  {
54  return PrxT::checkedCast(
55  createNJointController(className, instanceName, config, doManageController));
56  }
57 
58  template <class PrxT>
59  void
61  const std::string& className,
62  const std::string& instanceName,
63  const NJointControllerConfigPtr& config,
64  bool doManageController = true)
65  {
66  prx = PrxT::checkedCast(
67  createNJointController(className, instanceName, config, doManageController));
68  }
69 
70  NJointControllerInterfacePrx createNJointController(const std::string& className,
71  const std::string& instanceName,
72  const NJointControllerConfigPtr& config,
73  bool doManageController = true);
74  void manageController(const NJointControllerInterfacePrx& ctrl);
75  void manageController(const std::string& ctrl);
76 
77  //datastreaming
78 
80  startDataStreaming(const RobotUnitDataStreaming::Config& cfg);
81 
82  private:
83  static constexpr const char* PROPERTY_NAME = "RobotUnitName";
84  RobotUnitInterfacePrx _robotUnit;
85  std::string _robotUnitName;
86  bool _isRobotUnitOptionalDependency = false;
87  std::set<std::string> _ctrls;
88  };
89 } // namespace armarx::plugins
90 
92 
93 namespace armarx
94 {
95  /**
96  * @brief Provides a ready-to-use RobotUnit.
97  */
99  {
100  public:
102 
104 
105  void
106  setRobotUnitAsOptionalDependency(bool isOptional = true)
107  {
108  plugin->setRobotUnitAsOptionalDependency(isOptional);
109  }
110 
111  /**
112  * @brief Waits until the robot unit is running.
113  *
114  * Although the robot unit proxy might be initialized (\see getRobotUnit()), the robot unit might
115  * not be fully initialized.
116  *
117  * @param termCond Termination condition. If it evaluates to true, waitUntilRobotUnitIsRunning returns without waiting
118  * for the robot unit to become available.
119  */
120  void waitUntilRobotUnitIsRunning(const std::function<bool()>& termCond = []
121  { return false; }) const;
122 
123  plugins::RobotUnitComponentPlugin& getRobotUnitComponentPlugin();
124 
125  private:
127  };
128 
129 } // namespace armarx
130 
131 namespace armarx::plugins
132 {
133  // Legacy typedef.
135 } // namespace armarx::plugins
armarx::RobotUnitComponentPluginUser
Provides a ready-to-use RobotUnit.
Definition: RobotUnitComponentPlugin.h:98
armarx::plugins::RobotUnitComponentPlugin::createNJointController
PrxT createNJointController(const std::string &className, const std::string &instanceName, const NJointControllerConfigPtr &config, bool doManageController=true)
Definition: RobotUnitComponentPlugin.h:49
armarx::plugins::RobotUnitComponentPlugin::setRobotUnitName
void setRobotUnitName(const std::string &name)
Definition: RobotUnitComponentPlugin.cpp:118
armarx::plugins::RobotUnitComponentPlugin::postOnDisconnectComponent
void postOnDisconnectComponent() override
Definition: RobotUnitComponentPlugin.cpp:18
armarx::RobotUnitDataStreamingReceiverPtr
std::shared_ptr< class RobotUnitDataStreamingReceiver > RobotUnitDataStreamingReceiverPtr
Definition: RobotUnitReader.h:30
armarx::plugins::RobotUnitComponentPlugin::getRobotUnitName
const std::string & getRobotUnitName() const
Definition: RobotUnitComponentPlugin.cpp:125
armarx::plugins::RobotUnitComponentPlugin::robotUnitIsRunning
bool robotUnitIsRunning() const
Definition: RobotUnitComponentPlugin.cpp:164
armarx::plugins::RobotUnitComponentPlugin::manageController
void manageController(const NJointControllerInterfacePrx &ctrl)
armarx::plugins::RobotUnitComponentPlugin::createNJointController
void createNJointController(PrxT &prx, const std::string &className, const std::string &instanceName, const NJointControllerConfigPtr &config, bool doManageController=true)
Definition: RobotUnitComponentPlugin.h:60
RobotUnitDataStreamingReceiver.h
armarx::plugins::RobotUnitComponentPlugin::hasRobotUnitName
bool hasRobotUnitName() const
Definition: RobotUnitComponentPlugin.cpp:131
ManagedIceObject.h
armarx::plugins
This file is part of ArmarX.
Definition: DebugObserverComponentPlugin.cpp:28
armarx::ComponentPlugin
Definition: ComponentPlugin.h:38
armarx::plugins::RobotUnitComponentPluginUser
armarx::RobotUnitComponentPluginUser RobotUnitComponentPluginUser
Definition: RobotUnitComponentPlugin.h:134
armarx::RobotUnitComponentPluginUser::RobotUnitComponentPluginUser
RobotUnitComponentPluginUser()
Definition: RobotUnitComponentPlugin.cpp:179
armarx::plugins::RobotUnitComponentPlugin
Definition: RobotUnitComponentPlugin.h:11
armarx::RobotUnitComponentPluginUser::setRobotUnitAsOptionalDependency
void setRobotUnitAsOptionalDependency(bool isOptional=true)
Definition: RobotUnitComponentPlugin.h:106
armarx::plugins::RobotUnitComponentPlugin::startDataStreaming
RobotUnitDataStreamingReceiverPtr startDataStreaming(const RobotUnitDataStreaming::Config &cfg)
Definition: RobotUnitComponentPlugin.cpp:11
armarx::RobotUnitComponentPluginUser::waitUntilRobotUnitIsRunning
void waitUntilRobotUnitIsRunning(const std::function< bool()> &termCond=[] { return false;}) const
Waits until the robot unit is running.
Definition: RobotUnitComponentPlugin.cpp:197
armarx::plugins::RobotUnitComponentPlugin::postCreatePropertyDefinitions
void postCreatePropertyDefinitions(PropertyDefinitionsPtr &properties) override
Definition: RobotUnitComponentPlugin.cpp:93
armarx::ManagedIceObject
The ManagedIceObject is the base class for all ArmarX objects.
Definition: ManagedIceObject.h:163
armarx::plugins::RobotUnitComponentPlugin::preOnConnectComponent
void preOnConnectComponent() override
Definition: RobotUnitComponentPlugin.cpp:84
IceUtil::Handle< class PropertyDefinitionContainer >
armarx::plugins::RobotUnitComponentPlugin::preOnInitComponent
void preOnInitComponent() override
Definition: RobotUnitComponentPlugin.cpp:70
armarx::plugins::RobotUnitComponentPlugin::setRobotUnitAsOptionalDependency
void setRobotUnitAsOptionalDependency(bool isOptional=true)
Definition: RobotUnitComponentPlugin.cpp:137
IceInternal::ProxyHandle<::IceProxy::armarx::RobotUnitInterface >
armarx::RobotUnitComponentPluginUser::getRobotUnitComponentPlugin
plugins::RobotUnitComponentPlugin & getRobotUnitComponentPlugin()
Definition: RobotUnitComponentPlugin.cpp:191
ComponentPlugin.h
armarx::RobotUnitComponentPluginUser::getRobotUnit
RobotUnitInterfacePrx getRobotUnit() const
Definition: RobotUnitComponentPlugin.cpp:185
armarx::plugins::RobotUnitComponentPlugin::waitUntilRobotUnitIsRunning
void waitUntilRobotUnitIsRunning(const std::function< bool()> &termCond=[] { return false;})
Waits until the robot unit is running.
Definition: RobotUnitComponentPlugin.cpp:143
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
armarx::plugins::RobotUnitComponentPlugin::getRobotUnit
RobotUnitInterfacePrx getRobotUnit() const
Definition: RobotUnitComponentPlugin.cpp:112