RobotUnitComponentPlugin.h
Go to the documentation of this file.
1#pragma once
2
4
5#include <RobotAPI/interface/units/RobotUnit/RobotUnitInterface.h>
7
8namespace 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
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
93namespace 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
131namespace armarx::plugins
132{
133 // Legacy typedef.
135} // namespace armarx::plugins
ManagedIceObject(ManagedIceObject const &other)
Provides a ready-to-use RobotUnit.
plugins::RobotUnitComponentPlugin & getRobotUnitComponentPlugin()
void setRobotUnitAsOptionalDependency(bool isOptional=true)
void waitUntilRobotUnitIsRunning(const std::function< bool()> &termCond=[] { return false;}) const
Waits until the robot unit is running.
void createNJointController(PrxT &prx, const std::string &className, const std::string &instanceName, const NJointControllerConfigPtr &config, bool doManageController=true)
RobotUnitDataStreamingReceiverPtr startDataStreaming(const RobotUnitDataStreaming::Config &cfg)
void postCreatePropertyDefinitions(PropertyDefinitionsPtr &properties) override
NJointControllerInterfacePrx createNJointController(const std::string &className, const std::string &instanceName, const NJointControllerConfigPtr &config, bool doManageController=true)
void manageController(const NJointControllerInterfacePrx &ctrl)
void waitUntilRobotUnitIsRunning(const std::function< bool()> &termCond=[] { return false;})
Waits until the robot unit is running.
PrxT createNJointController(const std::string &className, const std::string &instanceName, const NJointControllerConfigPtr &config, bool doManageController=true)
This file is part of ArmarX.
armarx::RobotUnitComponentPluginUser RobotUnitComponentPluginUser
This file offers overloads of toIce() and fromIce() functions for STL container types.
::IceInternal::ProxyHandle<::IceProxy::armarx::RobotUnitInterface > RobotUnitInterfacePrx
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
std::shared_ptr< class RobotUnitDataStreamingReceiver > RobotUnitDataStreamingReceiverPtr