23 double min_distance_block_obs_to_junction,
24 bool enable_junction_borrow,
25 double passby_min_gap,
26 double passby_kappa_ratio,
27 int queue_check_count,
28 int stable_block_count) {
29 AINFO <<
"IsNeedEscape";
30 static std::pair<std::shared_ptr<Obstacle>,
int> queue_sence_obs_info = std::make_pair(std::make_shared<Obstacle>(), 0);
31 static std::pair<std::string, int> stable_block_obs_count = std::make_pair(
"", 0);
33 > common::VehicleConfigHelper::Instance()->GetConfig().vehicle_param().max_abs_speed_when_stopped()) {
34 AINFO <<
"Vehicle is not stopped.";
39 AINFO <<
"reference_line_info.path_data() is empty.";
50 AINFO <<
"Distance to destination is less than 20m.";
54 double min_distance = std::numeric_limits<double>::max();
55 std::string stop_decision_obs_id;
56 std::string block_obs_id;
58 AINFO <<
"sweeper decide stop, don't need escape.";
61 AINFO <<
"min_distance: " << min_distance;
62 if (min_distance < FLAGS_min_stop_distance_obstacle + 2.0 && min_distance > 0) {
63 block_obs_id = stop_decision_obs_id;
64 AINFO <<
"block_obs_id: " << block_obs_id;
66 queue_sence_obs_info.first.reset();
67 queue_sence_obs_info.second = 0;
68 stable_block_obs_count.first.clear();
69 stable_block_obs_count.second = 0;
74 < min_distance_block_obs_to_junction) {
75 AINFO <<
"enable_junction_borrow is false and DistanceBlockingObstacleToIntersection is smaller than 22m.";
78 if (!
IsEnoughSpace(reference_line_info, block_obs_id, passby_min_gap, passby_kappa_ratio)) {
79 AINFO <<
"IsEnoughSpace: false";
83 bool is_queue =
IsQueueSence(reference_line_info, block_obs_id, queue_check_count, queue_sence_obs_info);
84 bool is_stable_block_obs =
IsStableBlockObs(reference_line_info, block_obs_id, stable_block_count, stable_block_obs_count);
86 if (is_queue || !is_stable_block_obs) {
87 AINFO <<
"IsNeedEscape: false";
91 queue_sence_obs_info.first.reset();
92 queue_sence_obs_info.second = 0;
93 stable_block_obs_count.first.clear();
94 stable_block_obs_count.second = 0;
101 const std::string& blocking_obstacle_id,
102 const double &passby_min_gap,
103 const double &passby_kappa_ratio) {
104 bool enable_lane_borrow =
false;
105 bool lane_follow_enough_space =
false;
111 if (ptr_lane_info ==
nullptr) {
112 AWARN <<
"ptr_lane_info is null";
115 if (!ptr_lane_info->lane().left_neighbor_forward_lane_id().empty()
116 || !ptr_lane_info->lane().left_neighbor_reverse_lane_id().empty()) {
117 AERROR <<
"check_s: " << check_s;
122 AINFO <<
"cannot borrow left lane";
124 enable_lane_borrow =
true;
127 AERROR <<
"check_s: " << check_s;
128 if (!ptr_lane_info->lane().right_neighbor_forward_lane_id().empty()
129 || !ptr_lane_info->lane().right_neighbor_reverse_lane_id().empty()) {
133 AINFO <<
"cannot borrow right lane";
135 enable_lane_borrow =
true;
140 double ego_width = common::VehicleConfigHelper::Instance()->GetConfig().vehicle_param().width();
142 double obs_start_l = obstacle_sl.
start_l();
143 double obs_end_l = obstacle_sl.end_l();
144 double check_start_s = obstacle_sl.start_s();
145 double check_end_s = obstacle_sl.end_s();
146 double obs_s = (check_start_s + check_end_s) / 2;
147 double left_lane_width = 0.0;
148 double right_lane_width = 0.0;
152 std::vector<std::pair<double, int>> obs_l_range;
153 for (
const auto* ptr_obstacle_item : path_decision.
obstacles().
Items()) {
154 const Obstacle* ptr_obstacle = path_decision.
Find(ptr_obstacle_item->Id());
155 if (ptr_obstacle ==
nullptr || !ptr_obstacle->
IsStatic()
159 const SLBoundary& obs_sl_boundary = ptr_obstacle_item->PerceptionSLBoundary();
160 if (obs_sl_boundary.
start_s() > check_end_s || obs_sl_boundary.
end_s() < check_start_s) {
163 obs_l_range.emplace_back(std::make_pair(obs_sl_boundary.
start_l(), 0));
164 obs_l_range.emplace_back(std::make_pair(obs_sl_boundary.
end_l(), 1));
165 AINFO <<
"obstacle: " << ptr_obstacle->
Id() <<
" " << obs_sl_boundary.
start_l() <<
" "
166 << obs_sl_boundary.
end_l();
169 std::sort(obs_l_range.begin(), obs_l_range.end(), [](std::pair<double, int>& p1, std::pair<double, int>& p2) {
170 return p1.first < p2.first;
173 std::vector<double> space_gap;
174 for (
size_t i = 0; i < obs_l_range.size(); ++i) {
175 if (gap_count == 0) {
176 space_gap.push_back(obs_l_range.at(i).first);
177 AINFO <<
"space_gap: " << space_gap.back();
183 if (obs_l_range.at(i).second == 0) {
185 }
else if (obs_l_range.at(i).second == 1) {
188 if (gap_count == 0) {
189 space_gap.push_back(obs_l_range.at(i).first);
190 AINFO <<
"space_gap: " << space_gap.back();
193 if (space_gap.empty()) {
194 AINFO <<
"space_gap is empty";
195 space_gap.push_back(left_lane_width);
197 double max_gap = right_lane_width + space_gap.front();
198 AINFO <<
"max_gap: " << max_gap;
199 for (
int i = 2; i < space_gap.size(); i += 2) {
200 double temp_gap = space_gap[i] - space_gap[i - 1];
201 if (temp_gap > max_gap) {
203 AINFO <<
"max_gap: " << max_gap;
206 max_gap = std::max(max_gap, left_lane_width - space_gap.back());
208 AINFO <<
"max_gap: " << max_gap <<
" obs_reference_point_kappa: " << obs_reference_point_kappa;
209 if (max_gap - ego_width > passby_min_gap + obs_reference_point_kappa * passby_kappa_ratio) {
210 lane_follow_enough_space =
true;
212 AINFO <<
"lane_follow_enough_space: false, max_gap: " << max_gap <<
" ego_width: " << ego_width;
215 if (enable_lane_borrow || lane_follow_enough_space) {
218 AINFO <<
"enable_lane_borrow: " << enable_lane_borrow
219 <<
", lane_follow_enough_space: " << lane_follow_enough_space;
226 const std::string& blocking_obstacle_id,
227 const int &queue_check_count,
228 std::pair<std::shared_ptr<Obstacle>,
int> &queue_obs_info) {
229 if (blocking_obstacle_id.empty()) {
230 ADEBUG <<
"There is no blocking obstacle.";
234 if (obs ==
nullptr) {
235 ADEBUG <<
"Blocking obstacle is no longer there.";
244 if (obs_center_l < -1.5) {
245 AINFO <<
"side parking car: " << obs->
Id();
250 AINFO <<
"moving obs: " << obs->
Id();
254 if (queue_obs_info.first ==
nullptr) {
255 queue_obs_info.first = std::make_shared<Obstacle>(*obs);
256 queue_obs_info.second = 1;
260 if (queue_obs_info.first->Id() == obs->
Id()) {
261 if (queue_obs_info.second < queue_check_count) {
262 queue_obs_info.second++;
263 AINFO <<
"obs id: " << obs->
Id() <<
", queue sence is true.";
267 AINFO <<
"obs id: " << obs->
Id() <<
", queue sence is false.";
271 queue_obs_info.first = std::make_shared<Obstacle>(*obs);
272 queue_obs_info.second = 1;
273 AINFO <<
"obs id: " << obs->
Id() <<
", queue sence is true.";
279 if (blocking_obstacle_id.empty()) {
280 ADEBUG <<
"There is no blocking obstacle.";
283 if (stable_block_obs.first.empty()) {
284 stable_block_obs.first = blocking_obstacle_id;
285 stable_block_obs.second = 1;
289 if (stable_block_obs.first == blocking_obstacle_id) {
290 if (stable_block_obs.second < stable_block_count) {
291 stable_block_obs.second++;
292 AINFO <<
"obs id: " << blocking_obstacle_id <<
", stable is false.";
296 AINFO <<
"obs id: " << blocking_obstacle_id <<
", stable is true.";
300 stable_block_obs.first = blocking_obstacle_id;
301 stable_block_obs.second = 1;
302 AINFO <<
"obs id: " << blocking_obstacle_id <<
", stable is false.";
static bool IsNeedEscape(ReferenceLineInfo &reference_line_info, double min_distance_block_obs_to_junction, bool enable_junction_borrow, double passby_min_gap, double passby_kappa_ratio, int queue_check_count, int stable_block_count)