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