21 #include <gsl/gsl_integration.h>
23 #include <yarp/math/Math.h>
26 #define CAST_GSLFUNC(x) (static_cast<gsl_function*>(x))
27 #define CAST_GSLWS(x) (static_cast<gsl_integration_workspace*>(x))
28 #define WAVELET_LUP_SIZE 57
30 using namespace yarp::os;
31 using namespace yarp::sig;
32 using namespace yarp::math;
41 { 0.125, 0.0345833411415645 },
42 { 0.250, 0.107309738113335 },
43 { 0.375, 0.202014885729746 },
44 { 0.500, 0.328773960240219 },
45 { 0.625, 0.467801596736295 },
46 { 0.750, 0.618433317340402 },
47 { 0.875, 0.799799587363102 },
48 { 1.000, 1.00839956631986 },
49 { 1.125, 1.11213550554368 },
50 { 1.250, 1.10075377628576 },
51 { 1.375, 1.03456741914056 },
52 { 1.500, 0.876691003658645 },
53 { 1.625, 0.708936729237485 },
54 { 1.750, 0.535149009932799 },
55 { 1.875, 0.281586312944196 },
56 { 2.000, -0.0358782406601501 },
57 { 2.125, -0.233040642106083 },
58 { 2.250, -0.302412553008806 },
59 { 2.375, -0.321628766530846 },
60 { 2.500, -0.241966742214465 },
61 { 2.625, -0.190865137334676 },
62 { 2.750, -0.175103704342541 },
63 { 2.875, -0.0890678401406110 },
64 { 3.000, 0.0407115008395991 },
65 { 3.125, 0.108682072349430 },
66 { 3.250, 0.118185639560005 },
67 { 3.375, 0.101870197888310 },
68 { 3.500, 0.0341494900045930 },
69 { 3.625, 0.00431657421191742 },
70 { 3.750, 0.0162890023018952 },
71 { 3.875, 0.00436750867994683 },
72 { 4.000, -0.0120853649259263 },
73 { 4.125, -0.0194095628614931 },
74 { 4.250, -0.0234198437934784 },
75 { 4.375, -0.0169172631594144 },
76 { 4.500, 0.00224836903406590 },
77 { 4.625, 0.00948830118465152 },
78 { 4.750, 0.00525142022644811 },
79 { 4.875, 0.00340625270534754 },
80 { 5.000, -0.00116770339087780 },
81 { 5.125, -0.00296115923392665 },
82 { 5.250, -0.000413390931405029 },
83 { 5.375, 9.35269316433299e-05 },
84 { 5.500, 0.000103919276941685 },
85 { 5.625, 0.000321935964326630 },
86 { 5.750, -1.90454590045895e-05 },
87 { 5.875, -9.18215519817765e-05 },
88 { 6.000, 2.02418174948211e-05 },
89 { 6.125, 1.04451668231589e-05 },
90 { 6.250, -3.36622541321180e-06 },
102 const Vector &values=*pWavEnc->
pVal;
103 unsigned int n=pWavEnc->
iCoeff;
113 WaveletEncoder::WaveletEncoder()
116 w=gsl_integration_workspace_alloc(1000);
125 double WaveletEncoder::interpWavelet(
const double x)
137 return ((
x-x0)/(
x1-x0))*(y1-y0)+y0;
143 double WaveletEncoder::interpFunction(
const Vector &values,
const double x)
146 double L=(double)values.size()-1.0;
151 return values[(size_t)L];
154 size_t i=(size_t)(
x*L);
155 double x0=((double)i)/L;
161 double x1=((double)i)/L;
164 return ((
x-x0)/(
x1-x0))*(y1-y0)+y0;
170 bool WaveletEncoder::setEncoderOptions(
const Property &options)
172 if (options.check(
"resolution"))
174 double R=options.find(
"resolution").asFloat64();
186 Property WaveletEncoder::getEncoderOptions()
189 options.put(
"resolution",resolution);
195 Code WaveletEncoder::encode(
const Vector &values)
199 unsigned int N=(
unsigned int)resolution+1;
204 for (iCoeff=0; iCoeff<N; iCoeff++)
206 double tau1=(
waveLUP[0][0]+iCoeff)/resolution;
218 double WaveletEncoder::decode(
const Code &code,
const double x)
220 unsigned int N=(
unsigned int)resolution+1;
224 for (
unsigned int n=0;
n<N;
n++)
232 WaveletEncoder::~WaveletEncoder()
234 gsl_integration_workspace_free(
CAST_GSLWS(w));
Encode any given function as a set of wavelet coefficients.
const yarp::sig::Vector * pVal
double interpFunction(const yarp::sig::Vector &values, const double x)
double interpWavelet(const double x)
double waveLUP[WAVELET_LUP_SIZE][2]
double waveletIntegrand(double x, void *params)
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.