MemoryGrapher.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 VisionX::ArmarXObjects::MemoryGrapher
17  * @author [Author Name] ( [Author Email] )
18  * @date 2021
19  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20  * GNU General Public License
21  */
22 
23 
24 #pragma once
25 
26 #include <condition_variable>
27 #include <mutex>
28 
31 
32 // #include <ArmarXCore/libraries/ArmarXCoreComponentPlugins/DebugObserverComponentPlugin.h>
33 
35 
36 // #include <RobotAPI/libraries/RobotAPIComponentPlugins/ArVizComponentPlugin.h>
37 
39 
40 #include <VisionX/components/MemoryGrapher/MemoryGrapherInterface.h>
41 #include <VisionX/interface/libraries/SemanticObjectRelations/GraphStorage.h>
42 
44 {
45 
46  class MemoryGrapher :
47  virtual public armarx::Component,
48  virtual public MemoryGrapherInterface
49  // , virtual public armarx::DebugObserverComponentPluginUser
50  ,
52  // , virtual public armarx::ArVizComponentPluginUser
53  ,
54  virtual public armarx::armem::ClientPluginUser
55  {
56  public:
57  /// @see armarx::ManagedIceObject::getDefaultName()
58  std::string getDefaultName() const override;
59 
60 
61  protected:
62  /// @see PropertyUser::createPropertyDefinitions()
64 
65  /// @see armarx::ManagedIceObject::onInitComponent()
66  void onInitComponent() override;
67 
68  /// @see armarx::ManagedIceObject::onConnectComponent()
69  void onConnectComponent() override;
70 
71  /// @see armarx::ManagedIceObject::onDisconnectComponent()
72  void onDisconnectComponent() override;
73 
74  /// @see armarx::ManagedIceObject::onExitComponent()
75  void onExitComponent() override;
76 
77  /// This function should be called once in onConnect() or when you
78  /// need to re-create the Remote GUI tab.
79  void createRemoteGuiTab();
80 
81  /// After calling `RemoteGui_startRunningTask`, this function is
82  /// called periodically in a separate thread. If you update variables,
83  /// make sure to synchronize access to them.
84  void RemoteGui_update() override;
85 
86 
87  private:
88  // Private methods go here.
89 
90  void run(const std::string& memoryID);
91 
92  // Forward declare `Properties` if you used it before its defined.
93  // struct Properties;
94 
95  /* (Requires the armarx::ArVizComponentPluginUser.)
96  /// Draw some boxes in ArViz.
97  void drawBoxes(const Properties& p, viz::Client& arviz);
98  */
99 
100 
101  private:
102  static const std::string defaultName;
103 
104  // Private member variables go here.
105 
106  std::thread worker;
107  std::atomic<bool> finished = false;
108 
109  /// Properties shown in the Scenario GUI.
110  struct Properties
111  {
112  };
113 
114  Properties properties;
115 
116  /* Use a mutex if you access variables from different threads
117  * (e.g. ice functions and RemoteGui_update()).
118  std::mutex propertiesMutex;
119  */
120 
121 
122  /// Tab shown in the Remote GUI.
123  struct RemoteGuiTab : armarx::RemoteGui::Client::Tab
124  {
127  };
128 
129  RemoteGuiTab tab;
130 
131  armarx::semantic::GraphStorageTopicPrx graphTopic;
132 
133  /* (Requires the armarx::ArVizComponentPluginUser.)
134  * When used from different threads, an ArViz client needs to be synchronized.
135  /// Protects the arviz client inherited from the ArViz plugin.
136  std::mutex arvizMutex;
137  */
138  };
139 
140 } // namespace armarx::visionx::components::MemoryGrapher
armarx::visionx::components::MemoryGrapher::MemoryGrapher::onDisconnectComponent
void onDisconnectComponent() override
Definition: MemoryGrapher.cpp:116
armarx::visionx::components::MemoryGrapher::MemoryGrapher::onConnectComponent
void onConnectComponent() override
Definition: MemoryGrapher.cpp:76
armarx::RemoteGui::Client::Tab
Definition: Tab.h:15
LightweightRemoteGuiComponentPlugin.h
armarx::armem::client::plugins::PluginUser
Adds the Memory Name System client component plugin.
Definition: PluginUser.h:27
armarx::visionx::components::MemoryGrapher::MemoryGrapher::onInitComponent
void onInitComponent() override
Definition: MemoryGrapher.cpp:66
armarx::visionx::components::MemoryGrapher::MemoryGrapher::createPropertyDefinitions
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
Definition: MemoryGrapher.cpp:42
armarx::visionx::components::MemoryGrapher::MemoryGrapher
Definition: MemoryGrapher.h:46
armarx::RemoteGui::Client::LineEdit
Definition: Widgets.h:40
armarx::visionx::components::MemoryGrapher::MemoryGrapher::onExitComponent
void onExitComponent() override
Definition: MemoryGrapher.cpp:125
TaskUtil.h
armarx::LightweightRemoteGuiComponentPluginUser
Definition: LightweightRemoteGuiComponentPlugin.h:72
Component.h
armarx::Component
Baseclass for all ArmarX ManagedIceObjects requiring properties.
Definition: Component.h:91
IceUtil::Handle< class PropertyDefinitionContainer >
armarx::visionx::components::MemoryGrapher::MemoryGrapher::getDefaultName
std::string getDefaultName() const override
Definition: MemoryGrapher.cpp:134
armarx::armem::index::memoryID
const MemoryID memoryID
Definition: memory_ids.cpp:28
PluginUser.h
armarx::visionx::components::MemoryGrapher
Definition: MemoryGrapher.cpp:36
armarx::RemoteGui::Client::Button
Definition: Widgets.h:120
armarx::visionx::components::MemoryGrapher::MemoryGrapher::RemoteGui_update
void RemoteGui_update() override
After calling RemoteGui_startRunningTask, this function is called periodically in a separate thread.
Definition: MemoryGrapher.cpp:158
armarx::visionx::components::MemoryGrapher::MemoryGrapherInterface
Definition: MemoryGrapherInterface.ice:36
armarx::visionx::components::MemoryGrapher::MemoryGrapher::createRemoteGuiTab
void createRemoteGuiTab()
This function should be called once in onConnect() or when you need to re-create the Remote GUI tab.
Definition: MemoryGrapher.cpp:140