iCub-main
methods.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2014 iCub Facility - Istituto Italiano di Tecnologia
3  * Author: Ugo Pattacini
4  * email: ugo.pattacini@iit.it
5  * Permission is granted to copy, distribute, and/or modify this program
6  * under the terms of the GNU General Public License, version 2 or any
7  * later version published by the Free Software Foundation.
8  *
9  * A copy of the license can be found at
10  * http://www.robotcub.org/icub/license/gpl.txt
11  *
12  * This program is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
15  * Public License for more details
16 */
17 
18 #ifndef __DEPTH2KIN_METHODS_H__
19 #define __DEPTH2KIN_METHODS_H__
20 
21 #include <string>
22 #include <deque>
23 
24 #include <yarp/os/Property.h>
25 #include <yarp/sig/all.h>
26 
29 
30 
31 /************************************************************************/
33 {
34 protected:
36  std::deque<yarp::sig::Vector> in,out;
37 
39  {
40  yarp::sig::Matrix A;
41  yarp::sig::Vector c;
42  double scale;
44  yarp::sig::Matrix R;
45  yarp::sig::Vector radii;
47  {
48  A=yarp::math::eye(3,3);
49  c=yarp::sig::Vector(3,0.0);
50  R=yarp::math::eye(4,4);
51  radii=yarp::sig::Vector(3,1.0);
52  }
54 
55  virtual bool computeSpatialTransformation();
56  virtual bool computeSpatialCompetence(const std::deque<yarp::sig::Vector> &points);
57  void copySuperClassData(const Calibrator &src);
58 
59 public:
60  virtual std::string getType() const { return type; }
61  virtual bool getExtrapolation() const { return spatialCompetence.extrapolation; }
62  virtual void setExtrapolation(const bool extrapolation) { spatialCompetence.extrapolation=extrapolation; }
63  virtual bool addPoints(const yarp::sig::Vector &in, const yarp::sig::Vector &out)=0;
64  virtual bool clearPoints()=0;
65  virtual bool getPoints(std::deque<yarp::sig::Vector> &in, std::deque<yarp::sig::Vector> &out) const=0;
66  virtual size_t getNumPoints() const { return in.size(); }
67  virtual bool calibrate(double &error)=0;
68  virtual bool retrieve(const yarp::sig::Vector &in, yarp::sig::Vector &out)=0;
69  virtual double getSpatialCompetence(const yarp::sig::Vector &point);
70  virtual bool toProperty(yarp::os::Property &info) const;
71  virtual bool fromProperty(const yarp::os::Property &info);
72  virtual ~Calibrator() { }
73 };
74 
75 
76 /************************************************************************/
78 {
79 protected:
81  yarp::sig::Matrix H;
82  double scale;
83 
84 public:
85  MatrixCalibrator(const std::string &type="se3");
86  MatrixCalibrator(const MatrixCalibrator &calibrator);
87  virtual bool addPoints(const yarp::sig::Vector &in, const yarp::sig::Vector &out);
88  virtual bool clearPoints();
89  virtual bool getPoints(std::deque<yarp::sig::Vector> &in, std::deque<yarp::sig::Vector> &out) const;
90  virtual bool calibrate(double &error);
91  virtual bool retrieve(const yarp::sig::Vector &in, yarp::sig::Vector &out);
92  virtual bool toProperty(yarp::os::Property &info) const;
93  virtual bool fromProperty(const yarp::os::Property &info);
94  virtual ~MatrixCalibrator();
95 };
96 
97 
98 /************************************************************************/
100 {
101 protected:
103 
104 public:
105  LSSVMCalibrator(const std::string &type="lssvm");
106  LSSVMCalibrator(const LSSVMCalibrator &calibrator);
107  virtual bool addPoints(const yarp::sig::Vector &in, const yarp::sig::Vector &out);
108  virtual bool clearPoints();
109  virtual bool getPoints(std::deque<yarp::sig::Vector> &in, std::deque<yarp::sig::Vector> &out) const;
110  virtual bool calibrate(double &error);
111  virtual bool retrieve(const yarp::sig::Vector &in, yarp::sig::Vector &out);
112  virtual bool toProperty(yarp::os::Property &info) const;
113  virtual bool fromProperty(const yarp::os::Property &info);
114  virtual ~LSSVMCalibrator();
115 };
116 
117 
118 /************************************************************************/
120 {
121 protected:
122  std::deque<Calibrator*> models;
123 
124 public:
125  virtual size_t size() const { return models.size(); }
126  virtual Calibrator *operator[](const size_t i);
128  virtual bool retrieve(const yarp::sig::Vector &in, yarp::sig::Vector &out);
129  virtual void clear();
130  virtual ~LocallyWeightedExperts();
131 };
132 
133 
134 #endif
135 
136 
LSSVMCalibrator::getPoints
virtual bool getPoints(std::deque< yarp::sig::Vector > &in, std::deque< yarp::sig::Vector > &out) const
Definition: methods.cpp:403
Calibrator::retrieve
virtual bool retrieve(const yarp::sig::Vector &in, yarp::sig::Vector &out)=0
MatrixCalibrator::scale
double scale
Definition: methods.h:82
LSSVMCalibrator
Definition: methods.h:99
Calibrator::spatialCompetence
struct Calibrator::SpatialCompetence spatialCompetence
IMachineLearner.h
MatrixCalibrator::H
yarp::sig::Matrix H
Definition: methods.h:81
Calibrator::SpatialCompetence::A
yarp::sig::Matrix A
Definition: methods.h:40
iCub::action::log::info
@ info
Definition: actionPrimitives.cpp:64
iCub::learningmachine::IMachineLearner
Definition: IMachineLearner.h:89
Calibrator::toProperty
virtual bool toProperty(yarp::os::Property &info) const
Definition: methods.cpp:130
LocallyWeightedExperts::models
std::deque< Calibrator * > models
Definition: methods.h:122
LSSVMCalibrator::LSSVMCalibrator
LSSVMCalibrator(const std::string &type="lssvm")
Definition: methods.cpp:353
Calibrator::getExtrapolation
virtual bool getExtrapolation() const
Definition: methods.h:61
Calibrator
Definition: methods.h:32
LocallyWeightedExperts::clear
virtual void clear()
Definition: methods.cpp:571
Calibrator::getType
virtual std::string getType() const
Definition: methods.h:60
Calibrator::clearPoints
virtual bool clearPoints()=0
Calibrator::SpatialCompetence::radii
yarp::sig::Vector radii
Definition: methods.h:45
LSSVMCalibrator::calibrate
virtual bool calibrate(double &error)
Definition: methods.cpp:412
LSSVMCalibrator::addPoints
virtual bool addPoints(const yarp::sig::Vector &in, const yarp::sig::Vector &out)
Definition: methods.cpp:375
Calibrator::addPoints
virtual bool addPoints(const yarp::sig::Vector &in, const yarp::sig::Vector &out)=0
out
out
Definition: sine.m:8
LocallyWeightedExperts::operator<<
virtual LocallyWeightedExperts & operator<<(Calibrator &c)
Definition: methods.cpp:508
MatrixCalibrator::addPoints
virtual bool addPoints(const yarp::sig::Vector &in, const yarp::sig::Vector &out)
Definition: methods.cpp:224
MatrixCalibrator::impl
iCub::optimization::MatrixTransformationWithMatchedPoints * impl
Definition: methods.h:80
LSSVMCalibrator::~LSSVMCalibrator
virtual ~LSSVMCalibrator()
Definition: methods.cpp:489
LocallyWeightedExperts
Definition: methods.h:119
Calibrator::type
std::string type
Definition: methods.h:35
Calibrator::out
std::deque< yarp::sig::Vector > out
Definition: methods.h:36
LSSVMCalibrator::retrieve
virtual bool retrieve(const yarp::sig::Vector &in, yarp::sig::Vector &out)
Definition: methods.cpp:439
MatrixCalibrator::toProperty
virtual bool toProperty(yarp::os::Property &info) const
Definition: methods.cpp:293
Calibrator::~Calibrator
virtual ~Calibrator()
Definition: methods.h:72
Calibrator::in
std::deque< yarp::sig::Vector > in
Definition: methods.h:36
state::error
@ error
MatrixCalibrator
Definition: methods.h:77
Calibrator::SpatialCompetence::scale
double scale
Definition: methods.h:42
Calibrator::getSpatialCompetence
virtual double getSpatialCompetence(const yarp::sig::Vector &point)
Definition: methods.cpp:90
MatrixCalibrator::fromProperty
virtual bool fromProperty(const yarp::os::Property &info)
Definition: methods.cpp:310
Calibrator::fromProperty
virtual bool fromProperty(const yarp::os::Property &info)
Definition: methods.cpp:149
LSSVMCalibrator::toProperty
virtual bool toProperty(yarp::os::Property &info) const
Definition: methods.cpp:453
LocallyWeightedExperts::~LocallyWeightedExperts
virtual ~LocallyWeightedExperts()
Definition: methods.cpp:581
Calibrator::computeSpatialTransformation
virtual bool computeSpatialTransformation()
Definition: methods.cpp:41
Calibrator::calibrate
virtual bool calibrate(double &error)=0
LSSVMCalibrator::clearPoints
virtual bool clearPoints()
Definition: methods.cpp:393
MatrixCalibrator::clearPoints
virtual bool clearPoints()
Definition: methods.cpp:241
matrixTransformation.h
iCub::optimization::MatrixTransformationWithMatchedPoints
Definition: matrixTransformation.h:47
Calibrator::copySuperClassData
void copySuperClassData(const Calibrator &src)
Definition: methods.cpp:80
MatrixCalibrator::retrieve
virtual bool retrieve(const yarp::sig::Vector &in, yarp::sig::Vector &out)
Definition: methods.cpp:276
Calibrator::SpatialCompetence
Definition: methods.h:38
string
string(REPLACE "-rdynamic" "" CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "${CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS}") include_directories($
Definition: CMakeLists.txt:9
LocallyWeightedExperts::size
virtual size_t size() const
Definition: methods.h:125
MatrixCalibrator::~MatrixCalibrator
virtual ~MatrixCalibrator()
Definition: methods.cpp:217
Calibrator::SpatialCompetence::extrapolation
bool extrapolation
Definition: methods.h:43
LocallyWeightedExperts::operator[]
virtual Calibrator * operator[](const size_t i)
Definition: methods.cpp:498
Calibrator::getPoints
virtual bool getPoints(std::deque< yarp::sig::Vector > &in, std::deque< yarp::sig::Vector > &out) const =0
LocallyWeightedExperts::retrieve
virtual bool retrieve(const yarp::sig::Vector &in, yarp::sig::Vector &out)
Definition: methods.cpp:522
Calibrator::getNumPoints
virtual size_t getNumPoints() const
Definition: methods.h:66
MatrixCalibrator::calibrate
virtual bool calibrate(double &error)
Definition: methods.cpp:260
LSSVMCalibrator::impl
iCub::learningmachine::IMachineLearner * impl
Definition: methods.h:102
Calibrator::setExtrapolation
virtual void setExtrapolation(const bool extrapolation)
Definition: methods.h:62
Calibrator::SpatialCompetence::c
yarp::sig::Vector c
Definition: methods.h:41
Calibrator::SpatialCompetence::SpatialCompetence
SpatialCompetence()
Definition: methods.h:46
LSSVMCalibrator::fromProperty
virtual bool fromProperty(const yarp::os::Property &info)
Definition: methods.cpp:467
Calibrator::SpatialCompetence::R
yarp::sig::Matrix R
Definition: methods.h:44
Calibrator::computeSpatialCompetence
virtual bool computeSpatialCompetence(const std::deque< yarp::sig::Vector > &points)
Definition: methods.cpp:69
MatrixCalibrator::getPoints
virtual bool getPoints(std::deque< yarp::sig::Vector > &in, std::deque< yarp::sig::Vector > &out) const
Definition: methods.cpp:251
MatrixCalibrator::MatrixCalibrator
MatrixCalibrator(const std::string &type="se3")
Definition: methods.cpp:184