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 MemoryX::ArmarXObjects::GraphImportExport
17  * @author Rainer Kartmann ( rainer dot kartmann at kit dot edu )
18  * @date 2021
19  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20  * GNU General Public License
21  */
22 
23 #pragma once
24 
27 
29 
34 
36 
37 #include <MemoryX/interface/components/GraphNodePoseResolverInterface.h>
38 #include <MemoryX/interface/components/PriorKnowledgeInterface.h>
39 #include <MemoryX/interface/memorytypes/MemoryEntities.h>
40 #include <MemoryX/interface/memorytypes/MemorySegments.h>
41 
43 {
44 
45  /**
46  * @defgroup Component-GraphImportExport GraphImportExport
47  * @ingroup MemoryX-Components
48  * A description of the component GraphImportExport.
49  *
50  * @class GraphImportExport
51  * @ingroup Component-GraphImportExport
52  * @brief Brief description of class GraphImportExport.
53  *
54  * Detailed description of class GraphImportExport.
55  */
56  class Component :
57  virtual public armarx::Component,
60  virtual public armarx::ArVizComponentPluginUser,
61  virtual public armarx::armem::ClientPluginUser,
62  virtual public ObjectPoseClientPluginUser
63  {
64  public:
65  Component();
66 
67 
68  /// @see armarx::ManagedIceObject::getDefaultName()
69  std::string getDefaultName() const override;
70  static std::string GetDefaultName();
71 
72 
73  protected:
74  /// @see PropertyUser::createPropertyDefinitions()
76 
77  /// @see armarx::ManagedIceObject::onInitComponent()
78  void onInitComponent() override;
79 
80  /// @see armarx::ManagedIceObject::onConnectComponent()
81  void onConnectComponent() override;
82 
83  /// @see armarx::ManagedIceObject::onDisconnectComponent()
84  void onDisconnectComponent() override;
85 
86  /// @see armarx::ManagedIceObject::onExitComponent()
87  void onExitComponent() override;
88 
89 
90  /// This function should be called once in onConnect() or when you
91  /// need to re-create the Remote GUI tab.
92  void createRemoteGuiTab(const std::vector<std::string>& sceneNames);
93 
94  /// After calling `RemoteGui_startRunningTask`, this function is
95  /// called periodically in a separate thread. If you update variables,
96  /// make sure to synchronize access to them.
97  void RemoteGui_update() override;
98 
99 
100  private:
101  void refreshScenes();
102 
103  void locationsMemoryxToArmem(const std::string& sceneName);
104  void locationsArmemToMemoryx(const std::string& sceneName);
105  void graphMemoryxToArmem(const std::string& sceneName);
106  void graphArmemToMemoryx(const std::string& sceneName);
107 
108  void clearArMemProviderSegment(armem::client::Writer& writer,
109  const armem::MemoryID& providerSegmentID);
110 
111  armem::MemoryID getLocationProviderSegmentID();
112  armem::MemoryID getGraphProviderSegmentID();
113 
114  navigation::core::Graph toArmemGraph(const memoryx::GraphNodeBaseList& graphNodes);
115 
116 
117  private:
118  struct Proxies
119  {
120  memoryx::PriorKnowledgeInterfacePrx priorKnowledge;
121  memoryx::GraphNodePoseResolverInterfacePrx graphNodePoseResolver;
122  memoryx::GraphMemorySegmentBasePrx graphSegment;
123 
124  armem::client::Writer locationWriter;
125  armem::client::Writer graphWriter;
126  };
127 
128  Proxies proxies;
129 
130  /// Properties shown in the Scenario GUI.
131  struct Properties
132  {
133  armem::MemoryID locationCoreSegmentID;
134  armem::MemoryID graphCoreSegmentID;
135  };
136 
137  Properties properties;
138 
139  /// Tab shown in the Remote GUI.
140  struct RemoteGuiTab : armarx::RemoteGui::Client::Tab
141  {
143  armarx::RemoteGui::Client::Button sceneRefreshButton;
144 
145  armarx::RemoteGui::Client::LineEdit providerSegmentLine;
146 
147  armarx::RemoteGui::Client::Button locationsMemoryxToArmemButton;
148  armarx::RemoteGui::Client::Button locationsArmemToMemoryxButton;
149  armarx::RemoteGui::Client::Button locationsClearArMemButton;
150 
151  armarx::RemoteGui::Client::Button graphMemoryxToArmemButton;
152  armarx::RemoteGui::Client::Button graphArmemToMemoryxButton;
153  armarx::RemoteGui::Client::Button graphClearArMemButton;
154 
157  };
158 
159  RemoteGuiTab tab;
160 
161  objpose::ObjectPoseClient objClient;
162  };
163 } // namespace armarx::navigation::components::graph_import_export
armarx::navigation::components::graph_import_export
Definition: Component.cpp:46
ArVizComponentPlugin.h
armarx::navigation::components::graph_import_export::Component::onConnectComponent
void onConnectComponent() override
Definition: Component.cpp:77
Writer.h
armarx::navigation::components::graph_import_export::Component::getDefaultName
std::string getDefaultName() const override
Definition: Component.cpp:106
ObjectPoseClientPlugin.h
armarx::navigation::components::graph_import_export::Component::createPropertyDefinitions
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
Definition: Component.cpp:56
armarx::RemoteGui::Client::Tab
Definition: Tab.h:15
armarx::ObjectPoseClientPluginUser
Provides an objpose::ObjectPoseTopicPrx objectPoseTopic as member variable.
Definition: ObjectPoseClientPlugin.h:67
armarx::objpose::ObjectPoseClient
Provides access to the armarx::objpose::ObjectPoseStorageInterface (aka the object memory).
Definition: ObjectPoseClient.h:18
armarx::navigation::components::graph_import_export::Component::onInitComponent
void onInitComponent() override
Definition: Component.cpp:68
LightweightRemoteGuiComponentPlugin.h
armarx::armem::client::plugins::PluginUser
Adds the Memory Name System client component plugin.
Definition: PluginUser.h:29
armarx::navigation::components::graph_import_export::Component::RemoteGui_update
void RemoteGui_update() override
After calling RemoteGui_startRunningTask, this function is called periodically in a separate thread.
Definition: Component.cpp:172
armarx::ArVizComponentPluginUser
Provides a ready-to-use ArViz client arviz as member variable.
Definition: ArVizComponentPlugin.h:36
armarx::armem::MemoryID
A memory ID.
Definition: MemoryID.h:47
armarx::navigation::core::Graph
Definition: Graph.h:88
DebugObserverComponentPlugin.h
armarx::RemoteGui::Client::LineEdit
Definition: Widgets.h:40
armarx::armem::client::Writer
Helps a memory client sending data to a memory.
Definition: Writer.h:22
armarx::navigation::components::graph_import_export::Component::GetDefaultName
static std::string GetDefaultName()
Definition: Component.cpp:112
armarx::RemoteGui::Client::ComboBox
Definition: Widgets.h:50
armarx::LightweightRemoteGuiComponentPluginUser
Definition: LightweightRemoteGuiComponentPlugin.h:73
plugins.h
Component.h
armarx::Component
Baseclass for all ArmarX ManagedIceObjects requiring properties.
Definition: Component.h:95
IceUtil::Handle< class PropertyDefinitionContainer >
armarx::navigation::components::graph_import_export::Component::Component
Component()
Definition: Component.cpp:49
armarx::DebugObserverComponentPluginUser
Definition: DebugObserverComponentPlugin.h:82
armarx::RemoteGui::Client::CheckBox
Definition: Widgets.h:129
armarx::RemoteGui::Client::Button
Definition: Widgets.h:120
armarx::navigation::components::graph_import_export::Component
Definition: Component.h:56
armarx::navigation::components::graph_import_export::Component::onDisconnectComponent
void onDisconnectComponent() override
Definition: Component.cpp:96
armarx::navigation::components::graph_import_export::Component::createRemoteGuiTab
void createRemoteGuiTab(const std::vector< std::string > &sceneNames)
This function should be called once in onConnect() or when you need to re-create the Remote GUI tab.
Definition: Component.cpp:118
forward_declarations.h
armarx::navigation::components::graph_import_export::Component::onExitComponent
void onExitComponent() override
Definition: Component.cpp:101