Program Listing for File smooth_spline.hpp

Return to documentation for file (include/bitbots_splines/smooth_spline.hpp)

/*
This code is largely based on the original code by Quentin "Leph" Rouxel and Team Rhoban.
The original files can be found at:
https://github.com/Rhoban/model/
*/
#ifndef BITBOTS_SPLINES_INCLUDE_BITBOTS_SPLINES_SMOOTH_SPLINE_H_
#define BITBOTS_SPLINES_INCLUDE_BITBOTS_SPLINES_SMOOTH_SPLINE_H_

#include "spline.hpp"

namespace bitbots_splines {

class SmoothSpline : public Spline {
 public:
  struct Point {
    double time;
    double position;
    double velocity;
    double acceleration;
  };

  void addPoint(double time, double position, double velocity = 0.0, double acceleration = 0.0);

  const std::vector<Point> &points() const;
  std::vector<Point> &points();

  void computeSplines();

  std::string getDebugString();

 protected:
  void importCallBack() override;

 private:
  std::vector<Point> points_;

  Polynom polynomFit(double t, double pos_1, double vel_1, double acc_1, double pos_2, double vel_2,
                     double acc_2) const;
};

}  // namespace bitbots_splines

#endif