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