23#include "modules/common_msgs/perception_msgs/perception_obstacle.pb.h"
24#include "modules/planning/planning_base/proto/planning_config.pb.h"
42 std::unordered_map<std::string, std::vector<std::string>>;
45 std::shared_ptr<DependencyInjector> injector,
const std::string& name) {
51 if (!Scenario::LoadConfig<ScenarioStopSignUnprotectedConfig>(
53 AERROR <<
"Fail to get config of scenario " <<
Name();
62int StopSignUnprotectedScenario::GetAssociatedLanes(
66 std::vector<StopSignInfoConstPtr> associated_stop_signs;
68 &associated_stop_signs);
70 for (
const auto stop_sign : associated_stop_signs) {
71 if (stop_sign ==
nullptr) {
75 const auto& associated_lane_ids = stop_sign->OverlapLaneIds();
76 for (
const auto& lane_id : associated_lane_ids) {
78 if (lane ==
nullptr) {
81 for (
const auto& stop_sign_overlap : lane->stop_signs()) {
83 stop_sign_overlap->GetObjectOverlapInfo(stop_sign.get()->id());
84 if (over_lap_info !=
nullptr) {
86 std::make_pair(lane, stop_sign_overlap));
87 ADEBUG <<
"stop_sign: " << stop_sign_info.
id().
id()
88 <<
"; associated_lane: " << lane_id.id()
89 <<
"; associated_stop_sign: " << stop_sign.get()->id().id();
107 const auto& first_encountered_overlaps =
108 reference_line_info.FirstEncounteredOverlaps();
111 for (
const auto& overlap : first_encountered_overlaps) {
120 if (stop_sign_overlap ==
nullptr) {
123 const double adc_front_edge_s = reference_line_info.AdcSlBoundary().
end_s();
124 const double adc_distance_to_stop_sign =
125 stop_sign_overlap->
start_s - adc_front_edge_s;
126 ADEBUG <<
"adc_distance_to_stop_sign[" << adc_distance_to_stop_sign
127 <<
"] stop_sign[" << stop_sign_overlap->
object_id
128 <<
"] stop_sign_overlap_start_s[" << stop_sign_overlap->
start_s <<
"]";
129 const bool stop_sign_scenario =
130 (adc_distance_to_stop_sign > 0.0 &&
131 adc_distance_to_stop_sign <=
134 return stop_sign_scenario;
139 ->mutable_planning_status()
140 ->mutable_stop_sign()
147 std::string current_stop_sign_overlap_id;
148 const auto& overlaps = reference_line_info.FirstEncounteredOverlaps();
149 for (
auto overlap : overlaps) {
151 current_stop_sign_overlap_id = overlap.second.object_id;
156 if (current_stop_sign_overlap_id.empty()) {
158 ->mutable_planning_status()
159 ->mutable_stop_sign()
161 AERROR <<
"Can not find stop sign overlap in refline";
165 const std::vector<hdmap::PathOverlap>& stop_sign_overlaps =
166 reference_line_info.reference_line().map_path().stop_sign_overlaps();
167 auto stop_sign_overlap_itr = std::find_if(
168 stop_sign_overlaps.begin(), stop_sign_overlaps.end(),
170 return overlap.object_id == current_stop_sign_overlap_id;
173 if (stop_sign_overlap_itr != stop_sign_overlaps.end()) {
175 ->mutable_planning_status()
176 ->mutable_stop_sign()
177 ->set_current_stop_sign_overlap_id(current_stop_sign_overlap_id);
178 ADEBUG <<
"Update PlanningContext with first_encountered stop sign["
179 << current_stop_sign_overlap_id <<
"] start_s["
180 << stop_sign_overlap_itr->start_s <<
"]";
182 AERROR <<
"Can not find stop sign overlap " << current_stop_sign_overlap_id;
189 AERROR <<
"Could not find stop sign: " << current_stop_sign_overlap_id;
195 GetAssociatedLanes(*stop_sign);
static const HDMap & BaseMap()
StopSignInfoConstPtr GetStopSignById(const Id &id) const
LaneInfoConstPtr GetLaneById(const Id &id) const
int GetStopSignAssociatedStopSigns(const Id &id, std::vector< StopSignInfoConstPtr > *stop_signs) const
get all other stop signs associated with a stop sign in the same junction
Frame holds all data for one planning cycle.
const LocalView & local_view() const
const std::list< ReferenceLineInfo > & reference_line_info() const
virtual bool Init(std::shared_ptr< DependencyInjector > injector, const std::string &name)
std::shared_ptr< DependencyInjector > injector_
const std::string & Name() const
bool Init(std::shared_ptr< DependencyInjector > injector, const std::string &name) override
bool Enter(Frame *frame) override
bool Exit(Frame *frame) override
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 o...
Planning module main class.
apollo::hdmap::Id MakeMapId(const std::string &id)
create a Map ID given a string.
std::shared_ptr< const StopSignInfo > StopSignInfoConstPtr
std::unordered_map< std::string, std::vector< std::string > > StopSignLaneVehicles
std::shared_ptr< PlanningCommand > planning_command
optional double start_stop_sign_scenario_distance
std::vector< std::pair< hdmap::LaneInfoConstPtr, hdmap::OverlapInfoConstPtr > > associated_lanes
std::unordered_map< std::string, std::vector< std::string > > watch_vehicles
std::string current_stop_sign_overlap_id
ScenarioStopSignUnprotectedConfig scenario_config