Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(intersection): yield stuck stop #5403

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2020 Tier IV, Inc.

Check notice on line 1 in planning/behavior_velocity_intersection_module/src/scene_intersection.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

✅ Getting better: Lines of Code in a Single File

The lines of code decreases from 1741 to 1733, improve code health by reducing it to 1000. The number of Lines of Code in a single file. More Lines of Code lowers the code health.

Check notice on line 1 in planning/behavior_velocity_intersection_module/src/scene_intersection.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

✅ Getting better: Overall Code Complexity

The mean cyclomatic complexity decreases from 8.35 to 8.24, threshold = 4. This file has many conditional statements (e.g. if, for, while) across its implementation, leading to lower code health. Avoid adding more conditionals.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -1064,16 +1064,8 @@
const bool yield_stuck_detected = checkYieldStuckVehicle(
planner_data_, path_lanelets, intersection_lanelets.first_attention_area());
if (yield_stuck_detected && stuck_stop_line_idx_opt) {
auto stuck_stop_line_idx = stuck_stop_line_idx_opt.value();
if (is_private_area_ && planner_param_.stuck_vehicle.enable_private_area_stuck_disregard) {
if (
default_stop_line_idx_opt &&
fromEgoDist(stuck_stop_line_idx) < -planner_param_.common.stop_overshoot_margin) {
stuck_stop_line_idx = default_stop_line_idx_opt.value();
}
} else {
return IntersectionModule::YieldStuckStop{closest_idx, stuck_stop_line_idx};
}
const auto stuck_stop_line_idx = stuck_stop_line_idx_opt.value();

Check warning on line 1067 in planning/behavior_velocity_intersection_module/src/scene_intersection.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_velocity_intersection_module/src/scene_intersection.cpp#L1067

Added line #L1067 was not covered by tests
return IntersectionModule::YieldStuckStop{closest_idx, stuck_stop_line_idx};

Check notice on line 1068 in planning/behavior_velocity_intersection_module/src/scene_intersection.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

✅ Getting better: Bumpy Road Ahead

IntersectionModule::modifyPathVelocityDetail decreases from 5 to 4 logical blocks with deeply nested code, threshold is one single 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.

Check notice on line 1068 in planning/behavior_velocity_intersection_module/src/scene_intersection.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

✅ Getting better: Complex Method

IntersectionModule::modifyPathVelocityDetail decreases in cyclomatic complexity from 81 to 77, 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.
}

// if attention area is empty, collision/occlusion detection is impossible
Expand Down Expand Up @@ -1520,25 +1512,25 @@
.object_expected_deceleration));
return dist_to_stop_line > braking_distance;
};
const auto isTolerableOvershoot = [&](const util::TargetObject & target_object) {

Check warning on line 1515 in planning/behavior_velocity_intersection_module/src/scene_intersection.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_velocity_intersection_module/src/scene_intersection.cpp#L1515

Added line #L1515 was not covered by tests
if (
!target_object.attention_lanelet || !target_object.dist_to_stop_line ||
!target_object.stop_line) {
return false;
}
const double dist_to_stop_line = target_object.dist_to_stop_line.value();
const double v = target_object.object.kinematics.initial_twist_with_covariance.twist.linear.x;
const double braking_distance =
v * v /
(2.0 * std::fabs(planner_param_.collision_detection.ignore_on_amber_traffic_light
.object_expected_deceleration));

Check warning on line 1526 in planning/behavior_velocity_intersection_module/src/scene_intersection.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_velocity_intersection_module/src/scene_intersection.cpp#L1521-L1526

Added lines #L1521 - L1526 were not covered by tests
if (dist_to_stop_line > braking_distance) {
return false;
}
const auto stopline_front = target_object.stop_line.value().front();
const auto stopline_back = target_object.stop_line.value().back();
tier4_autoware_utils::LineString2d object_line;
object_line.emplace_back(

Check warning on line 1533 in planning/behavior_velocity_intersection_module/src/scene_intersection.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_velocity_intersection_module/src/scene_intersection.cpp#L1533

Added line #L1533 was not covered by tests
(stopline_front.x() + stopline_back.x()) / 2.0,
(stopline_front.y() + stopline_back.y()) / 2.0);
const auto stopline_mid = object_line.front();
Expand All @@ -1551,14 +1543,14 @@
}
const auto collision_point = intersections.front();
// distance from object expected stop position to collision point
const double stopline_to_object = -1.0 * dist_to_stop_line + braking_distance;

Check warning on line 1546 in planning/behavior_velocity_intersection_module/src/scene_intersection.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_velocity_intersection_module/src/scene_intersection.cpp#L1546

Added line #L1546 was not covered by tests
const double stopline_to_collision =
std::hypot(collision_point.x() - stopline_mid.x(), collision_point.y() - stopline_mid.y());
const double object2collision = stopline_to_collision - stopline_to_object;
const double margin =

Check warning on line 1550 in planning/behavior_velocity_intersection_module/src/scene_intersection.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_velocity_intersection_module/src/scene_intersection.cpp#L1548-L1550

Added lines #L1548 - L1550 were not covered by tests
planner_param_.collision_detection.ignore_on_red_traffic_light.object_margin_to_path;
return (object2collision > margin) || (object2collision < 0);
};

Check warning on line 1553 in planning/behavior_velocity_intersection_module/src/scene_intersection.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_velocity_intersection_module/src/scene_intersection.cpp#L1553

Added line #L1553 was not covered by tests
// check collision between predicted_path and ego_area
bool collision_detected = false;
for (const auto & target_object : target_objects->all_attention_objects) {
Expand All @@ -1572,11 +1564,11 @@
continue;
}
const bool is_tolerable_overshoot = isTolerableOvershoot(target_object);
if (

Check warning on line 1567 in planning/behavior_velocity_intersection_module/src/scene_intersection.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_velocity_intersection_module/src/scene_intersection.cpp#L1567

Added line #L1567 was not covered by tests
traffic_prioritized_level == util::TrafficPrioritizedLevel::FULLY_PRIORITIZED &&
!expected_to_stop_before_stopline && is_tolerable_overshoot) {
debug_data_.red_overshoot_ignore_targets.objects.push_back(object);
continue;

Check warning on line 1571 in planning/behavior_velocity_intersection_module/src/scene_intersection.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_velocity_intersection_module/src/scene_intersection.cpp#L1571

Added line #L1571 was not covered by tests
}
for (const auto & predicted_path : object.kinematics.predicted_paths) {
if (
Expand Down
Loading