Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef TOWR_VARIABLES_POLYNOMIAL_H_
00031 #define TOWR_VARIABLES_POLYNOMIAL_H_
00032
00033 #include <string>
00034 #include <vector>
00035
00036 #include <Eigen/Dense>
00037
00038 #include "state.h"
00039
00040 namespace towr {
00041
00053 class Polynomial {
00054 public:
00055 enum Coefficients { A=0, B, C, D, E, F, G, H, I, J};
00056 using CoeffIDVec = std::vector<Coefficients>;
00057 using VectorXd = Eigen::VectorXd;
00058
00059 public:
00065 explicit Polynomial(int poly_order, int poly_dim);
00066 virtual ~Polynomial() = default;
00067
00071 State GetPoint(double t) const;
00072
00080 double GetDerivativeWrtCoeff(double t, Dx poly_deriv, Coefficients coeff) const;
00081
00082 protected:
00083 std::vector<VectorXd> coeff_;
00084
00085 private:
00086 CoeffIDVec coeff_ids_;
00087 };
00088
00089
00105 class CubicHermitePolynomial : public Polynomial {
00106 public:
00107 CubicHermitePolynomial(int dim);
00108 virtual ~CubicHermitePolynomial() = default;
00109
00110
00114 void SetDuration(double duration);
00115
00121 void SetNodes(const Node& n0, const Node& n1);
00122
00126 void UpdateCoeff();
00127
00132 VectorXd GetDerivativeOfPosWrtDuration(double t) const;
00133
00140 double GetDerivativeWrtStartNode(Dx dfdt, Dx node_deriv, double t) const;
00141
00148 double GetDerivativeWrtEndNode(Dx dfdt, Dx node_deriv, double t) const;
00149
00153 const double GetDuration() const { return T_; };
00154
00155 private:
00156 double T_;
00157 Node n0_, n1_;
00158
00159
00160 double GetDerivativeOfPosWrtStartNode(Dx node_deriv, double t_local) const;
00161 double GetDerivativeOfVelWrtStartNode(Dx node_deriv, double t_local) const;
00162 double GetDerivativeOfAccWrtStartNode(Dx node_deriv, double t_local) const;
00163
00164 double GetDerivativeOfPosWrtEndNode(Dx node_deriv, double t_local) const;
00165 double GetDerivativeOfVelWrtEndNode(Dx node_deriv, double t_local) const;
00166 double GetDerivativeOfAccWrtEndNode(Dx node_deriv, double t_local) const;
00167 };
00168
00169 }
00170
00171 #endif // TOWR_VARIABLES_POLYNOMIAL_H_