55 static constexpr double gear_shift_max_t = 5.0;
56 static constexpr double gear_shift_unit_t = 0.1;
57 for (
double t = 0.0; t < gear_shift_max_t; t += gear_shift_unit_t) {
62 point.mutable_path_point()->set_s(0.0);
63 point.mutable_path_point()->set_kappa(0);
64 point.set_relative_time(t);
67 traj_pair->first.emplace_back(point);
70 AINFO <<
"GENERATE REVERSE TRAJECTORY";
71 need_to_stop_ =
false;
75 const auto& reference_line = reference_line_info.reference_line();
76 double adc_start_s = reference_line_info.AdcSlBoundary().start_s();
78 if (stop_point_ ==
nullptr) {
81 stop_point_ = std::make_shared<common::PathPoint>(ref_point.ToPathPoint(0.0));
83 AINFO <<
"need to stop";
85 reference_line.XYToSL(*stop_point_, &sl_point);
86 std::vector<std::string> wait_for_obstacles;
91 StopReasonCode::STOP_REASON_STOP_SIGN,
98 const auto& candidate_paths = reference_line_info.GetCandidatePathData();
99 bool has_regular_path =
false;
100 for (
const auto& path_data : candidate_paths) {
101 if (path_data.path_label().find(
"regular") != std::string::npos) {
102 AINFO <<
"path_label: true";
104 double distance_to_block_obs = std::numeric_limits<double>::max();
105 if (!path_data.blocking_obstacle_id().empty()) {
106 auto obstacle = reference_line_info.path_decision()->Find(path_data.blocking_obstacle_id());
107 distance_to_block_obs
108 = obstacle->PerceptionSLBoundary().start_s() - reference_line_info.AdcSlBoundary().end_s();
109 AINFO <<
"blocking_obstacle_id: " << path_data.blocking_obstacle_id()
110 <<
" distance_to_block_obs: " << distance_to_block_obs;
113 AINFO <<
"discretized_path().Length(): true";
115 if (path_data.path_label().find(
"regular") != std::string::npos
118 AINFO <<
"find regular path: " << path_data.path_label();
119 AINFO <<
"distance_to_block_obs: " << distance_to_block_obs;
120 has_regular_path =
true;
124 if (has_regular_path) {
125 success_path_times_++;
127 success_path_times_ = 0;
129 need_to_stop_ =
false;
131 AINFO <<
"success_path_times_: " << success_path_times_;
133 && !reference_line_info.path_data().discretized_path().empty()
135 AINFO <<
"find square path change stage";
136 need_to_stop_ =
true;
138 double deceleration_distance = ego_speed * ego_speed / (2 * 0.5);
139 double stop_distance = std::min(
141 reference_line_info.mutable_path_data()->discretized_path().Length());
142 *stop_point_ = reference_line_info.mutable_path_data()->discretized_path().Evaluate(stop_distance);
143 AINFO <<
"length: " << reference_line_info.mutable_path_data()->discretized_path().Length()
144 <<
" stop_distance: " << stop_distance <<
" deceleration_distance: " << deceleration_distance
145 << std::setprecision(9) <<
"stop_point_:" << stop_point_->x() <<
"," << stop_point_->y();
147 stop_check_count_ = std::fabs(vehicle_state.
linear_velocity()) < 0.05 ? stop_check_count_ + 1 : 0;
150 AINFO <<
"already stopped change stage" << vehicle_state.
linear_velocity() <<
" " << vehicle_state.
x() <<
", "
151 << vehicle_state.
y();
152 return FinishStage();
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)