Apollo 11.0
自动驾驶开放平台
quintic_spiral_path.h
浏览该文件的文档.
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
21#pragma once
22
23#include <utility>
24
25#include "cyber/common/log.h"
29
30namespace apollo {
31namespace planning {
32
38 public:
39 QuinticSpiralPath() = default;
40
41 QuinticSpiralPath(const std::array<double, 3>& start,
42 const std::array<double, 3>& end, const double delta_s);
43
44 QuinticSpiralPath(const double theta0, const double kappa0,
45 const double dkappa0, const double theta1,
46 const double kappa1, const double dkappa1,
47 const double delta_s);
48
49 template <size_t N>
50 double ComputeCartesianDeviationX(const double s) const {
51 auto cos_theta = [this](const double s) {
52 const auto a = Evaluate(0, s);
53 return std::cos(a);
54 };
55 return common::math::IntegrateByGaussLegendre<N>(cos_theta, 0.0, s);
56 }
57
58 template <size_t N>
59 double ComputeCartesianDeviationY(const double s) const {
60 auto sin_theta = [this](const double s) {
61 const auto a = Evaluate(0, s);
62 return std::sin(a);
63 };
64 return common::math::IntegrateByGaussLegendre<N>(sin_theta, 0.0, s);
65 }
66
67 template <size_t N>
68 std::pair<double, double> DeriveCartesianDeviation(
69 const size_t param_index) const {
70 auto gauss_points = common::math::GetGaussLegendrePoints<N>();
71 std::array<double, N> x = gauss_points.first;
72 std::array<double, N> w = gauss_points.second;
73
74 std::pair<double, double> cartesian_deviation = {0.0, 0.0};
75 for (size_t i = 0; i < N; ++i) {
76 double r = 0.5 * x[i] + 0.5;
77 auto curr_theta = Evaluate(0, r * param_);
78 double derived_theta = DeriveTheta(param_index, r);
79
80 cartesian_deviation.first +=
81 w[i] * (-std::sin(curr_theta)) * derived_theta;
82 cartesian_deviation.second += w[i] * std::cos(curr_theta) * derived_theta;
83 }
84
85 cartesian_deviation.first *= param_ * 0.5;
86 cartesian_deviation.second *= param_ * 0.5;
87
88 if (param_index == DELTA_S) {
89 for (size_t i = 0; i < N; ++i) {
90 double r = 0.5 * x[i] + 0.5;
91 auto theta_angle = Evaluate(0, r * param_);
92
93 cartesian_deviation.first += 0.5 * w[i] * std::cos(theta_angle);
94 cartesian_deviation.second += 0.5 * w[i] * std::sin(theta_angle);
95 }
96 }
97 return cartesian_deviation;
98 }
99
100 double DeriveKappaDerivative(const size_t param_index,
101 const double ratio) const;
102
103 double DeriveDKappaDerivative(const size_t param_index,
104 const double ratio) const;
105
106 double DeriveD2KappaDerivative(const size_t param_index,
107 const double r) const;
108
109 static const size_t THETA0 = 0;
110 static const size_t KAPPA0 = 1;
111 static const size_t DKAPPA0 = 2;
112 static const size_t THETA1 = 3;
113 static const size_t KAPPA1 = 4;
114 static const size_t DKAPPA1 = 5;
115 static const size_t DELTA_S = 6;
116
117 private:
118 double DeriveTheta(const size_t param_index,
119 const double delta_s_ratio) const;
120
121 std::array<std::array<double, 7>, 6> coef_deriv_;
122};
123
124} // namespace planning
125} // namespace apollo
Defines the templated Angle class.
double Evaluate(const std::uint32_t order, const double p) const override
Describe a quintic spiral path Map (theta0, kappa0, dkappa0) --— delta_s --—> (theta1,...
double ComputeCartesianDeviationX(const double s) const
double DeriveKappaDerivative(const size_t param_index, const double ratio) const
double DeriveD2KappaDerivative(const size_t param_index, const double r) const
double DeriveDKappaDerivative(const size_t param_index, const double ratio) const
std::pair< double, double > DeriveCartesianDeviation(const size_t param_index) const
double ComputeCartesianDeviationY(const double s) const
Planning module main class.
Functions to compute integral.
class register implement
Definition arena_queue.h:37