Apollo 10.0
自动驾驶开放平台
base_stage_creep.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
23#include <vector>
24
25#include "modules/planning/planning_interface_base/scenario_base/proto/creep_stage.pb.h"
26
27#include "cyber/common/log.h"
34
35namespace apollo {
36namespace planning {
37
40
42 Frame* frame, ReferenceLineInfo* reference_line_info) const {
43 CHECK_NOTNULL(frame);
44 CHECK_NOTNULL(reference_line_info);
45
46 double overlap_end_s = 0.0;
47 std::string current_overlap_id;
48 bool is_get_overlap_info = GetOverlapStopInfo(
49 frame, reference_line_info, &overlap_end_s, &current_overlap_id);
50
51 if (is_get_overlap_info) {
52 std::string virtual_obstacle_id = CREEP_VO_ID_PREFIX_ + current_overlap_id;
53 const double creep_stop_s =
54 GetCreepTargetS(overlap_end_s, *frame, *reference_line_info);
55 const std::vector<std::string> wait_for_obstacles;
56 util::BuildStopDecision(virtual_obstacle_id, creep_stop_s, 0.0,
57 StopReasonCode::STOP_REASON_CREEPER,
58 wait_for_obstacles, "CreepDecider", frame,
59 reference_line_info);
60 }
61
62 return Status::OK();
63}
64
65double BaseStageCreep::GetCreepTargetS(
66 double overlap_end_s, const Frame& frame,
67 const ReferenceLineInfo& reference_line_info) const {
68 // todo: more delicate design of creep target distance
69 return overlap_end_s + 4.0;
70}
71
73 double overlap_end_s, const Frame& frame,
74 const ReferenceLineInfo& reference_line_info) const {
75 // todo: more delicate design of creep finish distance
76 return GetCreepTargetS(overlap_end_s, frame, reference_line_info) - 2.0;
77}
78
80 const Frame& frame, const ReferenceLineInfo& reference_line_info,
81 const double traffic_sign_overlap_end_s, const double wait_time_sec,
82 const double timeout_sec) {
83 const auto& creep_config = GetCreepStageConfig();
84 bool creep_done = false;
85 double creep_stop_s =
86 GetCreepFinishS(traffic_sign_overlap_end_s, frame, reference_line_info);
87
88 const double distance =
89 creep_stop_s - reference_line_info.AdcSlBoundary().end_s();
90 if (distance < 0.0 || wait_time_sec >= timeout_sec) {
91 bool all_far_away = true;
92 for (auto* obstacle :
93 reference_line_info.path_decision().obstacles().Items()) {
94 if (obstacle->IsVirtual() || obstacle->IsStatic()) {
95 continue;
96 }
97 if (obstacle->reference_line_st_boundary().min_t() <
98 creep_config.min_boundary_t()) {
99 const double kepsilon = 1e-6;
100 double obstacle_traveled_s =
101 obstacle->reference_line_st_boundary().bottom_left_point().s() -
102 obstacle->reference_line_st_boundary().bottom_right_point().s();
103 ADEBUG << "obstacle[" << obstacle->Id() << "] obstacle_st_min_t["
104 << obstacle->reference_line_st_boundary().min_t()
105 << "] obstacle_st_min_s["
106 << obstacle->reference_line_st_boundary().min_s()
107 << "] obstacle_traveled_s[" << obstacle_traveled_s << "]";
108
109 // ignore the obstacle which is already on reference line and moving
110 // along the direction of ADC
111 if (obstacle_traveled_s < kepsilon &&
112 obstacle->reference_line_st_boundary().min_t() <
113 creep_config.ignore_max_st_min_t() &&
114 obstacle->reference_line_st_boundary().min_s() >
115 creep_config.ignore_min_st_min_s()) {
116 continue;
117 }
118 all_far_away = false;
119 break;
120 }
121 }
122 auto* creep_decider_status = injector_->planning_context()
123 ->mutable_planning_status()
124 ->mutable_creep_decider();
125 int creep_clear_counter = creep_decider_status->creep_clear_counter();
126 creep_clear_counter = all_far_away ? creep_clear_counter + 1 : 0;
127 if (creep_clear_counter >= 5) {
128 creep_clear_counter = 0; // reset
129 creep_done = true;
130 }
131 // use PlanningContext instead of static counter for multi-ADC
132 creep_decider_status->set_creep_clear_counter(creep_clear_counter);
133 }
134
135 return creep_done;
136}
137
138} // namespace planning
139} // namespace apollo
A general class to denote the return status of an API call.
Definition status.h:43
static Status OK()
generate a success status.
Definition status.h:60
double GetCreepFinishS(double overlap_end_s, const Frame &frame, const ReferenceLineInfo &reference_line_info) const
Get the postion where creeping stage finishes.
bool CheckCreepDone(const Frame &frame, const ReferenceLineInfo &reference_line_info, const double stop_sign_overlap_end_s, const double wait_time_sec, const double timeout_sec)
common::Status ProcessCreep(Frame *frame, ReferenceLineInfo *reference_line_info) const
Frame holds all data for one planning cycle.
Definition frame.h:62
const std::vector< const T * > & Items() const
List all the items in the container.
const IndexedList< std::string, Obstacle > & obstacles() const
ReferenceLineInfo holds all data for one reference line.
const SLBoundary & AdcSlBoundary() const
std::shared_ptr< DependencyInjector > injector_
Definition stage.h:91
Planning module main class.
#define ADEBUG
Definition log.h:41
int BuildStopDecision(const std::string &stop_wall_id, const double stop_line_s, const double stop_distance, const StopReasonCode &stop_reason_code, const std::vector< std::string > &wait_for_obstacles, const std::string &decision_tag, Frame *const frame, ReferenceLineInfo *const reference_line_info, double stop_wall_width)
Definition common.cc:28
class register implement
Definition arena_queue.h:37