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_'.
50 {
53 frame->mutable_open_space_info()->set_is_on_open_space_trajectory(true);
54 auto* traj_pair = frame->mutable_open_space_info()->mutable_publishable_trajectory_data();
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) {
58 TrajectoryPoint point;
59 point.mutable_path_point()->set_x(frame->vehicle_state().x());
60 point.mutable_path_point()->set_y(frame->vehicle_state().y());
61 point.mutable_path_point()->set_theta(frame->vehicle_state().heading());
62 point.mutable_path_point()->set_s(0.0);
63 point.mutable_path_point()->set_kappa(0);
64 point.set_relative_time(t);
65 point.set_v(0.0);
66 point.set_a(0.0);
67 traj_pair->first.emplace_back(point);
68 }
70 AINFO <<
"GENERATE REVERSE TRAJECTORY";
71 need_to_stop_ = false;
73 }
74 auto& reference_line_info = frame->mutable_reference_line_info()->back();
75 const auto& reference_line = reference_line_info.reference_line();
76 double adc_start_s = reference_line_info.AdcSlBoundary().start_s();
77
78 if (stop_point_ == nullptr) {
81 stop_point_ = std::make_shared<common::PathPoint>(ref_point.ToPathPoint(0.0));
82 }
83 AINFO <<
"need to stop";
84 common::SLPoint sl_point;
85 reference_line.XYToSL(*stop_point_, &sl_point);
86 std::vector<std::string> wait_for_obstacles;
88 "reverse_stop",
89 sl_point.s(),
90 0.1,
91 StopReasonCode::STOP_REASON_STOP_SIGN,
92 wait_for_obstacles,
93 "reverse stop",
94 frame,
95 &(frame->mutable_reference_line_info()->front()),
96 10.0);
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";
103 }
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;
111 }
113 AINFO <<
"discretized_path().Length(): true";
114 }
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;
121 break;
122 }
123 }
124 if (has_regular_path) {
125 success_path_times_++;
126 } else {
127 success_path_times_ = 0;
129 need_to_stop_ = false;
130 }
131 AINFO <<
"success_path_times_: " << success_path_times_;
133 && !reference_line_info.path_data().discretized_path().empty()
134 && !need_to_stop_) {
135 AINFO <<
"find square path change stage";
136 need_to_stop_ = true;
137 double ego_speed = frame->vehicle_state().linear_velocity();
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();
146 }
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();
153 }
155}
Implements a class of 2-dimensional vectors.
std::shared_ptr< DependencyInjector > injector_
StageResult ExecuteTaskOnReferenceLine(const common::TrajectoryPoint &planning_start_point, Frame *frame)
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)
optional double linear_velocity
optional apollo::canbus::Chassis::GearPosition gear
optional int32 success_path_count
optional double escape_stop_distance
optional double forward_path_length
optional double escape_reverse_distance
optional int32 stop_check_window