Apollo 10.0
自动驾驶开放平台
frenet_frame_path.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
21
22#include <algorithm>
23#include <limits>
24
25#include "cyber/common/log.h"
27
28namespace apollo {
29namespace planning {
30
32
33FrenetFramePath::FrenetFramePath(std::vector<FrenetFramePoint> points)
34 : std::vector<FrenetFramePoint>(std::move(points)) {}
35
37 if (empty()) {
38 return 0.0;
39 }
40 return back().s() - front().s();
41}
42
44 auto it_lower =
45 std::lower_bound(begin(), end(), sl.start_s(), LowerBoundComparator);
46 if (it_lower == end()) {
47 return back();
48 }
49 auto it_upper =
50 std::upper_bound(it_lower, end(), sl.end_s(), UpperBoundComparator);
51 double min_dist = std::numeric_limits<double>::max();
52 auto min_it = it_upper;
53 for (auto it = it_lower; it != it_upper; ++it) {
54 if (it->l() >= sl.start_l() && it->l() <= sl.end_l()) {
55 return *it;
56 } else if (it->l() > sl.end_l()) {
57 double diff = it->l() - sl.end_l();
58 if (diff < min_dist) {
59 min_dist = diff;
60 min_it = it;
61 }
62 } else {
63 double diff = sl.start_l() - it->l();
64 if (diff < min_dist) {
65 min_dist = diff;
66 min_it = it;
67 }
68 }
69 }
70 return *min_it;
71}
72
74 CHECK_GT(size(), 1U);
75 auto it_lower = std::lower_bound(begin(), end(), s, LowerBoundComparator);
76 if (it_lower == begin()) {
77 return front();
78 } else if (it_lower == end()) {
79 return back();
80 }
81 const auto& p0 = *(it_lower - 1);
82 const auto s0 = p0.s();
83 const auto& p1 = *it_lower;
84 const auto s1 = p1.s();
85
87 p.set_s(s);
88 p.set_l(common::math::lerp(p0.l(), s0, p1.l(), s1, s));
89 p.set_dl(common::math::lerp(p0.dl(), s0, p1.dl(), s1, s));
90 p.set_ddl(common::math::lerp(p0.ddl(), s0, p1.ddl(), s1, s));
91 return p;
92}
93
94} // namespace planning
95} // namespace apollo
common::FrenetFramePoint GetNearestPoint(const SLBoundary &sl) const
Get the FrenetFramePoint that is within SLBoundary, or the one with smallest l() in SLBoundary's s ra...
common::FrenetFramePoint EvaluateByS(const double s) const
Planning module main class.
Linear interpolation functions.
T lerp(const T &x0, const double t0, const T &x1, const double t1, const double t)
Linear interpolation between two points of type T.
class register implement
Definition arena_queue.h:37
Definition future.h:29