21 template <
class T,
typename SCALAR =
double>
25 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
28 typedef std::vector<vector_t, Eigen::aligned_allocator<vector_t>>
vector_array_t;
29 typedef Eigen::Matrix<SCALAR, T::DIM, T::DIM>
matrix_t;
40 void computeSpline(
const vector_array_t& points)
override { nodes_ = points; }
44 Eigen::Matrix<SCALAR, Eigen::Dynamic, 1> result;
45 result.resize(T::DIM);
48 SCALAR t_shot = timeGrid_->getShotDuration(shotIdx);
49 SCALAR t_s_start = timeGrid_->getShotStartTime(shotIdx);
50 SCALAR t_s_end = timeGrid_->getShotEndTime(shotIdx);
52 assert(shotIdx < nodes_.size());
54 result = nodes_[shotIdx] * (t_s_end - time) / t_shot + nodes_[shotIdx + 1] * (time - t_s_start) / t_shot;
64 SCALAR t_shot = timeGrid_->getShotDuration(shotIdx);
66 result = (nodes_[shotIdx + 1] - nodes_[shotIdx]) / t_shot;
76 SCALAR t_shot = timeGrid_->getShotDuration(shotIdx);
77 SCALAR t_s_start = timeGrid_->getShotStartTime(shotIdx);
79 result = (time - t_s_start) * (nodes_[shotIdx] - nodes_[shotIdx + 1]) / (t_shot * t_shot);
88 SCALAR t_shot = timeGrid_->getShotDuration(shotIdx);
89 SCALAR t_s_end = timeGrid_->getShotEndTime(shotIdx);
92 drv *= (t_s_end - time) / t_shot;
103 SCALAR t_shot = timeGrid_->getShotDuration(shotIdx);
104 SCALAR t_s_start = timeGrid_->getShotStartTime(shotIdx);
107 drv *= (time - t_s_start) / t_shot;
114 vector_array_t nodes_;
116 std::shared_ptr<tpl::TimeGrid<SCALAR>> timeGrid_;
Eigen::Matrix< SCALAR, T::DIM, T::DIM > matrix_t
Definition: LinearSpliner.h:29
Abstract base class for the control input splining between the DMS shots.
Definition: SplinerBase.h:20
matrix_t splineDerivative_q_i(const SCALAR time, const size_t shotIdx) const override
Return the spline derivative with respect to the control input at shot i.
Definition: LinearSpliner.h:84
The linear spline implementation.
Definition: LinearSpliner.h:22
vector_t evalSpline(const SCALAR time, const size_t shotIdx) override
Depending on the spline type, this method evaluates the control input between the shots...
Definition: LinearSpliner.h:42
~LinearSpliner() override=default
LinearSpliner(std::shared_ptr< tpl::TimeGrid< SCALAR >> grid)
Custom constructor.
Definition: LinearSpliner.h:38
CppAD::AD< CppAD::cg::CG< double > > SCALAR
void computeSpline(const vector_array_t &points) override
Updates the vector on the shots.
Definition: LinearSpliner.h:40
std::vector< vector_t, Eigen::aligned_allocator< vector_t > > vector_array_t
Definition: LinearSpliner.h:28
Definition: TimeGrid.h:27
EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef T vector_t
Definition: LinearSpliner.h:27
matrix_t splineDerivative_q_iplus1(const SCALAR time, const size_t shotIdx) const override
Returns the spline derivative with respect to the control input at shot i+1.
Definition: LinearSpliner.h:98
vector_t splineDerivative_t(const SCALAR time, const size_t shotIdx) const override
Returns the spline derivatives with respect to time.
Definition: LinearSpliner.h:60
vector_t splineDerivative_h_i(const SCALAR time, const size_t shotIdx) const override
Returns the spline derivatives with respect to the time segment between the shots.
Definition: LinearSpliner.h:72