polynomial.h
Go to the documentation of this file.
00001 /******************************************************************************
00002 Copyright (c) 2018, Alexander W. Winkler. All rights reserved.
00003 
00004 Redistribution and use in source and binary forms, with or without
00005 modification, are permitted provided that the following conditions are met:
00006 
00007 * Redistributions of source code must retain the above copyright notice, this
00008   list of conditions and the following disclaimer.
00009 
00010 * Redistributions in binary form must reproduce the above copyright notice,
00011   this list of conditions and the following disclaimer in the documentation
00012   and/or other materials provided with the distribution.
00013 
00014 * Neither the name of the copyright holder nor the names of its
00015   contributors may be used to endorse or promote products derived from
00016   this software without specific prior written permission.
00017 
00018 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00019 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00020 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00021 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
00022 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00023 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00024 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00025 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00026 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00027 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
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   // see matlab/cubic_hermite_polynomial.m script for derivation
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 } // namespace towr
00174 
00175 #endif // TOWR_VARIABLES_POLYNOMIAL_H_


towr
Author(s): Alexander W. Winkler
autogenerated on Mon Apr 15 2019 02:42:32