Apollo 11.0
自动驾驶开放平台
constraint_checker1d.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 {
30
31inline bool fuzzy_within(const double v, const double lower, const double upper,
32 const double e = 1.0e-4) {
33 return v > lower - e && v < upper + e;
34}
35} // namespace
36
38 const Curve1d& lon_trajectory) {
39 double t = 0.0;
40 while (t < lon_trajectory.ParamLength()) {
41 double v = lon_trajectory.Evaluate(1, t); // evaluate_v
42 if (!fuzzy_within(v, FLAGS_speed_lower_bound, FLAGS_speed_upper_bound)) {
43 return false;
44 }
45
46 double a = lon_trajectory.Evaluate(2, t); // evaluate_a
47 if (!fuzzy_within(a, FLAGS_longitudinal_acceleration_lower_bound,
48 FLAGS_longitudinal_acceleration_upper_bound)) {
49 return false;
50 }
51
52 double j = lon_trajectory.Evaluate(3, t);
53 if (!fuzzy_within(j, FLAGS_longitudinal_jerk_lower_bound,
54 FLAGS_longitudinal_jerk_upper_bound)) {
55 return false;
56 }
57 t += FLAGS_trajectory_time_resolution;
58 }
59 return true;
60}
61
63 const Curve1d& lat_trajectory, const Curve1d& lon_trajectory) {
64 double t = 0.0;
65 while (t < lon_trajectory.ParamLength()) {
66 double s = lon_trajectory.Evaluate(0, t);
67 double dd_ds = lat_trajectory.Evaluate(1, s);
68 double ds_dt = lon_trajectory.Evaluate(1, t);
69
70 double d2d_ds2 = lat_trajectory.Evaluate(2, s);
71 double d2s_dt2 = lon_trajectory.Evaluate(2, t);
72
73 double a = 0.0;
74 if (s < lat_trajectory.ParamLength()) {
75 a = d2d_ds2 * ds_dt * ds_dt + dd_ds * d2s_dt2;
76 }
77
78 if (!fuzzy_within(a, -FLAGS_lateral_acceleration_bound,
79 FLAGS_lateral_acceleration_bound)) {
80 return false;
81 }
82
83 // this is not accurate, just an approximation...
84 double j = 0.0;
85 if (s < lat_trajectory.ParamLength()) {
86 j = lat_trajectory.Evaluate(3, s) * lon_trajectory.Evaluate(3, t);
87 }
88
89 if (!fuzzy_within(j, -FLAGS_lateral_jerk_bound, FLAGS_lateral_jerk_bound)) {
90 return false;
91 }
92 t += FLAGS_trajectory_time_resolution;
93 }
94 return true;
95}
96
97} // namespace planning
98} // namespace apollo
static bool IsValidLateralTrajectory(const Curve1d &lat_trajectory, const Curve1d &lon_trajectory)
static bool IsValidLongitudinalTrajectory(const Curve1d &lon_trajectory)
virtual double ParamLength() const =0
virtual double Evaluate(const std::uint32_t order, const double param) const =0
Planning module main class.
class register implement
Definition arena_queue.h:37