Apollo 11.0
自动驾驶开放平台
st_guide_line.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
26constexpr double kSpeedGuideLineResolution = 0.1;
27
28void STGuideLine::Init(double desired_v) {
29 s0_ = 0.0;
30 t0_ = 0.0;
31 v0_ = desired_v;
32}
33
35 double desired_v,
36 const std::vector<common::TrajectoryPoint> &speed_reference) {
37 s0_ = 0.0;
38 t0_ = 0.0;
39 v0_ = desired_v;
40 DiscretizedTrajectory discrete_speed_reference(speed_reference);
41 double total_time = discrete_speed_reference.GetTemporalLength();
42 guideline_speed_data_.clear();
43 for (double t = 0; t <= total_time; t += kSpeedGuideLineResolution) {
44 const common::TrajectoryPoint trajectory_point =
45 discrete_speed_reference.Evaluate(t);
46 guideline_speed_data_.AppendSpeedPoint(
47 trajectory_point.path_point().s(), trajectory_point.relative_time(),
48 trajectory_point.v(), trajectory_point.a(), trajectory_point.da());
49 }
50}
51
53 common::SpeedPoint speed_point;
54 if (t < guideline_speed_data_.TotalTime() &&
55 guideline_speed_data_.EvaluateByTime(t, &speed_point)) {
56 s0_ = speed_point.s();
57 t0_ = t;
58 return speed_point.s();
59 }
60 return s0_ + (t - t0_) * v0_;
61}
62
63void STGuideLine::UpdateBlockingInfo(const double t, const double s_block,
64 const bool is_lower_block) {
65 if (is_lower_block) {
66 if (GetGuideSFromT(t) < s_block) {
67 s0_ = s_block;
68 t0_ = t;
69 }
70 } else {
71 if (GetGuideSFromT(t) > s_block) {
72 s0_ = s_block;
73 t0_ = t;
74 }
75 }
76}
77
78} // namespace planning
79} // namespace apollo
virtual common::TrajectoryPoint Evaluate(const double relative_time) const
void Init(double desired_v)
void UpdateBlockingInfo(const double t, const double s_block, const bool is_lower_block)
void AppendSpeedPoint(const double s, const double time, const double v, const double a, const double da)
Definition speed_data.cc:48
bool EvaluateByTime(const double time, common::SpeedPoint *const speed_point) const
Definition speed_data.cc:60
Planning module main class.
constexpr double kSpeedGuideLineResolution
class register implement
Definition arena_queue.h:37