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 
Abstract class to deal with function encoding.
virtual ~FunctionEncoder()
Destructor.
virtual bool setEncoderOptions(const yarp::os::Property &options)=0
Configure the encoder.
virtual double decode(const Code &code, const double x)=0
Compute the approximated value of function in x, given the code.
virtual yarp::os::Property getEncoderOptions()=0
Retrieve the encoder's configuration options.
virtual Code encode(const yarp::sig::Vector &values)=0
Encode the function.
Encode any given function as a set of wavelet coefficients.
const yarp::sig::Vector * pVal
friend double waveletIntegrand(double, void *)
virtual double decode(const Code &code, const double x)
Compute the approximated value of function in x, given the input set of wavelet coefficients.
virtual ~WaveletEncoder()
Destructor.
virtual yarp::os::Property getEncoderOptions()
Retrieve the encoder's configuration options.
virtual Code encode(const yarp::sig::Vector &values)
Encode the function.
virtual bool setEncoderOptions(const yarp::os::Property &options)
Configure the encoder.
double interpFunction(const yarp::sig::Vector &values, const double x)
double interpWavelet(const double x)
This file contains the definition of unique IDs for the body parts and the skin parts of the robot.
yarp::sig::Vector coefficients
The vector of coefficients encoding the function.