35 if (init_)
return true;
37 AINFO <<
"Load config path:" << FLAGS_traffic_rule_config_filename;
41 AERROR <<
"Load pipeline of Traffic decider"
46 for (
int i = 0; i < rule_pipeline_.rule_size(); i++) {
56 rule->Init(rule_pipeline_.
rule(i).
name(), injector);
57 rule_list_.push_back(rule);
64void TrafficDecider::BuildPlanningTarget(
66 double min_s = std::numeric_limits<double>::infinity();
68 for (
const auto *obstacle :
69 reference_line_info->path_decision()->obstacles().Items()) {
70 if (obstacle->IsVirtual() && obstacle->HasLongitudinalDecision() &&
71 obstacle->LongitudinalDecision().has_stop() &&
72 obstacle->PerceptionSLBoundary().start_s() < min_s) {
73 min_s = obstacle->PerceptionSLBoundary().start_s();
74 const auto &stop_code =
75 obstacle->LongitudinalDecision().stop().reason_code();
76 if (stop_code == StopReasonCode::STOP_REASON_DESTINATION ||
77 stop_code == StopReasonCode::STOP_REASON_CROSSWALK ||
78 stop_code == StopReasonCode::STOP_REASON_STOP_SIGN ||
79 stop_code == StopReasonCode::STOP_REASON_YIELD_SIGN ||
80 stop_code == StopReasonCode::STOP_REASON_CREEPER ||
81 stop_code == StopReasonCode::STOP_REASON_REFERENCE_END ||
82 stop_code == StopReasonCode::STOP_REASON_SIGNAL) {
84 ADEBUG <<
"Hard stop at: " << min_s
85 <<
"REASON: " << StopReasonCode_Name(stop_code);
86 }
else if (stop_code == StopReasonCode::STOP_REASON_YELLOW_SIGNAL) {
88 ADEBUG <<
"Soft stop at: " << min_s <<
" STOP_REASON_YELLOW_SIGNAL";
90 ADEBUG <<
"No planning target found at reference line.";
94 if (min_s != std::numeric_limits<double>::infinity()) {
95 const auto &vehicle_config =
96 common::VehicleConfigHelper::Instance()->GetConfig();
97 double front_edge_to_center =
98 vehicle_config.vehicle_param().front_edge_to_center();
99 stop_point.set_s(min_s - front_edge_to_center +
100 FLAGS_virtual_stop_wall_length / 2.0);
107 CHECK_NOTNULL(frame);
108 CHECK_NOTNULL(reference_line_info);
110 for (
const auto &rule : rule_list_) {
112 AERROR <<
"Could not find rule ";
116 rule->ApplyRule(frame, reference_line_info);
117 ADEBUG <<
"Applied rule " << rule->Getname();
120 BuildPlanningTarget(reference_line_info);
A general class to denote the return status of an API call.
static Status OK()
generate a success status.
static PluginManager * Instance()
get singleton instance of PluginManager
std::shared_ptr< Base > CreateInstance(const std::string &derived_class)
create plugin instance of derived class based on Base
static std::string GetFullPlanningClassName(const std::string &class_name)
Given the class name of planning module, combine the namespace "apollo::planning::" with it to create...
Frame holds all data for one planning cycle.
ReferenceLineInfo holds all data for one reference line.
void SetLatticeStopPoint(const StopPoint &stop_point)
apollo::common::Status Execute(Frame *frame, ReferenceLineInfo *reference_line_info)
bool Init(const std::shared_ptr< DependencyInjector > &injector)
Planning module main class.
bool LoadConfig(const std::string &relative_path, T *config)
repeated PluginDeclareInfo rule