sot-torque-control  1.6.1
Collection of dynamic-graph entities aimed at implementing torque control on different robots.
poly-estimator.hh
Go to the documentation of this file.
1 /*
2  Oscar Efrain RAMOS PONCE, LAAS-CNRS
3  Date: 28/10/2014
4  Object to estimate a polynomial that fits some data.
5 */
6 
7 #ifndef _POLY_ESTIMATOR_HH_
8 #define _POLY_ESTIMATOR_HH_
9 
10 #include <Eigen/Dense>
11 #include <vector>
12 
19 void pinv(const Eigen::MatrixXd& matrix_in, Eigen::MatrixXd& pseudo_inv, const double& pinvtoler = 1.0e-6);
20 
30  public:
37  PolyEstimator(const unsigned int& order, const unsigned int& N, const double& dt);
38 
48  void estimate(std::vector<double>& estimee, const std::vector<double>& data_element, const double& time);
49 
58  virtual void estimate(std::vector<double>& estimee, const std::vector<double>& data_element) = 0;
59 
68  virtual void estimateRecursive(std::vector<double>& estimee, const std::vector<double>& data_element,
69  const double& time) = 0;
70 
76  virtual void getEstimateDerivative(std::vector<double>& estimeeDerivative, const unsigned int order) = 0;
77 
82  void setWindowLength(const unsigned int& N);
83 
88  unsigned int getWindowLength();
89 
90  protected:
95  virtual void fit();
96 
100  virtual double getEsteeme() = 0;
101 
103  unsigned int order_;
104 
106  unsigned int N_;
107 
109  double dt_;
110 
112  bool dt_zero_;
113 
117 
119  std::vector<std::vector<double> > elem_list_;
120 
122  std::vector<double> time_list_;
123 
125  unsigned int pt_;
126 
128  Eigen::VectorXd coeff_;
129 
131  std::vector<double> t_;
132 
135  std::vector<double> x_;
136 
140  Eigen::MatrixXd R_;
141 };
142 
143 #endif
PolyEstimator::fit
virtual void fit()
Definition: poly-estimator.cpp:84
PolyEstimator::first_run_
bool first_run_
Definition: poly-estimator.hh:116
PolyEstimator::dt_
double dt_
Sampling (control) time.
Definition: poly-estimator.hh:109
PolyEstimator::R_
Eigen::MatrixXd R_
Definition: poly-estimator.hh:140
PolyEstimator::estimate
void estimate(std::vector< double > &estimee, const std::vector< double > &data_element, const double &time)
Definition: poly-estimator.cpp:36
PolyEstimator::getEstimateDerivative
virtual void getEstimateDerivative(std::vector< double > &estimeeDerivative, const unsigned int order)=0
PolyEstimator::coeff_
Eigen::VectorXd coeff_
Coefficients for the least squares solution.
Definition: poly-estimator.hh:128
PolyEstimator::setWindowLength
void setWindowLength(const unsigned int &N)
Definition: poly-estimator.cpp:100
PolyEstimator::dt_zero_
bool dt_zero_
Indicate that dt is zero (dt is invalid)
Definition: poly-estimator.hh:112
pinv
void pinv(const Eigen::MatrixXd &matrix_in, Eigen::MatrixXd &pseudo_inv, const double &pinvtoler=1.0e-6)
Definition: poly-estimator.cpp:9
PolyEstimator::t_
std::vector< double > t_
Time vector setting the lowest time to zero (for numerical stability).
Definition: poly-estimator.hh:131
PolyEstimator::N_
unsigned int N_
Window length.
Definition: poly-estimator.hh:106
PolyEstimator
Definition: poly-estimator.hh:29
PolyEstimator::getWindowLength
unsigned int getWindowLength()
Definition: poly-estimator.cpp:102
PolyEstimator::order_
unsigned int order_
Order of the polynomial estimator.
Definition: poly-estimator.hh:103
PolyEstimator::pt_
unsigned int pt_
Circular index to each data and time element.
Definition: poly-estimator.hh:125
PolyEstimator::x_
std::vector< double > x_
Definition: poly-estimator.hh:135
PolyEstimator::time_list_
std::vector< double > time_list_
Time vector corresponding to each element in elem_list_.
Definition: poly-estimator.hh:122
PolyEstimator::estimateRecursive
virtual void estimateRecursive(std::vector< double > &estimee, const std::vector< double > &data_element, const double &time)=0
PolyEstimator::PolyEstimator
PolyEstimator(const unsigned int &order, const unsigned int &N, const double &dt)
Definition: poly-estimator.cpp:22
PolyEstimator::elem_list_
std::vector< std::vector< double > > elem_list_
All the data (N elements of size dim)
Definition: poly-estimator.hh:119
PolyEstimator::getEsteeme
virtual double getEsteeme()=0