Feature.hpp
Go to the documentation of this file.
1/*
2 * This file is part of ArmarX.
3 *
4 * Copyright (C) 2011-2016, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved.
5 *
6 * ArmarX is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * ArmarX is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 *
18 * @package
19 * @author
20 * @date
21 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22 * GNU General Public License
23 */
24#pragma once
25
26#include <iostream>
27#include <limits>
28#include <memory>
29#include <string>
30#include <utility>
31
32#include <Eigen/Core>
33
34#include <ArmarXCore/interface/observers/Serialization.h>
37
38#include <VisionX/interface/components/ObjectShapeClassification.h>
39
40using namespace visionx;
41using namespace armarx;
42
43const std::string FEATURE_FIELD_NAME = "features";
44
45class Feature : public FeatureBase
46{
47public:
48 using Points = std::vector<Eigen::Vector3f>;
49 using TaggedPoints = std::pair<std::string, Points>;
50 using FeaturePtr = std::shared_ptr<Feature>;
51
52 virtual std::string
54 {
55 return m_name;
56 }
57
58 virtual FeaturePtr calculate(const Points& points) = 0;
59
60 virtual FeaturePtr
61 calculate(const TaggedPoints& points)
62 {
63 return calculate(points.second);
64 }
65
66 virtual double compare(const Feature&) const = 0;
67
68 virtual void serialize(const ObjectSerializerBasePtr& serializer,
69 const Ice::Current&) const = 0;
70 virtual void deserialize(const ObjectSerializerBasePtr& serializer, const Ice::Current&) = 0;
71
72 //TODO: properly implement this functions
73 virtual VariantDataClassPtr
74 clone(const Ice::Current&) const
75 {
76 return VariantDataClassPtr();
77 }
78
79 virtual std::string
80 output(const Ice::Current&) const
81 {
82 return "Feature";
83 }
84
85 virtual VariantTypeId
86 getType(const Ice::Current&) const
87 {
88 return 0;
89 }
90
91 virtual bool
92 validate(const Ice::Current&)
93 {
94 return true;
95 }
96
97 virtual std::ostream& output(std::ostream& out) const = 0;
98 friend std::ostream& operator<<(std::ostream& os, const Feature& f);
99
100protected:
101 std::string m_name;
102};
103
104using FeaturePtr = std::shared_ptr<Feature>;
105
106std::ostream&
107operator<<(std::ostream& os, const Feature& f)
108{
109 return f.output(os);
110}
const std::string FEATURE_FIELD_NAME
Definition Feature.hpp:43
std::shared_ptr< Feature > FeaturePtr
Definition Feature.hpp:104
virtual FeaturePtr calculate(const Points &points)=0
virtual void serialize(const ObjectSerializerBasePtr &serializer, const Ice::Current &) const =0
virtual FeaturePtr calculate(const TaggedPoints &points)
Definition Feature.hpp:61
std::vector< Eigen::Vector3f > Points
Definition Feature.hpp:48
virtual std::string name()
Definition Feature.hpp:53
virtual double compare(const Feature &) const =0
virtual std::string output(const Ice::Current &) const
Definition Feature.hpp:80
virtual VariantTypeId getType(const Ice::Current &) const
Definition Feature.hpp:86
friend std::ostream & operator<<(std::ostream &os, const Feature &f)
Definition Feature.hpp:107
std::shared_ptr< Feature > FeaturePtr
Definition Feature.hpp:50
std::pair< std::string, Points > TaggedPoints
Definition Feature.hpp:49
std::string m_name
Definition Feature.hpp:101
virtual void deserialize(const ObjectSerializerBasePtr &serializer, const Ice::Current &)=0
virtual VariantDataClassPtr clone(const Ice::Current &) const
Definition Feature.hpp:74
virtual bool validate(const Ice::Current &)
Definition Feature.hpp:92
virtual std::ostream & output(std::ostream &out) const =0
This file offers overloads of toIce() and fromIce() functions for STL container types.
std::ostream & operator<<(std::ostream &os, const PythonApplicationManager::Paths &paths)
Ice::Int VariantTypeId
Definition Variant.h:43
ArmarX headers.