ExampleMemoryClient.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 RobotAPI::ArmarXObjects::ExampleClient
17 * @author Rainer Kartmann ( rainer dot kartmann at kit dot edu )
18 * @date 2020
19 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20 * GNU General Public License
21 */
22
23
24#pragma once
25
27#include <ArmarXCore/interface/observers/ObserverInterface.h>
29
31
32#include <RobotAPI/interface/armem/mns/MemoryNameSystemInterface.h>
38
39namespace armarx
40{
41
42 /**
43 * @defgroup Component-ExampleClient ExampleClient
44 * @ingroup RobotAPI-Components
45 *
46 * An example for an ArMem Memory Client.
47 *
48 * @class ExampleClient
49 * @ingroup Component-ExampleClient
50 * @brief Brief description of class ExampleClient.
51 *
52 * Connects to the example memory, and commits and queries example data.
53 */
55 virtual public armarx::Component,
58 {
59 public:
60 /// @see armarx::ManagedIceObject::getDefaultName()
61 std::string getDefaultName() const override;
62
63
64 // LightweightRemoteGuiComponentPluginUser interface
65 public:
66 void createRemoteGuiTab();
67 void RemoteGui_update() override;
68
69
70 protected:
72
73 void onInitComponent() override;
74 void onConnectComponent() override;
75 void onDisconnectComponent() override;
76 void onExitComponent() override;
77
78 void run();
79
80
81 private:
82 // Callback for updates on `example_entity`.
83 void processExampleEntityUpdate(const armem::MemoryID& id,
84 const std::vector<armem::MemoryID>& snapshotIDs);
85
86 // Examples
87 void waitForMemory();
88 armem::MemoryID addProviderSegment();
89
90 armem::MemoryID commitSingleSnapshot(const armem::MemoryID& exampleEntityID);
91 void commitMultipleSnapshots(const armem::MemoryID& exampleEntityID, int num = 3);
92
93 void queryLatestSnapshot(const armem::MemoryID& exampleEntityID);
94 void queryExactSnapshot(const armem::MemoryID& snapshotID);
95
96 void commitExampleData();
97 void queryExampleData();
98
99 void commitExamplesWithIDs();
100 void commitExamplesWithLinks();
101
102 void commitExampleImages();
103 void commitExamplesWithUntypedData();
104
105 void queryPredictionEngines();
106
107 void loadDataFromLTMExport();
108
109
110 private:
111 struct Properties
112 {
113 std::string usedMemoryName = "Example";
114 float commitFrequency = 10;
115 };
116
117 Properties p;
118
119 armem::client::Reader memoryReader;
120 armem::client::Writer memoryWriter;
121 armem::client::Loader memoryLoader;
122
123 armem::MemoryID exampleProviderID;
124 armem::MemoryID exampleEntityID;
125
126 armem::MemoryID exampleDataProviderID;
127 armem::MemoryID theAnswerSnapshotID;
128 armem::MemoryID linkedDataProviderID;
129 armem::MemoryID yetMoreDataSnapshotID;
130
131
132 armem::Time runStarted;
133 unsigned int imageCounter = 0;
134
136
138
139 struct RemoteGuiTab : RemoteGui::Client::Tab
140 {
141 std::atomic_bool rebuild = false;
142
143 std::optional<armem::wm::Memory> queryResult;
144 RemoteGui::Client::GroupBox queryResultGroup;
145 };
146
147 RemoteGuiTab tab;
148 };
149} // namespace armarx
Baseclass for all ArmarX ManagedIceObjects requiring properties.
Definition Component.h:94
void onInitComponent() override
Pure virtual hook for the subclass.
void onDisconnectComponent() override
Hook for subclass.
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
void onConnectComponent() override
Pure virtual hook for the subclass.
void onExitComponent() override
Hook for subclass.
std::string getDefaultName() const override
IceUtil::Handle< RunningTask< T > > pointer_type
Shared pointer type for convenience.
Load LTMs into WM.
Definition Loader.h:12
Reads data from a memory server.
Definition Reader.h:25
Helps a memory client sending data to a memory.
Definition Writer.h:23
armarx::core::time::DateTime Time
client::plugins::ListeningPluginUser ListeningClientPluginUser
This file offers overloads of toIce() and fromIce() functions for STL container types.
::IceInternal::ProxyHandle<::IceProxy::armarx::DebugObserverInterface > DebugObserverInterfacePrx
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.