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:
35  std::string type;
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 
virtual bool clearPoints()=0
virtual bool retrieve(const yarp::sig::Vector &in, yarp::sig::Vector &out)=0
virtual bool getExtrapolation() const
Definition: methods.h:61
std::deque< yarp::sig::Vector > out
Definition: methods.h:36
virtual bool toProperty(yarp::os::Property &info) const
Definition: methods.cpp:130
virtual bool getPoints(std::deque< yarp::sig::Vector > &in, std::deque< yarp::sig::Vector > &out) const =0
virtual bool computeSpatialCompetence(const std::deque< yarp::sig::Vector > &points)
Definition: methods.cpp:69
virtual bool addPoints(const yarp::sig::Vector &in, const yarp::sig::Vector &out)=0
virtual void setExtrapolation(const bool extrapolation)
Definition: methods.h:62
virtual bool fromProperty(const yarp::os::Property &info)
Definition: methods.cpp:149
std::string type
Definition: methods.h:35
void copySuperClassData(const Calibrator &src)
Definition: methods.cpp:80
virtual bool calibrate(double &error)=0
virtual bool computeSpatialTransformation()
Definition: methods.cpp:41
virtual ~Calibrator()
Definition: methods.h:72
std::deque< yarp::sig::Vector > in
Definition: methods.h:36
struct Calibrator::SpatialCompetence spatialCompetence
virtual size_t getNumPoints() const
Definition: methods.h:66
virtual std::string getType() const
Definition: methods.h:60
virtual double getSpatialCompetence(const yarp::sig::Vector &point)
Definition: methods.cpp:90
virtual ~LSSVMCalibrator()
Definition: methods.cpp:489
virtual bool addPoints(const yarp::sig::Vector &in, const yarp::sig::Vector &out)
Definition: methods.cpp:375
virtual bool getPoints(std::deque< yarp::sig::Vector > &in, std::deque< yarp::sig::Vector > &out) const
Definition: methods.cpp:403
LSSVMCalibrator(const std::string &type="lssvm")
Definition: methods.cpp:353
virtual bool clearPoints()
Definition: methods.cpp:393
iCub::learningmachine::IMachineLearner * impl
Definition: methods.h:102
virtual bool toProperty(yarp::os::Property &info) const
Definition: methods.cpp:453
virtual bool calibrate(double &error)
Definition: methods.cpp:412
virtual bool fromProperty(const yarp::os::Property &info)
Definition: methods.cpp:467
virtual bool retrieve(const yarp::sig::Vector &in, yarp::sig::Vector &out)
Definition: methods.cpp:439
virtual LocallyWeightedExperts & operator<<(Calibrator &c)
Definition: methods.cpp:508
virtual size_t size() const
Definition: methods.h:125
virtual Calibrator * operator[](const size_t i)
Definition: methods.cpp:498
virtual bool retrieve(const yarp::sig::Vector &in, yarp::sig::Vector &out)
Definition: methods.cpp:522
std::deque< Calibrator * > models
Definition: methods.h:122
virtual void clear()
Definition: methods.cpp:571
virtual ~LocallyWeightedExperts()
Definition: methods.cpp:581
virtual bool clearPoints()
Definition: methods.cpp:241
virtual bool fromProperty(const yarp::os::Property &info)
Definition: methods.cpp:310
virtual bool calibrate(double &error)
Definition: methods.cpp:260
MatrixCalibrator(const std::string &type="se3")
Definition: methods.cpp:184
virtual bool retrieve(const yarp::sig::Vector &in, yarp::sig::Vector &out)
Definition: methods.cpp:276
double scale
Definition: methods.h:82
yarp::sig::Matrix H
Definition: methods.h:81
virtual bool addPoints(const yarp::sig::Vector &in, const yarp::sig::Vector &out)
Definition: methods.cpp:224
virtual bool toProperty(yarp::os::Property &info) const
Definition: methods.cpp:293
virtual bool getPoints(std::deque< yarp::sig::Vector > &in, std::deque< yarp::sig::Vector > &out) const
Definition: methods.cpp:251
iCub::optimization::MatrixTransformationWithMatchedPoints * impl
Definition: methods.h:80
virtual ~MatrixCalibrator()
Definition: methods.cpp:217
A generalized interface for a learning machine for offline and online learning machines (e....
A class interface to deal with the problem of determining the matrix transformation between two sets ...
out
Definition: sine.m:8
yarp::sig::Matrix A
Definition: methods.h:40
yarp::sig::Vector radii
Definition: methods.h:45
yarp::sig::Vector c
Definition: methods.h:41
yarp::sig::Matrix R
Definition: methods.h:44