CommonPlacesTester.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::CommonPlacesTester
17* @author Alexey Kozlov (kozlov at kit dot edu)
18* @date 2013
19* @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20* GNU General Public License
21*/
22
23#pragma once
24
27
28#include <MemoryX/interface/components/CommonPlacesLearnerInterface.h>
29#include <MemoryX/interface/components/LongtermMemoryInterface.h>
30#include <MemoryX/interface/components/WorkingMemoryInterface.h>
31
32namespace memoryx
33{
34
36 {
37 public:
40 {
42 "TestToRun",
43 "LearnFromSnapshot",
44 "Name of test that should be executed (LearnFromSnapshot, LoadLTM)");
46 "SnapshotToLoad", "", "Name of snapshot to be loaded into WM on startup");
48 "SnapshotsToLearnFrom",
49 "",
50 "Comma-separated list of snapshot to be processed by CommonPlacesLearner");
52 "LoadToWM",
53 false,
54 "Load LTM contents to WM after each learned snapshot (e.g. for visualization)");
55
57 "InitialDelay", 0, "Timeout before starting the learning process (in ms)");
59 "DelayBetweenSnapshots", 0, "Timeout after each learned snapshot (in ms)");
61 "ObjectToLoad", "", "Name of object to load from LTM ");
63 "LTMSegment",
64 "objects",
65 "Name of segment in LTM to store learned CommonPlaces / to run queries on");
67 "ClusterDeviationType",
68 "AABB",
69 "Type of deviation: AABB, OrientedBBox or EqualSphere");
71 "ClusterMaxDeviation",
72 100.,
73 "Max. intra-cluster deviation (meanings depends of ClusterDeviationType)");
74
75 defineOptionalProperty<int>("SampleSize", 10, "");
76 defineOptionalProperty<int>("IterationCount", 1, "");
77 }
78 };
79
81 {
82 public:
83 /**
84 * @see PropertyUser::createPropertyDefinitions()
85 */
92
93 // inherited from Component
94 std::string
95 getDefaultName() const override
96 {
97 return "CommonPlacesTester";
98 }
99
100 void onInitComponent() override;
101 void onConnectComponent() override;
102
103 private:
104 WorkingMemoryInterfacePrx memoryPrx;
105 LongtermMemoryInterfacePrx longtermMemoryPrx;
106 CommonPlacesLearnerInterfacePrx cpLearnerPrx;
107 std::string testToRun;
108 std::string objectToLoad;
109 std::string ltmSegmentName;
110
111 void testLearnFromSnapshot();
112 void testLearnFromSingleSnapshot();
113 void testLoadLTM();
114 void testClustering();
115
116 void testMerging();
117 void testClusteringBatch();
118 void testAging();
119 void testAging2();
120 void testGetClusterLocations();
121
122 void getRandomIds(std::vector<std::string>& allIds,
123 std::vector<std::string>& ids,
124 int sampleSize);
125
126 DeviationType getDeviationTypeFromString(const std::string& devTypeStr);
127
128 struct SimpleTimer
129 {
130 struct timeval tv1, tv2, dtv;
131 struct timezone tz;
132
133 void
134 time_start()
135 {
136 gettimeofday(&tv1, &tz);
137 }
138
139 long
140 time_stop()
141 {
142 gettimeofday(&tv2, &tz);
143 dtv.tv_sec = tv2.tv_sec - tv1.tv_sec;
144 dtv.tv_usec = tv2.tv_usec - tv1.tv_usec;
145
146 if (dtv.tv_usec < 0)
147 {
148 dtv.tv_sec--;
149 dtv.tv_usec += 1000000;
150 }
151
152 return dtv.tv_sec * 1000 + dtv.tv_usec / 1000;
153 }
154 };
155
156 SimpleTimer mstimer;
157 };
158} // namespace memoryx
#define ARMARXCOMPONENT_IMPORT_EXPORT
Default component property definition container.
Definition Component.h:70
ComponentPropertyDefinitions(std::string prefix, bool hasObjectNameParameter=true)
Definition Component.cpp:46
Baseclass for all ArmarX ManagedIceObjects requiring properties.
Definition Component.h:94
std::string getConfigIdentifier()
Retrieve config identifier for this component as set in constructor.
Definition Component.cpp:90
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
PropertyDefinition< PropertyType > & defineOptionalProperty(const std::string &name, PropertyType defaultValue, const std::string &description="", PropertyDefinitionBase::PropertyConstness constness=PropertyDefinitionBase::eConstant)
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
std::string getDefaultName() const override
Retrieve default name of component.
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
VirtualRobot headers.