Each stage does its business logic inside Process function.
If the stage want to transit to a different stage after finish, it should set the type of 'next_stage_'.
41 {
42 ADEBUG <<
"stage: Approach";
43 CHECK_NOTNULL(frame);
45
46 const ScenarioPullOverConfig& scenario_config =
47 GetContextAs<PullOverContext>()->scenario_config;
48
50 if (result.HasError()) {
51 AERROR <<
"PullOverStageApproach planning error";
52 }
53
54 const auto& reference_line_info = frame->reference_line_info().front();
57 scenario_config,
injector_->planning_context());
58
61 return FinishStage(true);
63 return FinishStage(false);
64 }
65
66
67 bool path_fail = false;
68 const auto& candidate_path_data = reference_line_info.GetCandidatePathData();
69 if (!candidate_path_data.empty()) {
70 for (const auto& path_data : candidate_path_data) {
71 if (path_data.path_label().find("pullover") == std::string::npos) {
72 break;
73 }
74
75 const double min_distance_to_end = FLAGS_path_bounds_decider_resolution *
76 FLAGS_num_extra_tail_bound_point;
77 for (size_t i = path_data.discretized_path().size(); i >= 1; --i) {
78 if (path_data.frenet_frame_path().back().s() -
79 path_data.frenet_frame_path()[i - 1].s() <
80 min_distance_to_end) {
81 continue;
82 }
83
84 const auto& path_point = path_data.discretized_path()[i];
86 reference_line_info, scenario_config, path_point,
89 path_fail = true;
90 }
91 break;
92 }
93 }
94 }
95
96
97 if (path_fail) {
98 const auto& pull_over_status =
99 injector_->planning_context()->planning_status().pull_over();
100 if (pull_over_status.has_position() &&
101 pull_over_status.position().has_x() &&
102 pull_over_status.position().has_y()) {
103 const auto& reference_line = reference_line_info.reference_line();
104 common::SLPoint pull_over_sl;
105 reference_line.XYToSL(pull_over_status.position(), &pull_over_sl);
106
107 const double stop_line_s =
108 pull_over_sl.s() -
109 scenario_config.s_distance_to_stop_for_open_space_parking();
110 const std::string virtual_obstacle_id = "DEST_PULL_OVER_PREPARKING";
111 const std::vector<std::string> wait_for_obstacle_ids;
113 virtual_obstacle_id, stop_line_s, 1.0,
114 StopReasonCode::STOP_REASON_PREPARKING, wait_for_obstacle_ids,
115 "PULL-OVER-scenario", frame,
116 &(frame->mutable_reference_line_info()->front()));
117
118 ADEBUG <<
"Build a stop fence to pause ADC at a better position: id["
119 << virtual_obstacle_id << "] s[" << stop_line_s << "]";
120
121 const double adc_front_edge_s =
122 reference_line_info.AdcSlBoundary().end_s();
123 double distance = stop_line_s - adc_front_edge_s;
124 static constexpr double kPreparkingStopDistance = 1.0;
125 static constexpr double kPreparkingAngleDiff = 0.2;
126 auto ref_point = reference_line.GetReferencePoint(adc_front_edge_s);
128 ref_point.heading());
129 if (distance <= kPreparkingStopDistance &&
130 angle <= kPreparkingAngleDiff) {
131 return FinishStage(false);
132 }
133 }
134 }
135
137}
std::shared_ptr< DependencyInjector > injector_
StageResult ExecuteTaskOnReferenceLine(const common::TrajectoryPoint &planning_start_point, Frame *frame)
double AngleDiff(const double from, const double to)
Calculate the difference between angle from and to
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)
PullOverState CheckADCPullOver(const common::VehicleStateProvider *vehicle_state_provider, const ReferenceLineInfo &reference_line_info, const ScenarioPullOverConfig &scenario_config, const PlanningContext *planning_context)
: check adc parked properly
PullOverState CheckADCPullOverPathPoint(const ReferenceLineInfo &reference_line_info, const ScenarioPullOverConfig &scenario_config, const common::PathPoint &path_point, const PlanningContext *planning_context)
: check path data to see properly