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