@@ -334,13 +334,14 @@ IntersectionModule::OcclusionType IntersectionModule::detectOcclusion(
334
334
}
335
335
return nearest;
336
336
};
337
- struct NearestOcclusionPoint
337
+ struct NearestOcclusionInterval
338
338
{
339
339
int64 division_index{0 };
340
340
int64 point_index{0 };
341
341
double dist{0.0 };
342
342
geometry_msgs::msg::Point point;
343
343
geometry_msgs::msg::Point projection;
344
+ geometry_msgs::msg::Point visible_end;
344
345
} nearest_occlusion_point;
345
346
double min_dist = std::numeric_limits<double >::infinity ();
346
347
for (unsigned division_index = 0 ; division_index < lane_divisions.size (); ++division_index) {
@@ -370,6 +371,8 @@ IntersectionModule::OcclusionType IntersectionModule::detectOcclusion(
370
371
continue ;
371
372
}
372
373
double acc_dist = 0.0 ;
374
+ bool found_min_dist_for_this_division = false ;
375
+ bool is_prev_occluded = false ;
373
376
auto acc_dist_it = projection_it;
374
377
for (auto point_it = projection_it; point_it != division.end (); point_it++) {
375
378
const double dist =
@@ -386,11 +389,24 @@ IntersectionModule::OcclusionType IntersectionModule::detectOcclusion(
386
389
if (acc_dist < min_dist) {
387
390
min_dist = acc_dist;
388
391
nearest_occlusion_point = {
389
- division_index, std::distance (division.begin (), point_it), acc_dist,
392
+ division_index,
393
+ std::distance (division.begin (), point_it),
394
+ acc_dist,
390
395
tier4_autoware_utils::createPoint (point_it->x (), point_it->y (), origin.z ),
391
- tier4_autoware_utils::createPoint (projection_it->x (), projection_it->y (), origin.z )};
396
+ tier4_autoware_utils::createPoint (projection_it->x (), projection_it->y (), origin.z ),
397
+ tier4_autoware_utils::createPoint (
398
+ projection_it->x (), projection_it->y (),
399
+ origin.z ) /* initialize with projection point at first*/ };
400
+ found_min_dist_for_this_division = true ;
401
+ } else if (found_min_dist_for_this_division && is_prev_occluded) {
402
+ // although this cell is not "nearest" cell, we have found the "nearest" cell on this
403
+ // division previously in this iteration, and the iterated cells are still OCCLUDED since
404
+ // then
405
+ nearest_occlusion_point.visible_end =
406
+ tier4_autoware_utils::createPoint (point_it->x (), point_it->y (), origin.z );
392
407
}
393
408
}
409
+ is_prev_occluded = (pixel == OCCLUDED);
394
410
}
395
411
}
396
412
@@ -400,16 +416,24 @@ IntersectionModule::OcclusionType IntersectionModule::detectOcclusion(
400
416
401
417
debug_data_.nearest_occlusion_projection =
402
418
std::make_pair (nearest_occlusion_point.point , nearest_occlusion_point.projection );
403
- LineString2d ego_occlusion_line;
404
- ego_occlusion_line.emplace_back (current_pose.position .x , current_pose.position .y );
405
- ego_occlusion_line.emplace_back (nearest_occlusion_point.point .x , nearest_occlusion_point.point .y );
419
+ debug_data_.nearest_occlusion_triangle = std::make_tuple (
420
+ current_pose.position , nearest_occlusion_point.point , nearest_occlusion_point.visible_end );
421
+ Polygon2d ego_occlusion_triangle;
422
+ ego_occlusion_triangle.outer ().emplace_back (current_pose.position .x , current_pose.position .y );
423
+ ego_occlusion_triangle.outer ().emplace_back (
424
+ nearest_occlusion_point.point .x , nearest_occlusion_point.point .y );
425
+ ego_occlusion_triangle.outer ().emplace_back (
426
+ nearest_occlusion_point.visible_end .x , nearest_occlusion_point.visible_end .y );
427
+ bg::correct (ego_occlusion_triangle);
406
428
for (const auto & attention_object_info : object_info_manager_.allObjects ()) {
407
429
const auto obj_poly =
408
430
tier4_autoware_utils::toPolygon2d (attention_object_info->predicted_object ());
409
- if (bg::intersects (obj_poly, ego_occlusion_line)) {
431
+ if (bg::intersects (obj_poly, ego_occlusion_triangle)) {
432
+ debug_data_.static_occlusion = false ;
410
433
return DynamicallyOccluded{min_dist};
411
434
}
412
435
}
436
+ debug_data_.static_occlusion = true ;
413
437
return StaticallyOccluded{min_dist};
414
438
}
415
439
} // namespace behavior_velocity_planner
0 commit comments