Apollo 11.0
自动驾驶开放平台
spline_2d_seg.cc
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2017 The Apollo Authors. All Rights Reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *****************************************************************************/
16
23
24namespace apollo {
25namespace planning {
26Spline2dSeg::Spline2dSeg(const uint32_t order)
27 : spline_func_x_(order), spline_func_y_(order) {
28 derivative_x_ = PolynomialXd::DerivedFrom(spline_func_x_);
29 derivative_y_ = PolynomialXd::DerivedFrom(spline_func_y_);
30 second_derivative_x_ = PolynomialXd::DerivedFrom(derivative_x_);
31 second_derivative_y_ = PolynomialXd::DerivedFrom(derivative_y_);
32 third_derivative_x_ = PolynomialXd::DerivedFrom(second_derivative_x_);
33 third_derivative_y_ = PolynomialXd::DerivedFrom(second_derivative_y_);
34}
35
36Spline2dSeg::Spline2dSeg(const std::vector<double>& x_param,
37 const std::vector<double>& y_param)
38 : spline_func_x_(x_param), spline_func_y_(y_param) {
39 derivative_x_ = PolynomialXd::DerivedFrom(spline_func_x_);
40 derivative_y_ = PolynomialXd::DerivedFrom(spline_func_y_);
41 second_derivative_x_ = PolynomialXd::DerivedFrom(derivative_x_);
42 second_derivative_y_ = PolynomialXd::DerivedFrom(derivative_y_);
43 third_derivative_x_ = PolynomialXd::DerivedFrom(second_derivative_x_);
44 third_derivative_y_ = PolynomialXd::DerivedFrom(second_derivative_y_);
45}
46
47bool Spline2dSeg::SetParams(const std::vector<double>& x_param,
48 const std::vector<double>& y_param) {
49 if (x_param.size() != y_param.size()) {
50 return false;
51 }
52
53 spline_func_x_ = PolynomialXd(x_param);
54 spline_func_y_ = PolynomialXd(y_param);
55 derivative_x_ = PolynomialXd::DerivedFrom(spline_func_x_);
56 derivative_y_ = PolynomialXd::DerivedFrom(spline_func_y_);
57 second_derivative_x_ = PolynomialXd::DerivedFrom(derivative_x_);
58 second_derivative_y_ = PolynomialXd::DerivedFrom(derivative_y_);
59 third_derivative_x_ = PolynomialXd::DerivedFrom(second_derivative_x_);
60 third_derivative_y_ = PolynomialXd::DerivedFrom(second_derivative_y_);
61 return true;
62}
63
64std::pair<double, double> Spline2dSeg::operator()(const double t) const {
65 return std::make_pair(spline_func_x_(t), spline_func_y_(t));
66}
67
68double Spline2dSeg::x(const double t) const { return spline_func_x_(t); }
69
70double Spline2dSeg::y(const double t) const { return spline_func_y_(t); }
71
72double Spline2dSeg::DerivativeX(const double t) const {
73 return derivative_x_(t);
74}
75
76double Spline2dSeg::DerivativeY(const double t) const {
77 return derivative_y_(t);
78}
79
80double Spline2dSeg::SecondDerivativeX(const double t) const {
81 return second_derivative_x_(t);
82}
83
84double Spline2dSeg::SecondDerivativeY(const double t) const {
85 return second_derivative_y_(t);
86}
87
88double Spline2dSeg::ThirdDerivativeX(const double t) const {
89 return third_derivative_x_(t);
90}
91
92double Spline2dSeg::ThirdDerivativeY(const double t) const {
93 return third_derivative_y_(t);
94}
95
97 return spline_func_x_;
98}
99
101 return spline_func_y_;
102}
103
104const PolynomialXd& Spline2dSeg::DerivativeX() const { return derivative_x_; }
105
106const PolynomialXd& Spline2dSeg::DerivativeY() const { return derivative_y_; }
107
109 return second_derivative_x_;
110}
111
113 return second_derivative_y_;
114}
115
117 return third_derivative_x_;
118}
119
121 return third_derivative_y_;
122}
123
124} // namespace planning
125} // namespace apollo
static PolynomialXd DerivedFrom(const PolynomialXd &base)
const PolynomialXd & ThirdDerivativeY() const
const PolynomialXd & SecondDerivativeY() const
bool SetParams(const std::vector< double > &x_param, const std::vector< double > &y_param)
const PolynomialXd & ThirdDerivativeX() const
const PolynomialXd & DerivativeX() const
std::pair< double, double > operator()(const double t) const
Spline2dSeg(const uint32_t order)
const PolynomialXd & SecondDerivativeX() const
const PolynomialXd & spline_func_y() const
const PolynomialXd & DerivativeY() const
double y(const double t) const
double x(const double t) const
const PolynomialXd & spline_func_x() const
Planning module main class.
class register implement
Definition arena_queue.h:37