Apollo 11.0
自动驾驶开放平台
st_driving_limits.cc
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2019 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
23namespace apollo {
24namespace planning {
25
26void STDrivingLimits::Init(const double max_acc, const double max_dec,
27 const double max_v, double curr_v) {
28 max_acc_ = max_acc;
29 max_dec_ = max_dec;
30 max_v_ = max_v;
31 upper_t0_ = 0.0;
32 upper_v0_ = curr_v;
33 upper_s0_ = 0.0;
34 lower_t0_ = 0.0;
35 lower_v0_ = curr_v;
36 lower_s0_ = 0.0;
37}
38
40 const double t) const {
41 std::pair<double, double> dynamic_limits;
42 // Process lower bound: (constant deceleration)
43 double dec_time = lower_v0_ / max_dec_;
44 if (t - lower_t0_ < dec_time) {
45 dynamic_limits.first =
46 lower_s0_ + (lower_v0_ - max_dec_ * (t - lower_t0_) + lower_v0_) *
47 (t - lower_t0_) * 0.5;
48 } else {
49 dynamic_limits.first = lower_s0_ + (lower_v0_ * dec_time) * 0.5;
50 }
51
52 // Process upper bound: (constant acceleration)
53 double acc_time = (max_v_ - upper_v0_) / max_acc_;
54 if (t - upper_t0_ < acc_time) {
55 dynamic_limits.second =
56 upper_s0_ + (upper_v0_ + max_acc_ * (t - upper_t0_) + upper_v0_) *
57 (t - upper_t0_) * 0.5;
58 } else {
59 dynamic_limits.second = upper_s0_ + (upper_v0_ + max_v_) * acc_time * 0.5 +
60 (t - upper_t0_ - acc_time) * max_v_;
61 }
62
63 return dynamic_limits;
64}
65
66void STDrivingLimits::UpdateBlockingInfo(const double t, const double lower_s,
67 const double lower_v,
68 const double upper_s,
69 const double upper_v) {
70 auto curr_bounds = GetVehicleDynamicsLimits(t);
71 if (curr_bounds.first < lower_s) {
72 // lower_v0_ = std::fmax(lower_v, 0.0);
73 lower_v0_ = std::fmax(0.0, lower_v0_ - max_dec_ * (t - lower_t0_));
74 lower_t0_ = t;
75 lower_s0_ = lower_s;
76 }
77 if (curr_bounds.second > upper_s) {
78 // upper_v0_ = std::fmax(upper_v, 0.0);
79 upper_v0_ = std::fmin(max_v_, upper_v0_ + max_acc_ * (t - upper_t0_));
80 upper_t0_ = t;
81 upper_s0_ = upper_s;
82 }
83}
84
85} // namespace planning
86} // namespace apollo
void Init(const double max_acc, const double max_dec, const double max_v, double curr_v)
std::pair< double, double > GetVehicleDynamicsLimits(const double t) const
Given time t, calculate the driving limits in s due to vehicle's dynamics.
void UpdateBlockingInfo(const double t, const double lower_s, const double lower_v, const double upper_s, const double upper_v)
Update the anchoring of the vehicle dynamics limits.
Planning module main class.
class register implement
Definition arena_queue.h:37