Apollo 11.0
自动驾驶开放平台
constraint_checker.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
22
23#include "cyber/common/log.h"
25
26namespace apollo {
27namespace planning {
28
29namespace {
30template <typename T>
31bool WithinRange(const T v, const T lower, const T upper) {
32 return lower <= v && v <= upper;
33}
34} // namespace
35
37 const DiscretizedTrajectory& trajectory) {
38 const double kMaxCheckRelativeTime = FLAGS_trajectory_time_length;
39 for (const auto& p : trajectory) {
40 double t = p.relative_time();
41 if (t > kMaxCheckRelativeTime) {
42 break;
43 }
44 double lon_v = p.v();
45 if (!WithinRange(lon_v, FLAGS_speed_lower_bound, FLAGS_speed_upper_bound)) {
46 ADEBUG << "Velocity at relative time " << t
47 << " exceeds bound, value: " << lon_v << ", bound ["
48 << FLAGS_speed_lower_bound << ", " << FLAGS_speed_upper_bound
49 << "].";
51 }
52
53 double lon_a = p.a();
54 if (!WithinRange(lon_a, FLAGS_longitudinal_acceleration_lower_bound,
55 FLAGS_longitudinal_acceleration_upper_bound)) {
56 ADEBUG << "Longitudinal acceleration at relative time " << t
57 << " exceeds bound, value: " << lon_a << ", bound ["
58 << FLAGS_longitudinal_acceleration_lower_bound << ", "
59 << FLAGS_longitudinal_acceleration_upper_bound << "].";
61 }
62
63 double kappa = p.path_point().kappa();
64 if (!WithinRange(kappa, -FLAGS_kappa_bound, FLAGS_kappa_bound)) {
65 ADEBUG << "Kappa at relative time " << t
66 << " exceeds bound, value: " << kappa << ", bound ["
67 << -FLAGS_kappa_bound << ", " << FLAGS_kappa_bound << "].";
69 }
70 }
71
72 for (size_t i = 1; i < trajectory.NumOfPoints(); ++i) {
73 const auto& p0 = trajectory.TrajectoryPointAt(static_cast<uint32_t>(i - 1));
74 const auto& p1 = trajectory.TrajectoryPointAt(static_cast<uint32_t>(i));
75
76 if (p1.relative_time() > kMaxCheckRelativeTime) {
77 break;
78 }
79
80 double t = p0.relative_time();
81
82 double dt = p1.relative_time() - p0.relative_time();
83 double d_lon_a = p1.a() - p0.a();
84 double lon_jerk = d_lon_a / dt;
85 if (!WithinRange(lon_jerk, FLAGS_longitudinal_jerk_lower_bound,
86 FLAGS_longitudinal_jerk_upper_bound)) {
87 ADEBUG << "Longitudinal jerk at relative time " << t
88 << " exceeds bound, value: " << lon_jerk << ", bound ["
89 << FLAGS_longitudinal_jerk_lower_bound << ", "
90 << FLAGS_longitudinal_jerk_upper_bound << "].";
92 }
93
94 double lat_a = p1.v() * p1.v() * p1.path_point().kappa();
95 if (!WithinRange(lat_a, -FLAGS_lateral_acceleration_bound,
96 FLAGS_lateral_acceleration_bound)) {
97 ADEBUG << "Lateral acceleration at relative time " << t
98 << " exceeds bound, value: " << lat_a << ", bound ["
99 << -FLAGS_lateral_acceleration_bound << ", "
100 << FLAGS_lateral_acceleration_bound << "].";
102 }
103
104 // TODO(zhangyajia): this is temporarily disabled
105 // due to low quality reference line.
119 }
120
121 return Result::VALID;
122}
123
124} // namespace planning
125} // namespace apollo
static Result ValidTrajectory(const DiscretizedTrajectory &trajectory)
const common::TrajectoryPoint & TrajectoryPointAt(const size_t index) const
Planning module main class.
#define ADEBUG
Definition log.h:41
class register implement
Definition arena_queue.h:37