Apollo 11.0
自动驾驶开放平台
feasible_region.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 <cmath>
24
25#include "cyber/common/log.h"
27
28namespace apollo {
29namespace planning {
30
31FeasibleRegion::FeasibleRegion(const std::array<double, 3>& init_s) {
32 init_s_ = init_s;
33
34 double v = init_s[1];
35 CHECK_GE(v, 0.0);
36
37 const double max_deceleration = -FLAGS_longitudinal_acceleration_lower_bound;
38 t_at_zero_speed_ = v / max_deceleration;
39 s_at_zero_speed_ = init_s[0] + v * v / (2.0 * max_deceleration);
40}
41
42double FeasibleRegion::SUpper(const double t) const {
43 ACHECK(t >= 0.0);
44 return init_s_[0] + init_s_[1] * t +
45 0.5 * FLAGS_longitudinal_acceleration_upper_bound * t * t;
46}
47
48double FeasibleRegion::SLower(const double t) const {
49 if (t < t_at_zero_speed_) {
50 return init_s_[0] + init_s_[1] * t +
51 0.5 * FLAGS_longitudinal_acceleration_lower_bound * t * t;
52 }
53 return s_at_zero_speed_;
54}
55
56double FeasibleRegion::VUpper(const double t) const {
57 return init_s_[1] + FLAGS_longitudinal_acceleration_upper_bound * t;
58}
59
60double FeasibleRegion::VLower(const double t) const {
61 return t < t_at_zero_speed_
62 ? init_s_[1] + FLAGS_longitudinal_acceleration_lower_bound * t
63 : 0.0;
64}
65
66double FeasibleRegion::TLower(const double s) const {
67 ACHECK(s >= init_s_[0]);
68
69 double delta_s = s - init_s_[0];
70 double v = init_s_[1];
71 double a = FLAGS_longitudinal_acceleration_upper_bound;
72 double t = (std::sqrt(v * v + 2.0 * a * delta_s) - v) / a;
73 return t;
74}
75
76} // namespace planning
77} // namespace apollo
double VLower(const double t) const
double TLower(const double s) const
double SLower(const double t) const
FeasibleRegion(const std::array< double, 3 > &init_s)
double SUpper(const double t) const
double VUpper(const double t) const
Planning module main class.
#define ACHECK(cond)
Definition log.h:80
class register implement
Definition arena_queue.h:37