iCub-main
Loading...
Searching...
No Matches
adaptWinPolyEstimator.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2006-2018 Istituto Italiano di Tecnologia (IIT)
3 * Copyright (C) 2006-2010 RobotCub Consortium
4 * All rights reserved.
5 *
6 * This software may be modified and distributed under the terms
7 * of the BSD-3-Clause license. See the accompanying LICENSE file for
8 * details.
9*/
10
25#ifndef __ADAPTWINPOLYESTIMATOR_H__
26#define __ADAPTWINPOLYESTIMATOR_H__
27
28#include <deque>
29
30#include <yarp/sig/Vector.h>
31#include <iCub/ctrl/math.h>
32
33
34namespace iCub
35{
36
37namespace ctrl
38{
39
46{
47public:
48 yarp::sig::Vector data;
49 double time;
50
55
61 AWPolyElement(const yarp::sig::Vector &d, const double t): data(d), time(t) { }
62};
63
64
65typedef std::deque<AWPolyElement> AWPolyList;
66
74{
75protected:
77 unsigned int order;
78 unsigned int N;
79 double D;
80
81 yarp::sig::Vector t;
82 yarp::sig::Vector x;
83 yarp::sig::Vector coeff;
84 yarp::sig::Vector winLen;
85 yarp::sig::Vector mse;
86
88
97 virtual yarp::sig::Vector fit(const yarp::sig::Vector &x,
98 const yarp::sig::Vector &y, const unsigned int n=0);
99
105 virtual double eval(double x);
106
112 virtual double getEsteeme() = 0;
113
114public:
122 AWPolyEstimator(unsigned int _order, unsigned int _N, const double _D);
123
129
134 void feedData(const AWPolyElement &el);
135
140 yarp::sig::Vector getWinLen() { return winLen; }
141
147 yarp::sig::Vector getMSE() { return mse; }
148
154 yarp::sig::Vector estimate();
155
162 yarp::sig::Vector estimate(const AWPolyElement &el);
163
169 void reset();
170
174 virtual ~AWPolyEstimator() { }
175};
176
177
185{
186protected:
191 virtual yarp::sig::Vector fit(const yarp::sig::Vector &x,
192 const yarp::sig::Vector &y, const unsigned int n=0);
193
194 virtual double getEsteeme() { return coeff[1]; }
195
196public:
197 AWLinEstimator(unsigned int _N, const double _D) : AWPolyEstimator(1,_N,_D) { }
198};
199
200
208{
209protected:
210 virtual double getEsteeme() { return 2.0*coeff[2]; }
211
212public:
213 AWQuadEstimator(unsigned int _N, const double _D) : AWPolyEstimator(2,_N,_D) { }
214};
215
216}
217
218}
219
220#endif
221
222
Adaptive window linear fitting to estimate the first derivative.
virtual yarp::sig::Vector fit(const yarp::sig::Vector &x, const yarp::sig::Vector &y, const unsigned int n=0)
Redefine method to improve computation just for first-order estimator.
AWLinEstimator(unsigned int _N, const double _D)
virtual double getEsteeme()
Return the current estimation.
Basic element for adaptive polynomial fitting.
AWPolyElement()
Default constructor.
AWPolyElement(const yarp::sig::Vector &d, const double t)
Create an element for adaptive polynomial fitting.
Adaptive window polynomial fitting.
yarp::sig::Vector estimate()
Execute the algorithm upon the elements list, with the max deviation threshold given by D.
void feedData(const AWPolyElement &el)
Feed data into the algorithm.
yarp::sig::Vector getMSE()
Return the mean squared error (MSE) computed over the current windows lengths between the predictions...
virtual ~AWPolyEstimator()
Destructor.
virtual double eval(double x)
Evaluate regressor at certain point.
void reset()
Reinitialize the internal state.
virtual double getEsteeme()=0
Return the current estimation.
AWPolyList & getList()
Return a reference to internal elements list.
yarp::sig::Vector getWinLen()
Return the current windows lengths.
virtual yarp::sig::Vector fit(const yarp::sig::Vector &x, const yarp::sig::Vector &y, const unsigned int n=0)
Find the regressor which best fits in least square sense the last n data sample couples,...
Adaptive window quadratic fitting to estimate the second derivative.
virtual double getEsteeme()
Return the current estimation.
AWQuadEstimator(unsigned int _N, const double _D)
int n
std::deque< AWPolyElement > AWPolyList
This file contains the definition of unique IDs for the body parts and the skin parts of the robot.