iCub-main
functionEncoder.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2010 RobotCub Consortium, European Commission FP6 Project IST-004370
3  * Author: Ugo Pattacini
4  * email: ugo.pattacini@iit.it
5  * website: www.robotcub.org
6  * Permission is granted to copy, distribute, and/or modify this program
7  * under the terms of the GNU General Public License, version 2 or any
8  * later version published by the Free Software Foundation.
9  *
10  * A copy of the license can be found at
11  * http://www.robotcub.org/icub/license/gpl.txt
12  *
13  * This program is distributed in the hope that it will be useful, but
14  * WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
16  * Public License for more details
17 */
18 
30 #ifndef __FUNCTIONENCODER_H__
31 #define __FUNCTIONENCODER_H__
32 
33 #include <yarp/os/Property.h>
34 #include <yarp/sig/Vector.h>
35 
36 
37 namespace iCub
38 {
39 
40 namespace ctrl
41 {
42 
48 struct Code
49 {
53  yarp::sig::Vector coefficients;
54 };
55 
56 
63 {
64 public:
70  virtual bool setEncoderOptions(const yarp::os::Property &options) = 0;
71 
76  virtual yarp::os::Property getEncoderOptions() = 0;
77 
87  virtual Code encode(const yarp::sig::Vector &values) = 0;
88 
98  virtual double decode(const Code &code, const double x) = 0;
99 
103  virtual ~FunctionEncoder() { }
104 };
105 
106 
114 {
115 protected:
116  void *w;
117  void *F;
118  const yarp::sig::Vector *pVal;
119 
120  unsigned int iCoeff;
121  double resolution;
122 
123  double interpWavelet(const double x);
124  double interpFunction(const yarp::sig::Vector &values, const double x);
125 
126  friend double waveletIntegrand(double, void*);
127 
128 public:
132  WaveletEncoder();
133 
145  virtual bool setEncoderOptions(const yarp::os::Property &options);
146 
151  virtual yarp::os::Property getEncoderOptions();
152 
164  virtual Code encode(const yarp::sig::Vector &values);
165 
177  virtual double decode(const Code &code, const double x);
178 
182  virtual ~WaveletEncoder();
183 };
184 
185 }
186 
187 }
188 
189 #endif
190 
191 
iCub
This file contains the definition of unique IDs for the body parts and the skin parts of the robot.
Definition: emotionInterface.h:17
iCub::ctrl::FunctionEncoder::decode
virtual double decode(const Code &code, const double x)=0
Compute the approximated value of function in x, given the code.
iCub::ctrl::WaveletEncoder::interpWavelet
double interpWavelet(const double x)
Definition: functionEncoder.cpp:125
iCub::ctrl::WaveletEncoder::decode
virtual double decode(const Code &code, const double x)
Compute the approximated value of function in x, given the input set of wavelet coefficients.
Definition: functionEncoder.cpp:218
iCub::ctrl::Code::coefficients
yarp::sig::Vector coefficients
The vector of coefficients encoding the function.
Definition: functionEncoder.h:53
iCub::ctrl::WaveletEncoder::F
void * F
Definition: functionEncoder.h:117
iCub::ctrl::FunctionEncoder::setEncoderOptions
virtual bool setEncoderOptions(const yarp::os::Property &options)=0
Configure the encoder.
iCub::ctrl::WaveletEncoder::getEncoderOptions
virtual yarp::os::Property getEncoderOptions()
Retrieve the encoder's configuration options.
Definition: functionEncoder.cpp:186
iCub::ctrl::WaveletEncoder::pVal
const yarp::sig::Vector * pVal
Definition: functionEncoder.h:118
iCub::ctrl::WaveletEncoder::interpFunction
double interpFunction(const yarp::sig::Vector &values, const double x)
Definition: functionEncoder.cpp:143
iCub::ctrl::WaveletEncoder::setEncoderOptions
virtual bool setEncoderOptions(const yarp::os::Property &options)
Configure the encoder.
Definition: functionEncoder.cpp:170
iCub::ctrl::FunctionEncoder
Definition: functionEncoder.h:62
iCub::ctrl::WaveletEncoder::w
void * w
Definition: functionEncoder.h:116
iCub::ctrl::WaveletEncoder::waveletIntegrand
friend double waveletIntegrand(double, void *)
Definition: functionEncoder.cpp:99
iCub::ctrl::WaveletEncoder::~WaveletEncoder
virtual ~WaveletEncoder()
Destructor.
Definition: functionEncoder.cpp:232
iCub::ctrl::FunctionEncoder::getEncoderOptions
virtual yarp::os::Property getEncoderOptions()=0
Retrieve the encoder's configuration options.
x
x
Definition: compute_ekf_sym.m:21
iCub::ctrl::WaveletEncoder::encode
virtual Code encode(const yarp::sig::Vector &values)
Encode the function.
Definition: functionEncoder.cpp:195
iCub::ctrl::FunctionEncoder::encode
virtual Code encode(const yarp::sig::Vector &values)=0
Encode the function.
iCub::ctrl::WaveletEncoder::WaveletEncoder
WaveletEncoder()
Constructor.
Definition: functionEncoder.cpp:113
iCub::ctrl::WaveletEncoder::iCoeff
unsigned int iCoeff
Definition: functionEncoder.h:120
iCub::ctrl::WaveletEncoder::resolution
double resolution
Definition: functionEncoder.h:121
iCub::ctrl::Code
Definition: functionEncoder.h:48
iCub::ctrl::FunctionEncoder::~FunctionEncoder
virtual ~FunctionEncoder()
Destructor.
Definition: functionEncoder.h:103
iCub::ctrl::WaveletEncoder
Definition: functionEncoder.h:113