Skip to content

Commit

Permalink
fix(bpp): update collided polygon pose only once
Browse files Browse the repository at this point in the history
Signed-off-by: Zulfaqar Azmi <zulfaqar.azmi@tier4.jp>
  • Loading branch information
zulfaqar-azmi-t4 committed Nov 15, 2024
1 parent d819a66 commit 91bb0e2
Showing 1 changed file with 15 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -622,13 +622,15 @@ std::vector<Polygon2d> get_collided_polygons(

// check intersects
if (boost::geometry::intersects(ego_polygon, obj_polygon)) {
debug.unsafe_reason = "overlap_polygon";
if (collided_polygons.empty()) {
debug.unsafe_reason = "overlap_polygon";
debug.expected_ego_pose = ego_pose;
debug.expected_obj_pose = obj_pose;
debug.extended_ego_polygon = ego_polygon;
debug.extended_obj_polygon = obj_polygon;
}
collided_polygons.push_back(obj_polygon);

debug.expected_ego_pose = ego_pose;
debug.expected_obj_pose = obj_pose;
debug.extended_ego_polygon = ego_polygon;
debug.extended_obj_polygon = obj_polygon;
continue;
}

Expand Down Expand Up @@ -676,14 +678,15 @@ std::vector<Polygon2d> get_collided_polygons(

// check intersects with extended polygon
if (boost::geometry::intersects(extended_ego_polygon, extended_obj_polygon)) {
debug.unsafe_reason = "overlap_extended_polygon";
if (collided_polygons.empty()) {
debug.unsafe_reason = "overlap_extended_polygon";
debug.rss_longitudinal = rss_dist;
debug.inter_vehicle_distance = min_lon_length;
debug.extended_ego_polygon = extended_ego_polygon;
debug.extended_obj_polygon = extended_obj_polygon;
debug.is_front = is_object_front;
}
collided_polygons.push_back(obj_polygon);

Check warning on line 689 in planning/behavior_path_planner/autoware_behavior_path_planner_common/src/utils/path_safety_checker/safety_check.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

❌ Getting worse: Complex Method

get_collided_polygons increases in cyclomatic complexity from 15 to 17, threshold = 9. This function has many conditional statements (e.g. if, for, while), leading to lower code health. Avoid adding more conditionals and code to it without refactoring.

Check warning on line 689 in planning/behavior_path_planner/autoware_behavior_path_planner_common/src/utils/path_safety_checker/safety_check.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

❌ New issue: Bumpy Road Ahead

get_collided_polygons has 3 blocks with nested conditional logic. Any nesting of 2 or deeper is considered. Threshold is one single, nested block per function. The Bumpy Road code smell is a function that contains multiple chunks of nested conditional logic. The deeper the nesting and the more bumps, the lower the code health.

debug.rss_longitudinal = rss_dist;
debug.inter_vehicle_distance = min_lon_length;
debug.extended_ego_polygon = extended_ego_polygon;
debug.extended_obj_polygon = extended_obj_polygon;
debug.is_front = is_object_front;
}
}

Expand Down

0 comments on commit 91bb0e2

Please sign in to comment.