29 : t_knots_(t_knots), spline_order_(order) {
31 for (uint32_t i = 1; i < t_knots_.size(); ++i) {
32 splines_.emplace_back(spline_order_);
38 if (splines_.empty()) {
39 return std::make_pair(0.0, 0.0);
41 uint32_t index = find_index(t);
42 return splines_[index](t - t_knots_[index]);
46 if (splines_.empty()) {
49 uint32_t index = find_index(t);
50 return splines_[index].x(t - t_knots_[index]);
54 if (splines_.empty()) {
57 uint32_t index = find_index(t);
58 return splines_[index].y(t - t_knots_[index]);
63 if (splines_.empty()) {
66 uint32_t index = find_index(t);
67 return splines_[index].DerivativeX(t - t_knots_[index]);
72 if (splines_.empty()) {
75 uint32_t index = find_index(t);
76 return splines_[index].DerivativeY(t - t_knots_[index]);
80 if (splines_.empty()) {
83 uint32_t index = find_index(t);
84 return splines_[index].SecondDerivativeX(t - t_knots_[index]);
88 if (splines_.empty()) {
91 uint32_t index = find_index(t);
92 return splines_[index].SecondDerivativeY(t - t_knots_[index]);
96 if (splines_.empty()) {
99 uint32_t index = find_index(t);
100 return splines_[index].ThirdDerivativeX(t - t_knots_[index]);
104 if (splines_.empty()) {
107 uint32_t index = find_index(t);
108 return splines_[index].ThirdDerivativeY(t - t_knots_[index]);
114 const uint32_t order) {
115 const uint32_t num_params = order + 1;
117 if (2 * t_knots_.size() * num_params !=
118 2 * num_params +
static_cast<uint32_t
>(params.rows())) {
121 for (uint32_t i = 0; i < splines_.size(); ++i) {
122 std::vector<double> spline_piece_x(num_params, 0.0);
123 std::vector<double> spline_piece_y(num_params, 0.0);
124 for (uint32_t j = 0; j < num_params; ++j) {
125 spline_piece_x[j] = params(2 * i * num_params + j, 0);
126 spline_piece_y[j] = params((2 * i + 1) * num_params + j, 0);
128 splines_[i].SetParams(spline_piece_x, spline_piece_y);
130 spline_order_ = order;
135 return splines_[index];
142uint32_t Spline2d::find_index(
const double t)
const {
143 auto upper_bound = std::upper_bound(t_knots_.begin() + 1, t_knots_.end(), t);
144 return std::min(
static_cast<uint32_t
>(t_knots_.size() - 1),
145 static_cast<uint32_t
>(upper_bound - t_knots_.begin())) -
double ThirdDerivativeX(const double t) const
double DerivativeX(const double t) const
double DerivativeY(const double t) const
const std::vector< double > & t_knots() const
double x(const double t) const
bool set_splines(const Eigen::MatrixXd ¶ms, const uint32_t order)
: set splines
double SecondDerivativeX(const double t) const
Spline2d(const std::vector< double > &t_knots, const uint32_t order)
const Spline2dSeg & smoothing_spline(const uint32_t index) const
std::pair< double, double > operator()(const double t) const
double y(const double t) const
double SecondDerivativeY(const double t) const
double ThirdDerivativeY(const double t) const
uint32_t spline_order() const
Planning module main class.
: piecewise smoothing spline 2d class