Apollo 10.0
自动驾驶开放平台
stop_sign.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 <memory>
24
29
30namespace apollo {
31namespace planning {
32
35
36bool StopSign::Init(const std::string& name,
37 const std::shared_ptr<DependencyInjector>& injector) {
38 if (!TrafficRule::Init(name, injector)) {
39 return false;
40 }
41 // Load the config this task.
42 return TrafficRule::LoadConfig<StopSignConfig>(&config_);
43}
44
46 ReferenceLineInfo* const reference_line_info) {
47 MakeDecisions(frame, reference_line_info);
48 return Status::OK();
49}
50
51void StopSign::MakeDecisions(Frame* const frame,
52 ReferenceLineInfo* const reference_line_info) {
53 CHECK_NOTNULL(frame);
54 CHECK_NOTNULL(reference_line_info);
55
56 if (!config_.enabled()) {
57 return;
58 }
59
60 const auto& stop_sign_status =
61 injector_->planning_context()->planning_status().stop_sign();
62 const double adc_back_edge_s = reference_line_info->AdcSlBoundary().start_s();
63
64 const std::vector<PathOverlap>& stop_sign_overlaps =
65 reference_line_info->reference_line().map_path().stop_sign_overlaps();
66 for (const auto& stop_sign_overlap : stop_sign_overlaps) {
67 if (stop_sign_overlap.end_s <= adc_back_edge_s) {
68 continue;
69 }
70
71 if (stop_sign_overlap.object_id ==
72 stop_sign_status.done_stop_sign_overlap_id()) {
73 continue;
74 }
75
76 // build stop decision
77 ADEBUG << "BuildStopDecision: stop_sign[" << stop_sign_overlap.object_id
78 << "] start_s[" << stop_sign_overlap.start_s << "]";
79 const std::string virtual_obstacle_id =
80 STOP_SIGN_VO_ID_PREFIX + stop_sign_overlap.object_id;
81 const std::vector<std::string> wait_for_obstacle_ids(
82 stop_sign_status.wait_for_obstacle_id().begin(),
83 stop_sign_status.wait_for_obstacle_id().end());
85 virtual_obstacle_id, stop_sign_overlap.start_s, config_.stop_distance(),
86 StopReasonCode::STOP_REASON_STOP_SIGN, wait_for_obstacle_ids, Getname(),
87 frame, reference_line_info);
88 }
89}
90
91} // namespace planning
92} // 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
const std::vector< PathOverlap > & stop_sign_overlaps() const
Definition path.h:307
Frame holds all data for one planning cycle.
Definition frame.h:62
ReferenceLineInfo holds all data for one reference line.
const ReferenceLine & reference_line() const
const SLBoundary & AdcSlBoundary() const
const hdmap::Path & map_path() const
bool Init(const std::string &name, const std::shared_ptr< DependencyInjector > &injector) override
Definition stop_sign.cc:36
common::Status ApplyRule(Frame *const frame, ReferenceLineInfo *const reference_line_info)
Definition stop_sign.cc:45
virtual bool Init(const std::string &name, const std::shared_ptr< DependencyInjector > &injector)
std::shared_ptr< DependencyInjector > injector_
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