Apollo 11.0
自动驾驶开放平台
piecewise_quintic_spiral_path.cc
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2018 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
22
23namespace apollo {
24namespace planning {
25
27 const double kappa,
28 const double dkappa)
29 : last_theta_(theta), last_kappa_(kappa), last_dkappa_(dkappa) {
30 accumulated_s_.push_back(0.0);
31}
32
33void PiecewiseQuinticSpiralPath::Append(const double theta, const double kappa,
34 const double dkappa,
35 const double delta_s) {
36 double s = delta_s + accumulated_s_.back();
37 accumulated_s_.push_back(s);
38
39 pieces_.emplace_back(last_theta_, last_kappa_, last_dkappa_, theta, kappa,
40 dkappa, delta_s);
41
42 last_theta_ = theta;
43 last_kappa_ = kappa;
44 last_dkappa_ = dkappa;
45}
46
47double PiecewiseQuinticSpiralPath::Evaluate(const std::uint32_t order,
48 const double s) const {
49 auto index = LocatePiece(s);
50 return pieces_[index].Evaluate(order, s - accumulated_s_[index]);
51}
52
53double PiecewiseQuinticSpiralPath::DeriveKappaS(const double s) const {
54 auto index = LocatePiece(s);
55 const auto& piece = pieces_[index];
56 double ratio = (s - accumulated_s_[index]) / piece.ParamLength();
57 return piece.DeriveKappaDerivative(QuinticSpiralPath::DELTA_S, ratio);
58}
59
61 return accumulated_s_.back();
62}
63
64size_t PiecewiseQuinticSpiralPath::LocatePiece(const double s) const {
65 ACHECK(s >= accumulated_s_.front() && s <= accumulated_s_.back());
66
67 auto it_lower =
68 std::lower_bound(accumulated_s_.begin(), accumulated_s_.end(), s);
69
70 if (it_lower == accumulated_s_.begin()) {
71 return 0;
72 } else {
73 return std::distance(accumulated_s_.begin(), it_lower) - 1;
74 }
75}
76
77} // namespace planning
78} // namespace apollo
PiecewiseQuinticSpiralPath(const double theta, const double kappa, const double dkappa)
double Evaluate(const std::uint32_t order, const double param) const override
void Append(const double theta, const double kappa, const double dkappa, const double delta_s)
Planning module main class.
#define ACHECK(cond)
Definition log.h:80
class register implement
Definition arena_queue.h:37