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
00109 class CubicHermitePolynomial : public Polynomial {
00110 public:
00111 CubicHermitePolynomial(int dim);
00112 virtual ~CubicHermitePolynomial() = default;
00113
00114
00118 void SetDuration(double duration);
00119
00125 void SetNodes(const Node& n0, const Node& n1);
00126
00130 void UpdateCoeff();
00131
00136 VectorXd GetDerivativeOfPosWrtDuration(double t) const;
00137
00144 double GetDerivativeWrtStartNode(Dx dfdt, Dx node_deriv, double t) const;
00145
00152 double GetDerivativeWrtEndNode(Dx dfdt, Dx node_deriv, double t) const;
00153
00157 const double GetDuration() const { return T_; };
00158
00159 private:
00160 double T_;
00161 Node n0_, n1_;
00162
00163
00164 double GetDerivativeOfPosWrtStartNode(Dx node_deriv, double t_local) const;
00165 double GetDerivativeOfVelWrtStartNode(Dx node_deriv, double t_local) const;
00166 double GetDerivativeOfAccWrtStartNode(Dx node_deriv, double t_local) const;
00167
00168 double GetDerivativeOfPosWrtEndNode(Dx node_deriv, double t_local) const;
00169 double GetDerivativeOfVelWrtEndNode(Dx node_deriv, double t_local) const;
00170 double GetDerivativeOfAccWrtEndNode(Dx node_deriv, double t_local) const;
00171 };
00172
00173 }
00174
00175 #endif // TOWR_VARIABLES_POLYNOMIAL_H_