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 
43 
45 {
46 
47  class MemoryGrapher :
48  virtual public armarx::Component,
49  virtual public MemoryGrapherInterface
50  // , virtual public armarx::DebugObserverComponentPluginUser
51  ,
53  // , virtual public armarx::ArVizComponentPluginUser
54  ,
55  virtual public armarx::armem::ClientPluginUser
56  {
57  public:
58  /// @see armarx::ManagedIceObject::getDefaultName()
59  std::string getDefaultName() const override;
60 
61 
62  protected:
63  /// @see PropertyUser::createPropertyDefinitions()
65 
66  /// @see armarx::ManagedIceObject::onInitComponent()
67  void onInitComponent() override;
68 
69  /// @see armarx::ManagedIceObject::onConnectComponent()
70  void onConnectComponent() override;
71 
72  /// @see armarx::ManagedIceObject::onDisconnectComponent()
73  void onDisconnectComponent() override;
74 
75  /// @see armarx::ManagedIceObject::onExitComponent()
76  void onExitComponent() override;
77 
78  /// This function should be called once in onConnect() or when you
79  /// need to re-create the Remote GUI tab.
80  void createRemoteGuiTab();
81 
82  /// After calling `RemoteGui_startRunningTask`, this function is
83  /// called periodically in a separate thread. If you update variables,
84  /// make sure to synchronize access to them.
85  void RemoteGui_update() override;
86 
87 
88  private:
89  // Private methods go here.
90 
91  void run(const std::string& memoryID);
92 
93  // Forward declare `Properties` if you used it before its defined.
94  // struct Properties;
95 
96  /* (Requires the armarx::ArVizComponentPluginUser.)
97  /// Draw some boxes in ArViz.
98  void drawBoxes(const Properties& p, viz::Client& arviz);
99  */
100 
101 
102  private:
103  static const std::string defaultName;
104 
105  // Private member variables go here.
106 
107  std::thread worker;
108  std::atomic<bool> finished = false;
109 
110  /// Properties shown in the Scenario GUI.
111  struct Properties
112  {
113  };
114  Properties properties;
115  /* Use a mutex if you access variables from different threads
116  * (e.g. ice functions and RemoteGui_update()).
117  std::mutex propertiesMutex;
118  */
119 
120 
121  /// Tab shown in the Remote GUI.
122  struct RemoteGuiTab : armarx::RemoteGui::Client::Tab
123  {
126  };
127  RemoteGuiTab tab;
128 
129  armarx::semantic::GraphStorageTopicPrx graphTopic;
130 
131  /* (Requires the armarx::ArVizComponentPluginUser.)
132  * When used from different threads, an ArViz client needs to be synchronized.
133  /// Protects the arviz client inherited from the ArViz plugin.
134  std::mutex arvizMutex;
135  */
136  };
137 
138 } // namespace VisionX::components::MemoryGrapher
armarx::visionx::components::MemoryGrapher::MemoryGrapher::onDisconnectComponent
void onDisconnectComponent() override
Definition: MemoryGrapher.cpp:122
armarx::visionx::components::MemoryGrapher::MemoryGrapher::onConnectComponent
void onConnectComponent() override
Definition: MemoryGrapher.cpp:81
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:29
armarx::visionx::components::MemoryGrapher::MemoryGrapher::onInitComponent
void onInitComponent() override
Definition: MemoryGrapher.cpp:70
armarx::visionx::components::MemoryGrapher::MemoryGrapher::createPropertyDefinitions
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
Definition: MemoryGrapher.cpp:45
armarx::visionx::components::MemoryGrapher::MemoryGrapher
Definition: MemoryGrapher.h:47
armarx::RemoteGui::Client::LineEdit
Definition: Widgets.h:40
armarx::visionx::components::MemoryGrapher::MemoryGrapher::onExitComponent
void onExitComponent() override
Definition: MemoryGrapher.cpp:132
TaskUtil.h
armarx::LightweightRemoteGuiComponentPluginUser
Definition: LightweightRemoteGuiComponentPlugin.h:73
Component.h
armarx::Component
Baseclass for all ArmarX ManagedIceObjects requiring properties.
Definition: Component.h:95
IceUtil::Handle< class PropertyDefinitionContainer >
armarx::visionx::components::MemoryGrapher::MemoryGrapher::getDefaultName
std::string getDefaultName() const override
Definition: MemoryGrapher.cpp:142
armarx::armem::index::memoryID
const MemoryID memoryID
Definition: memory_ids.cpp:29
PluginUser.h
armarx::visionx::components::MemoryGrapher
Definition: MemoryGrapher.cpp:38
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:168
armarx::visionx::components::MemoryGrapher::MemoryGrapherInterface
Definition: MemoryGrapherInterface.ice:30
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:149