63 if (!FLAGS_enable_pull_over_at_destination) {
67 if (
nullptr == routing_end) {
72 const auto& reference_line = reference_line_info.reference_line();
73 reference_line.XYToSL(routing_end->pose(), &dest_sl);
74 if (!reference_line.IsOnLane(dest_sl)) {
77 const double adc_front_edge_s = reference_line_info.AdcSlBoundary().end_s();
79 const double adc_distance_to_dest = dest_sl.
s() - adc_front_edge_s;
80 ADEBUG <<
"adc_distance_to_dest[" << adc_distance_to_dest
81 <<
"] destination_s[" << dest_sl.
s() <<
"] adc_front_edge_s["
82 << adc_front_edge_s <<
"]";
84 bool pull_over_scenario =
86 adc_distance_to_dest >=
88 adc_distance_to_dest <=
91 if (pull_over_scenario) {
92 if (adc_distance_to_dest <
94 pull_over_scenario =
false;
98 auto first_encountered_overlaps =
100 if (pull_over_scenario) {
101 static constexpr double kDistanceToAvoidJunction = 8.0;
102 for (
const auto& overlap : first_encountered_overlaps) {
107 const double distance_to = overlap.second.start_s - dest_sl.
s();
108 const double distance_passed = dest_sl.
s() - overlap.second.end_s;
109 if ((distance_to > 0.0 && distance_to < kDistanceToAvoidJunction) ||
110 (distance_passed > 0.0 &&
111 distance_passed < kDistanceToAvoidJunction)) {
112 pull_over_scenario =
false;
120 if (pull_over_scenario) {
121 double check_s = adc_front_edge_s;
122 static constexpr double kDistanceUnit = 5.0;
123 while (check_s < dest_sl.
s()) {
124 check_s += kDistanceUnit;
126 std::vector<hdmap::LaneInfoConstPtr> lanes;
127 reference_line.GetLaneFromS(check_s, &lanes);
129 ADEBUG <<
"check_s[" << check_s <<
"] can't find a lane";
133 const std::string lane_id = lane->lane().id().id();
134 ADEBUG <<
"check_s[" << check_s <<
"] lane[" << lane_id <<
"]";
137 bool rightmost_driving_lane =
true;
138 for (
const auto& neighbor_lane_id :
139 lane->lane().right_neighbor_forward_lane_id()) {
141 CHECK_NOTNULL(hdmap_ptr);
142 const auto neighbor_lane = hdmap_ptr->GetLaneById(neighbor_lane_id);
143 if (neighbor_lane ==
nullptr) {
144 AWARN <<
"Failed to find neighbor lane[" << neighbor_lane_id.id()
148 const auto& lane_type = neighbor_lane->lane().type();
150 AWARN <<
"lane[" << lane_id <<
"]'s right neighbor forward lane["
151 << neighbor_lane_id.id() <<
"] type["
152 << Lane_LaneType_Name(lane_type) <<
"] can't pull over";
153 rightmost_driving_lane =
false;
157 if (!rightmost_driving_lane) {
158 pull_over_scenario =
false;
163 return pull_over_scenario;
bool IsTransferable(const Scenario *other_scenario, const Frame &frame) override
Each scenario should define its own transfer condition, i.e., when it should allow to transfer from o...
ScenarioPullOverConfig scenario_config