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_'.
49 {
50 AINFO <<
"In SquareLaneFollowStage";
51 if (frame->reference_line_info().empty()) {
53 }
56 frame->mutable_open_space_info()->set_is_on_open_space_trajectory(true);
57 auto* traj_pair = frame->mutable_open_space_info()->mutable_publishable_trajectory_data();
58 static constexpr double gear_shift_max_t = 5.0;
59 static constexpr double gear_shift_unit_t = 0.1;
60 for (double t = 0.0; t < gear_shift_max_t; t += gear_shift_unit_t) {
61 common::TrajectoryPoint point;
62 point.mutable_path_point()->set_x(frame->vehicle_state().x());
63 point.mutable_path_point()->set_y(frame->vehicle_state().y());
64 point.mutable_path_point()->set_theta(frame->vehicle_state().heading());
65 point.mutable_path_point()->set_s(0.0);
66 point.mutable_path_point()->set_kappa(0);
67 point.set_relative_time(t);
68 point.set_v(0.0);
69 point.set_a(0.0);
70 traj_pair->first.emplace_back(point);
71 }
73 AINFO <<
"GEAR SHIFT TO DRIVE";
75 }
76 std::string junction_id = GetContextAs<SquareContext>()->junction_id;
78 if (result.HasError()) {
79 AERROR <<
"SquareLaneFollowStage planning error";
80 }
81 const auto& reference_line_info = frame->reference_line_info().back();
82 hdmap::PathOverlap* current_pnc_junction
84 double adc_end_s = reference_line_info.AdcSlBoundary().end_s();
85 if (!current_pnc_junction || current_pnc_junction->end_s < adc_end_s) {
87 }
88 const auto& path_data = reference_line_info.path_data();
89 bool is_path_blocked = false;
90 if (path_data.path_label().find("regular") == std::string::npos) {
91 is_path_blocked = true;
92 } else if (!path_data.blocking_obstacle_id().empty()) {
93 is_path_blocked = true;
94 } else {
95 is_path_blocked = false;
96 }
97 bool is_square_path_block = is_path_blocked && vehicle_state.
linear_velocity() < 0.1;
98
99 double trajectory_length = 0;
100 if (reference_line_info.trajectory().size() > 0) {
101 trajectory_length = reference_line_info.trajectory().back().path_point().s()
102 - reference_line_info.trajectory().front().path_point().s();
103 }
104 is_square_path_block = is_square_path_block
105 || (path_data.path_label().find(
"square") != std::string::npos && vehicle_state.
linear_velocity() < 0.1
106 && trajectory_length < 0.1);
107 if (is_square_path_block) {
108 blocking_times_ = std::min<int>(blocking_times_ + 1, 50);
109 } else {
110 blocking_times_ = 0;
111 }
112 AINFO <<
"label: " << path_data.path_label() <<
", blocking_obstacle_id: " << path_data.blocking_obstacle_id()
113 << ", is_path_blocked: " << is_path_blocked
114 <<
", vehicle_state.linear_velocity: " << vehicle_state.
linear_velocity()
115 << ", blocking_times_: " << blocking_times_;
116 if (blocking_times_ >= 50) {
117 auto* context = GetContextAs<SquareContext>();
118 context->blocking_obstacle_id = path_data.blocking_obstacle_id();
120 }
122}
StageResult FinishStage()
virtual StageResult FinishScenario()
std::shared_ptr< DependencyInjector > injector_
StageResult ExecuteTaskOnReferenceLine(const common::TrajectoryPoint &planning_start_point, Frame *frame)
optional double linear_velocity
optional apollo::canbus::Chassis::GearPosition gear