Skip to content

Commit

Permalink
fix when prepare length is insufficient
Browse files Browse the repository at this point in the history
Signed-off-by: Muhammad Zulfaqar Azmi <zulfaqar.azmi@tier4.jp>
  • Loading branch information
zulfaqar-azmi-t4 committed Aug 9, 2024
1 parent 33df0cb commit 158b6d2
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@
min_longitudinal_acc: -1.0
max_longitudinal_acc: 1.0

skip_process:
longitudinal_distance_diff_threshold:
prepare: 0.5
lane_changing: 0.5

# safety check
safety_check:
allow_loose_check_for_cancel: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ struct Parameters
double min_longitudinal_acc{-1.0};
double max_longitudinal_acc{1.0};

double skip_process_lon_diff_th_prepare{0.5};
double skip_process_lon_diff_th_lane_changing{1.0};

// collision check
bool enable_collision_check_for_prepare_phase_in_general_lanes{false};
bool enable_collision_check_for_prepare_phase_in_intersection{true};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,13 @@ void LaneChangeModuleManager::updateModuleParams(const std::vector<rclcpp::Param
updateParam<double>(parameters, ns + "max_longitudinal_acc", p->max_longitudinal_acc);
}

{
const std::string ns = "lane_change.skip_process.longitudinal_distance_diff_threshold.";
updateParam<double>(parameters, ns + "prepare", p->skip_process_lon_diff_th_prepare);
updateParam<double>(
parameters, ns + "lane_changing", p->skip_process_lon_diff_th_lane_changing);
}

Check warning on line 363 in planning/behavior_path_planner/autoware_behavior_path_lane_change_module/src/manager.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

❌ Getting worse: Large Method

LaneChangeModuleManager::updateModuleParams increases from 93 to 99 lines of code, threshold = 70. Large functions with many lines of code are generally harder to understand and lower the code health. Avoid adding more lines to this function.
{
const std::string ns = "lane_change.safety_check.lane_expansion.";
updateParam<double>(parameters, ns + "left_offset", p->lane_expansion_left_offset);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1417,6 +1417,13 @@ bool NormalLaneChange::getLaneChangePaths(
continue;
}

if (!candidate_paths->empty()) {
const auto prev_prep_diff = candidate_paths->back().info.length.prepare - prepare_length;
if (std::abs(prev_prep_diff) < lane_change_parameters_->skip_process_lon_diff_th_prepare) {
RCLCPP_DEBUG(logger_, "Skip: Change in prepare length is less than threshold.");
continue;
}
}
auto prepare_segment = getPrepareSegment(current_lanes, backward_path_length, prepare_length);

const auto debug_print = [&](const auto & s) {
Expand Down Expand Up @@ -1488,6 +1495,19 @@ bool NormalLaneChange::getLaneChangePaths(
lane_changing_time, sampled_longitudinal_acc, longitudinal_acc_on_lane_changing,
lane_changing_length);
};
if (!candidate_paths->empty()) {
const auto prev_prep_diff = candidate_paths->back().info.length.prepare - prepare_length;
const auto lc_length_diff =
candidate_paths->back().info.length.lane_changing - lane_changing_length;

if (
std::abs(prev_prep_diff) < eps &&
std::abs(lc_length_diff) <
lane_change_parameters_->skip_process_lon_diff_th_lane_changing) {
RCLCPP_DEBUG(logger_, "Skip: Change in lane changing length is less than threshold.");
continue;
}
}

Check warning on line 1510 in planning/behavior_path_planner/autoware_behavior_path_lane_change_module/src/scene.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

❌ Getting worse: Complex Method

NormalLaneChange::getLaneChangePaths increases in cyclomatic complexity from 46 to 53, 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 1510 in planning/behavior_path_planner/autoware_behavior_path_lane_change_module/src/scene.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

❌ Getting worse: Bumpy Road Ahead

NormalLaneChange::getLaneChangePaths increases from 4 to 5 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.

if (lane_changing_length + prepare_length > dist_to_end_of_current_lanes) {
debug_print_lat("Reject: length of lane changing path is longer than length to goal!!");
Expand Down

0 comments on commit 158b6d2

Please sign in to comment.