Component.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 navigation::ArmarXObjects::dynamic_scene_provider
17  * @author Fabian Reister ( fabian dot reister at kit dot edu )
18  * @date 2022
19  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20  * GNU General Public License
21  */
22 
23 
24 #pragma once
25 
26 
27 // #include <mutex>
28 
29 #include <VirtualRobot/VirtualRobot.h>
30 
34 
38 
40 
42 
43 // #include <ArmarXGui/libraries/ArmarXGuiComponentPlugins/LightweightRemoteGuiComponentPlugin.h>
44 
48 
50 #include <armarx/navigation/components/dynamic_scene_provider/ComponentInterface.h>
55 
57 {
58 
59  class Component :
60  virtual public armarx::Component,
63  // , virtual public armarx::LightweightRemoteGuiComponentPluginUser
64  virtual public armarx::ArVizComponentPluginUser,
66  virtual public ObjectPoseClientPluginUser
67  {
68  public:
69  Component();
70 
71  /// @see armarx::ManagedIceObject::getDefaultName()
72  std::string getDefaultName() const override;
73 
74  /// Get the component's default name.
75  static std::string GetDefaultName();
76 
77 
78  protected:
79  /// @see PropertyUser::createPropertyDefinitions()
81 
82  /// @see armarx::ManagedIceObject::onInitComponent()
83  void onInitComponent() override;
84 
85  /// @see armarx::ManagedIceObject::onConnectComponent()
86  void onConnectComponent() override;
87 
88  /// @see armarx::ManagedIceObject::onDisconnectComponent()
89  void onDisconnectComponent() override;
90 
91  /// @see armarx::ManagedIceObject::onExitComponent()
92  void onExitComponent() override;
93 
94 
95  /* (Requires armarx::LightweightRemoteGuiComponentPluginUser.)
96  /// This function should be called once in onConnect() or when you
97  /// need to re-create the Remote GUI tab.
98  void createRemoteGuiTab();
99 
100  /// After calling `RemoteGui_startRunningTask`, this function is
101  /// called periodically in a separate thread. If you update variables,
102  /// make sure to synchronize access to them.
103  void RemoteGui_update() override;
104  */
105 
106 
107  private:
108  // Private methods go here.
109 
110  // Forward declare `Properties` if you used it before its defined.
111  // struct Properties;
112 
113  /* (Requires the armarx::ArVizComponentPluginUser.)
114  /// Draw some boxes in ArViz.
115  void drawBoxes(const Properties& p, viz::Client& arviz);
116  */
117 
118  void runPeriodically();
119 
120  VirtualRobot::RobotPtr robot = nullptr;
121 
122 
123  private:
124  static const std::string defaultName;
125 
126  // Private member variables go here.
127 
128 
129  /// Properties shown in the Scenario GUI.
130  struct Properties
131  {
132  int taskPeriodMs = 100;
133 
134  struct
135  {
136  bool enabled = true;
137  std::string providerName = "LaserScannerFeatureExtraction";
138  std::string name = "global"; // the merged entity of all sensors
139  } laserScannerFeatures;
140 
141  struct
142  {
143  std::string name;
144  } robot;
145 
146  struct
147  {
148  std::string providerName = "CartographerMappingAndLocalization";
149  std::string name = ""; // all
150 
151  float freespaceThreshold = 0.45F;
152  float occupiedThreshold = 0.55;
153  } occupancyGrid;
154 
155  struct
156  {
157  bool enabled = true;
158  std::string providerName = "AzureKinectPointCloudProvider";
159  } humanPoses;
160  };
161 
162  Properties properties;
163  /* Use a mutex if you access variables from different threads
164  * (e.g. ice functions and RemoteGui_update()).
165  std::mutex propertiesMutex;
166  */
167 
168 
169  /* (Requires the armarx::LightweightRemoteGuiComponentPluginUser.)
170  /// Tab shown in the Remote GUI.
171  struct RemoteGuiTab : armarx::RemoteGui::Client::Tab
172  {
173  armarx::RemoteGui::Client::LineEdit boxLayerName;
174  armarx::RemoteGui::Client::IntSpinBox numBoxes;
175 
176  armarx::RemoteGui::Client::Button drawBoxes;
177  };
178  RemoteGuiTab tab;
179  */
180 
181 
182  /* (Requires the armarx::ArVizComponentPluginUser.)
183  * When used from different threads, an ArViz client needs to be synchronized.
184  /// Protects the arviz client inherited from the ArViz plugin.
185  std::mutex arvizMutex;
186  */
187 
188  std::optional<ArVizDrawer> arvizDrawer;
189 
190 
192 
193  template <typename T>
195 
196  ReaderWriterPlugin<armem::human::client::Reader>* humanPoseReaderPlugin = nullptr;
197 
199  laserScannerFeaturesReaderPlugin = nullptr;
200 
202  nullptr;
203 
204  ReaderWriterPlugin<memory::client::costmap::Reader>* costmapReaderPlugin = nullptr;
205 
207  occupancyGridReaderPlugin = nullptr;
208 
209  ReaderWriterPlugin<memory::client::human::Writer>* humanWriterPlugin = nullptr;
211  laserScannerFeaturesWriterPlugin = nullptr;
212 
213 
214  human::HumanTracker humanTracker;
215  };
216 
217 } // namespace armarx::navigation::components::dynamic_scene_provider
ArVizComponentPlugin.h
armarx::navigation::components::dynamic_scene_provider::Component::getDefaultName
std::string getDefaultName() const override
Definition: Component.cpp:180
ObjectPoseClientPlugin.h
armarx::armem::client::plugins::ReaderWriterPlugin
A component plugin offering client-side access to a reader or writer and manages the lifecycle,...
Definition: ReaderWriterPlugin.h:44
Reader.h
armarx::navigation::components::dynamic_scene_provider::Component
Definition: Component.h:59
armarx::navigation::components::dynamic_scene_provider::Component::onExitComponent
void onExitComponent() override
Definition: Component.cpp:175
ReaderWriterPlugin.h
armarx::ObjectPoseClientPluginUser
Provides an objpose::ObjectPoseTopicPrx objectPoseTopic as member variable.
Definition: ObjectPoseClientPlugin.h:67
HumanTracker.h
Reader.h
armarx::navigation::components::dynamic_scene_provider::Component::Component
Component()
Definition: Component.cpp:49
armarx::armem::client::plugins::PluginUser
Adds the Memory Name System client component plugin.
Definition: PluginUser.h:29
Reader.h
armarx::ArVizComponentPluginUser
Provides a ready-to-use ArViz client arviz as member variable.
Definition: ArVizComponentPlugin.h:36
armarx::navigation::components::dynamic_scene_provider::Component::onInitComponent
void onInitComponent() override
Definition: Component.cpp:108
enabled
std::atomic< bool > * enabled
Definition: RemoteGuiWidgetController.cpp:75
DebugObserverComponentPlugin.h
armarx::navigation::components::dynamic_scene_provider::ComponentInterface
Definition: ComponentInterface.ice:30
VirtualRobotReader.h
TaskUtil.h
armarx::navigation::components::dynamic_scene_provider
Definition: ArVizDrawer.cpp:16
armarx::navigation::components::dynamic_scene_provider::Component::GetDefaultName
static std::string GetDefaultName()
Get the component's default name.
Definition: Component.cpp:186
armarx::navigation::components::dynamic_scene_provider::Component::onDisconnectComponent
void onDisconnectComponent() override
Definition: Component.cpp:169
Component.h
armarx::Component
Baseclass for all ArmarX ManagedIceObjects requiring properties.
Definition: Component.h:95
HumanPoseReader.h
Writer.h
IceUtil::Handle< class PropertyDefinitionContainer >
Writer.h
armarx::DebugObserverComponentPluginUser
Definition: DebugObserverComponentPlugin.h:82
PluginUser.h
armarx::navigation::components::dynamic_scene_provider::Component::createPropertyDefinitions
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
Definition: Component.cpp:61
armarx::navigation::human::HumanTracker
The HumanTracker class can be used to track and filter multiple humans.
Definition: HumanTracker.h:47
ArVizDrawer.h
armarx::navigation::components::dynamic_scene_provider::Component::onConnectComponent
void onConnectComponent() override
Definition: Component.cpp:118
VirtualRobot::RobotPtr
std::shared_ptr< class Robot > RobotPtr
Definition: Bus.h:18