Apollo 10.0
自动驾驶开放平台
apollo::planning::TrafficLightProtectedScenario类 参考

#include <traffic_light_protected_scenario.h>

类 apollo::planning::TrafficLightProtectedScenario 继承关系图:
apollo::planning::TrafficLightProtectedScenario 的协作图:

Public 成员函数

bool Init (std::shared_ptr< DependencyInjector > injector, const std::string &name) override
 
TrafficLightProtectedContextGetContext () override
 Get the scenario context.
 
bool IsTransferable (const Scenario *const other_scenario, const Frame &frame) override
 Each scenario should define its own transfer condition, i.e., when it should allow to transfer from other scenario to itself.
 
bool Exit (Frame *frame) override
 
bool Enter (Frame *frame) override
 
- Public 成员函数 继承自 apollo::planning::Scenario
 Scenario ()
 
virtual ~Scenario ()=default
 
virtual ScenarioResult Process (const common::TrajectoryPoint &planning_init_point, Frame *frame)
 
std::shared_ptr< StageCreateStage (const StagePipeline &stage_pipeline)
 Each scenario should define its own stages object's creation scenario will call stage's Stage::Process function following a configured order, The return value of Stage::Process function determines the transition from one stage to another.
 
const ScenarioStatusTypeGetStatus () const
 
const std::string GetStage () const
 
const std::string & GetMsg () const
 
const std::string & Name () const
 
void Reset ()
 Reset the scenario, used before entering the scenario.
 

额外继承的成员函数

- Protected 成员函数 继承自 apollo::planning::Scenario
template<typename T >
bool LoadConfig (T *config)
 
- Protected 属性 继承自 apollo::planning::Scenario
ScenarioResult scenario_result_
 
std::shared_ptr< Stagecurrent_stage_
 
std::unordered_map< std::string, const StagePipeline * > stage_pipeline_map_
 
std::string msg_
 
std::shared_ptr< DependencyInjectorinjector_
 
std::string config_path_
 
std::string config_dir_
 
std::string name_
 
ScenarioPipeline scenario_pipeline_config_
 

详细描述

在文件 traffic_light_protected_scenario.h37 行定义.

成员函数说明

◆ Enter()

bool apollo::planning::TrafficLightProtectedScenario::Enter ( Frame frame)
overridevirtual

重载 apollo::planning::Scenario .

在文件 traffic_light_protected_scenario.cc138 行定义.

138 {
139 injector_->planning_context()
140 ->mutable_planning_status()
141 ->mutable_traffic_light()
142 ->Clear();
143 if (context_.current_traffic_light_overlap_ids.empty()) {
144 AERROR << "Can not find traffic light overlap in reference line!";
145 return false;
146 }
147 for (const auto& overlap_id : context_.current_traffic_light_overlap_ids) {
148 injector_->planning_context()
149 ->mutable_planning_status()
150 ->mutable_traffic_light()
151 ->add_current_traffic_light_overlap_id(overlap_id);
152 }
153 return true;
154}
std::shared_ptr< DependencyInjector > injector_
Definition scenario.h:113
#define AERROR
Definition log.h:44
std::vector< std::string > current_traffic_light_overlap_ids
Definition context.h:32

◆ Exit()

bool apollo::planning::TrafficLightProtectedScenario::Exit ( Frame frame)
overridevirtual

重载 apollo::planning::Scenario .

在文件 traffic_light_protected_scenario.cc130 行定义.

130 {
131 injector_->planning_context()
132 ->mutable_planning_status()
133 ->mutable_traffic_light()
134 ->Clear();
135 return true;
136}

◆ GetContext()

TrafficLightProtectedContext * apollo::planning::TrafficLightProtectedScenario::GetContext ( )
inlineoverridevirtual

Get the scenario context.

实现了 apollo::planning::Scenario.

在文件 traffic_light_protected_scenario.h45 行定义.

45{ return &context_; }

◆ Init()

bool apollo::planning::TrafficLightProtectedScenario::Init ( std::shared_ptr< DependencyInjector injector,
const std::string &  name 
)
overridevirtual

重载 apollo::planning::Scenario .

在文件 traffic_light_protected_scenario.cc36 行定义.

37 {
38 if (init_) {
39 return true;
40 }
41
42 if (!Scenario::Init(injector, name)) {
43 AERROR << "failed to init scenario" << Name();
44 return false;
45 }
46
47 if (!Scenario::LoadConfig<ScenarioTrafficLightProtectedConfig>(
48 &context_.scenario_config)) {
49 AERROR << "fail to get specific config of scenario " << Name();
50 return false;
51 }
52 init_ = true;
53 return true;
54}
virtual bool Init(std::shared_ptr< DependencyInjector > injector, const std::string &name)
Definition scenario.cc:43
const std::string & Name() const
Definition scenario.h:98
ScenarioTrafficLightProtectedConfig scenario_config
Definition context.h:31

◆ IsTransferable()

bool apollo::planning::TrafficLightProtectedScenario::IsTransferable ( const Scenario *const  other_scenario,
const Frame frame 
)
overridevirtual

Each scenario should define its own transfer condition, i.e., when it should allow to transfer from other scenario to itself.

重载 apollo::planning::Scenario .

在文件 traffic_light_protected_scenario.cc56 行定义.

57 {
58 if (!frame.local_view().planning_command->has_lane_follow_command()) {
59 return false;
60 }
61 if (other_scenario == nullptr || frame.reference_line_info().empty()) {
62 return false;
63 }
64 const auto& reference_line_info = frame.reference_line_info().front();
65 const auto& first_encountered_overlaps =
66 reference_line_info.FirstEncounteredOverlaps();
67 hdmap::PathOverlap* traffic_sign_overlap = nullptr;
68 for (const auto& overlap : first_encountered_overlaps) {
69 if (overlap.first == ReferenceLineInfo::STOP_SIGN ||
70 overlap.first == ReferenceLineInfo::YIELD_SIGN) {
71 return false;
72 } else if (overlap.first == ReferenceLineInfo::SIGNAL) {
73 traffic_sign_overlap = const_cast<hdmap::PathOverlap*>(&overlap.second);
74 break;
75 }
76 }
77 if (traffic_sign_overlap == nullptr) {
78 return false;
79 }
80 const std::vector<hdmap::PathOverlap>& traffic_light_overlaps =
81 reference_line_info.reference_line().map_path().signal_overlaps();
82 const double start_check_distance =
84 const double adc_front_edge_s = reference_line_info.AdcSlBoundary().end_s();
85 // find all the traffic light belong to
86 // the same group as first encountered traffic light
87 std::vector<hdmap::PathOverlap> next_traffic_lights;
88 static constexpr double kTrafficLightGroupingMaxDist = 2.0; // unit: m
89 for (const auto& overlap : traffic_light_overlaps) {
90 const double dist = overlap.start_s - traffic_sign_overlap->start_s;
91 if (fabs(dist) <= kTrafficLightGroupingMaxDist) {
92 next_traffic_lights.push_back(overlap);
93 }
94 }
95 bool traffic_light_scenario = false;
96 // note: need iterate all lights to check no RED/YELLOW/UNKNOWN
97 for (const auto& overlap : next_traffic_lights) {
98 const double adc_distance_to_traffic_light =
99 overlap.start_s - adc_front_edge_s;
100 ADEBUG << "traffic_light[" << overlap.object_id << "] start_s["
101 << overlap.start_s << "] adc_distance_to_traffic_light["
102 << adc_distance_to_traffic_light << "]";
103
104 // enter traffic-light scenarios: based on distance only
105 if (adc_distance_to_traffic_light <= 0.0 ||
106 adc_distance_to_traffic_light > start_check_distance) {
107 continue;
108 }
109
110 const auto& signal_color = frame.GetSignal(overlap.object_id).color();
111 ADEBUG << "traffic_light_id[" << overlap.object_id << "] start_s["
112 << overlap.start_s << "] color[" << signal_color << "]";
113
114 if (signal_color != perception::TrafficLight::GREEN &&
115 signal_color != perception::TrafficLight::BLACK) {
116 traffic_light_scenario = true;
117 break;
118 }
119 }
120 if (!traffic_light_scenario) {
121 return false;
122 }
123 context_.current_traffic_light_overlap_ids.clear();
124 for (const auto& overlap : next_traffic_lights) {
125 context_.current_traffic_light_overlap_ids.push_back(overlap.object_id);
126 }
127 return true;
128}
#define ADEBUG
Definition log.h:41

该类的文档由以下文件生成: