CommonPlacesLearner.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::CommonPlacesLearner
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 #include <MemoryX/interface/components/CommonPlacesLearnerInterface.h>
28 #include <MemoryX/interface/components/LongtermMemoryInterface.h>
29 #include <MemoryX/interface/components/PriorKnowledgeInterface.h>
30 
33 
34 // memoryx helpers
36 
37 
38 namespace memoryx
39 {
40 
43  {
44  public:
47  {
48  defineOptionalProperty<std::string>("LTMSegment", "objects", "Name of segment in LTM to store learned CommonPlaces / to run queries on");
49  defineOptionalProperty<float>("AgingFactor", 0.8, "Discount factor to make older observations less significant");
50  defineOptionalProperty<float>("PruningThreshold", 0.0, "Maximum weight of Gauss component to be pruned");
51  defineOptionalProperty<std::string>("MergingDistanceType", "KL", "Distance type to be used for association/merging: Mahalanobis, ISD, KL");
52  defineOptionalProperty<float>("MergingThreshold", 0.0, "Maximum distance value for association (meaning depends upon measure used)");
53  defineOptionalProperty<std::string>("GMMReducerAlgorithm", "West", "A GMM reducing algorithm to be used for queries: West, Runnalls, Williams");
54  }
55  };
56 
58  virtual public CommonPlacesLearnerInterface,
59  virtual public armarx::Component
60  {
61  public:
62  // inherited from Component
63  std::string getDefaultName() const override
64  {
65  return "CommonPlacesLearner";
66  };
67  void onInitComponent() override;
68  void onConnectComponent() override;
69  void onExitComponent() override;
70 
71  // inherited from CommonPlacesLearnerInterface
72  void setLTMSegmentName(const ::std::string& segmentName, const ::Ice::Current& = Ice::emptyCurrent) override;
73  void setAgingFactor(float factor, const ::Ice::Current& = Ice::emptyCurrent) override;
74  void setMergingThreshold(float threshold, const ::Ice::Current& = Ice::emptyCurrent) override;
75 
76  void learnFromSnapshot(const ::std::string& snapshotName, const ::Ice::Current& = Ice::emptyCurrent) override;
77  void learnFromObject(const ObjectInstanceBasePtr& newObject, const ::Ice::Current& = Ice::emptyCurrent) override;
78  void learnFromObjectMCA(const ::std::string& objectName, const MultivariateNormalDistributionBasePtr& posDist,
79  const ::Ice::Current& = Ice::emptyCurrent) override;
80 
81  // inherited from CommonPlacesQueryInterface
82  GaussianMixtureDistributionBasePtr getPositionFull(const ::std::string& objectName, const ::Ice::Current& = Ice::emptyCurrent) override;
83  GaussianMixtureDistributionBasePtr getPositionReducedByComponentCount(const ::std::string& objectName, Ice::Int compCount, const ::Ice::Current& = Ice::emptyCurrent) override;
84  GaussianMixtureDistributionBasePtr getPositionReducedByMaxDeviation(const ::std::string& objectName, Ice::Float maxDeviation, DeviationType devType, const ::Ice::Current& = Ice::emptyCurrent) override;
85  NormalDistributionBasePtr getPositionAsGaussian(const ::std::string& objectName, const ::Ice::Current& = Ice::emptyCurrent) override;
86 
87  Cluster3DList getPositionClustersByComponentCount(const ::std::string& objectName, Ice::Int compCount, const ::Ice::Current& = Ice::emptyCurrent) override;
88  Cluster3DList getPositionClustersByMaxDeviation(const ::std::string& objectName, Ice::Float maxDeviation, DeviationType devType, const ::Ice::Current& = Ice::emptyCurrent) override;
89 
90  private:
91  PriorKnowledgeInterfacePrx priorKnowledgePrx;
92 
93  LongtermMemoryInterfacePrx longtermMemoryPrx;
94  PersistentObjectInstanceSegmentBasePrx ltmInstancesSegmentPrx;
95 
98  GMMReducerPtr gmmReducer;
99 
100  //
101  DeviationMeasure convertDeviationType(DeviationType devType);
102  Cluster3DList gmmToClusterList(const GaussianMixtureDistributionBasePtr& gmm);
103  void getChildClasses(std::string className, NameList& result);
104 
105  public:
106  /**
107  * @see PropertyUser::createPropertyDefinitions()
108  */
110  {
113  getConfigIdentifier()));
114  }
115 
116  };
117 
119 }
120 
armarx::VariantType::Float
const VariantTypeId Float
Definition: Variant.h:918
GaussianMixtureAssociationMethod.h
memoryx::CommonPlacesLearner
Definition: CommonPlacesLearner.h:57
armarx::PropertyDefinitionContainer::prefix
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
Definition: PropertyDefinitionContainer.h:333
memoryx
VirtualRobot headers.
Definition: CommonPlacesTester.cpp:48
memoryx::DeviationMeasure
DeviationMeasure
Definition: GMMReducer.h:37
memoryx::CommonPlacesLearnerPropertyDefinitions
Definition: CommonPlacesLearner.h:41
memoryx::CommonPlacesLearner::createPropertyDefinitions
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
Definition: CommonPlacesLearner.h:109
IceInternal::Handle< GaussianMixtureAssociationMethod >
ARMARXCOMPONENT_IMPORT_EXPORT
#define ARMARXCOMPONENT_IMPORT_EXPORT
Definition: ImportExportComponent.h:38
memoryx::CommonPlacesLearner::getDefaultName
std::string getDefaultName() const override
Retrieve default name of component.
Definition: CommonPlacesLearner.h:63
GaussianMixturePositionFusion.h
GMMReducer.h
Component.h
armarx::Component
Baseclass for all ArmarX ManagedIceObjects requiring properties.
Definition: Component.h:95
armarx::ComponentPropertyDefinitions
Default component property definition container.
Definition: Component.h:70
IceUtil::Handle< class PropertyDefinitionContainer >
armarx::ComponentPropertyDefinitions::ComponentPropertyDefinitions
ComponentPropertyDefinitions(std::string prefix, bool hasObjectNameParameter=true)
Definition: Component.cpp:37
armarx::VariantType::Int
const VariantTypeId Int
Definition: Variant.h:916
memoryx::CommonPlacesLearnerPropertyDefinitions::CommonPlacesLearnerPropertyDefinitions
CommonPlacesLearnerPropertyDefinitions(std::string prefix)
Definition: CommonPlacesLearner.h:45
armarx::PropertyDefinitionsPtr
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
Definition: forward_declarations.h:34
memoryx::GMMReducerPtr
std::shared_ptr< GMMReducer > GMMReducerPtr
Definition: GMMReducer.h:90
ImportExportComponent.h