Apollo
11.0
自动驾驶开放平台
discretized_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
#include "
modules/planning/planning_base/common/path/discretized_path.h
"
22
23
#include <algorithm>
24
25
#include "
cyber/common/log.h
"
26
#include "
modules/common/math/linear_interpolation.h
"
27
28
namespace
apollo
{
29
namespace
planning
{
30
31
using
apollo::common::PathPoint
;
32
33
DiscretizedPath::DiscretizedPath
(std::vector<PathPoint> path_points)
34
:
std
::vector<
PathPoint
>(
std
::move(path_points)) {}
35
36
double
DiscretizedPath::Length
()
const
{
37
if
(empty()) {
38
return
0.0;
39
}
40
return
back().
s
() - front().s();
41
}
42
43
PathPoint
DiscretizedPath::Evaluate
(
const
double
path_s)
const
{
44
ACHECK
(!empty());
45
auto
it_lower =
QueryLowerBound
(path_s);
46
if
(it_lower == begin()) {
47
return
front();
48
}
49
if
(it_lower == end()) {
50
return
back();
51
}
52
return
common::math::InterpolateUsingLinearApproximation
(*(it_lower - 1),
53
*it_lower, path_s);
54
}
55
56
std::vector<PathPoint>::const_iterator
DiscretizedPath::QueryLowerBound
(
57
const
double
path_s)
const
{
58
auto
func = [](
const
PathPoint
&tp,
const
double
path_s) {
59
return
tp.
s
() < path_s;
60
};
61
return
std::lower_bound(begin(), end(), path_s, func);
62
}
63
64
PathPoint
DiscretizedPath::EvaluateReverse
(
const
double
path_s)
const
{
65
ACHECK
(!empty());
66
auto
it_upper =
QueryUpperBound
(path_s);
67
if
(it_upper == begin()) {
68
return
front();
69
}
70
if
(it_upper == end()) {
71
return
back();
72
}
73
return
common::math::InterpolateUsingLinearApproximation
(*(it_upper - 1),
74
*it_upper, path_s);
75
}
76
77
std::vector<PathPoint>::const_iterator
DiscretizedPath::QueryUpperBound
(
78
const
double
path_s)
const
{
79
auto
func = [](
const
double
path_s,
const
PathPoint
&tp) {
80
return
tp.s() < path_s;
81
};
82
return
std::upper_bound(begin(), end(), path_s, func);
83
}
84
85
}
// namespace planning
86
}
// namespace apollo
apollo::planning::DiscretizedPath::EvaluateReverse
common::PathPoint EvaluateReverse(const double path_s) const
Definition
discretized_path.cc:64
apollo::planning::DiscretizedPath::DiscretizedPath
DiscretizedPath()=default
apollo::planning::DiscretizedPath::QueryUpperBound
std::vector< common::PathPoint >::const_iterator QueryUpperBound(const double path_s) const
Definition
discretized_path.cc:77
apollo::planning::DiscretizedPath::QueryLowerBound
std::vector< common::PathPoint >::const_iterator QueryLowerBound(const double path_s) const
Definition
discretized_path.cc:56
apollo::planning::DiscretizedPath::Evaluate
common::PathPoint Evaluate(const double path_s) const
Definition
discretized_path.cc:43
apollo::planning::DiscretizedPath::Length
double Length() const
Definition
discretized_path.cc:36
planning
Planning module main class.
discretized_path.h
linear_interpolation.h
Linear interpolation functions.
log.h
ACHECK
#define ACHECK(cond)
Definition
log.h:80
apollo::common::math::InterpolateUsingLinearApproximation
SLPoint InterpolateUsingLinearApproximation(const SLPoint &p0, const SLPoint &p1, const double w)
Definition
linear_interpolation.cc:48
apollo
class register implement
Definition
arena_queue.h:37
std
Definition
future.h:29
apollo::common::PathPoint
Definition
pnc_point.proto:31
apollo::common::PathPoint::s
optional double s
Definition
pnc_point.proto:42
modules
planning
planning_base
common
path
discretized_path.cc