Skip to content

Commit

Permalink
fix conflict
Browse files Browse the repository at this point in the history
Signed-off-by: Zulfaqar Azmi <[email protected]>
  • Loading branch information
zulfaqar-azmi-t4 committed Jan 14, 2025
1 parent 080250b commit 04d9227
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1266,15 +1266,21 @@ bool NormalLaneChange::get_path_using_path_shifter(
const auto shift_length =
lanelet::utils::getLateralDistanceToClosestLanelet(target_lanes, lane_changing_start_pose);

lane_change_debug_.lane_change_metrics.emplace_back();
auto & debug_metrics = lane_change_debug_.lane_change_metrics.back();
debug_metrics.prep_metric = prep_metric;
debug_metrics.max_prepare_length = common_data_ptr_->transient_data.dist_to_terminal_start;
const auto lane_changing_metrics = get_lane_changing_metrics(
prepare_segment, prep_metric, shift_length, dist_to_next_regulatory_element);
prepare_segment, prep_metric, shift_length, dist_to_next_regulatory_element, debug_metrics);

// set_prepare_velocity must only be called after computing lane change metrics, as lane change
// metrics rely on the prepare segment's original velocity as max_path_velocity.
utils::lane_change::set_prepare_velocity(
prepare_segment, common_data_ptr_->get_ego_speed(), prep_metric.velocity);

for (const auto & lc_metric : lane_changing_metrics) {
debug_metrics.lc_metrics.emplace_back(lc_metric, -1);

const auto debug_print_lat = [&](const std::string & s) {
RCLCPP_DEBUG(
logger_, "%s | lc_time: %.5f | lon_acc: %.5f | lat_acc: %.5f | lc_len: %.5f", s.c_str(),
Expand All @@ -1296,6 +1302,7 @@ bool NormalLaneChange::get_path_using_path_shifter(
}

candidate_paths.push_back(candidate_path);
debug_metrics.lc_metrics.back().second = static_cast<int>(candidate_paths.size()) - 1;

Check notice on line 1305 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)

✅ No longer an issue: Complex Method

NormalLaneChange::get_lane_change_paths is no longer above the threshold for cyclomatic complexity. 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 notice on line 1305 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)

ℹ New issue: Complex Method

NormalLaneChange::get_path_using_path_shifter has a cyclomatic complexity of 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 notice on line 1305 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)

✅ No longer an issue: Bumpy Road Ahead

NormalLaneChange::get_lane_change_paths is no longer above the threshold for logical blocks with deeply nested code. 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 1305 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)

ℹ New issue: Bumpy Road Ahead

NormalLaneChange::get_path_using_path_shifter has 2 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.

try {
if (check_candidate_path_safety(candidate_path, target_objects)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,27 +206,30 @@ MarkerArray ShowLaneChangeMetricsInfo(
text_marker.pose = autoware::universe_utils::calcOffsetPose(pose, 10.0, 15.0, 0.0);

if (!debug_data.lane_change_metrics.empty()) {
text_marker.text = fmt::format("{:<12}", "") + fmt::format("{:^18}|", "lat_accel[m/s2]") +
fmt::format("{:^18}|", "lon_accel[m/s2]") +
fmt::format("{:^17}|", "velocity[m/s]") +
fmt::format("{:^15}|", "duration[s]") + fmt::format("{:^15}|", "length[m]") +
fmt::format("{:^20}\n", "max_length_th[m]");
text_marker.text =
fmt::format("{:<12}", "") + fmt::format("{:^18}|", "lat_accel[m/s2]") +
fmt::format("{:^18}|", "lon_accel[m/s2]") + fmt::format("{:^17}|", "velocity[m/s]") +
fmt::format("{:^15}|", "duration[s]") + fmt::format("{:^15}|", "length[m]") +
fmt::format("{:^20}|", "max_length_th[m]") + fmt::format("{:^15}\n", "path_index");
for (const auto & metrics : debug_data.lane_change_metrics) {
text_marker.text += fmt::format("{:-<170}\n", "");
text_marker.text += fmt::format("{:-<190}\n", "");
const auto & p_m = metrics.prep_metric;
text_marker.text +=
fmt::format("{:<17}", "prep_metrics:") + fmt::format("{:^10.3f}", p_m.lat_accel) +
fmt::format("{:^21.3f}", p_m.actual_lon_accel) + fmt::format("{:^12.3f}", p_m.velocity) +
fmt::format("{:^15.3f}", p_m.duration) + fmt::format("{:^15.3f}", p_m.length) +
fmt::format("{:^17.3f}\n", metrics.max_prepare_length);
fmt::format("{:^17.3f}", metrics.max_prepare_length) + fmt::format("{:^15}\n", "-");
text_marker.text += fmt::format("{:<20}\n", "lc_metrics:");

Check warning on line 222 in planning/behavior_path_planner/autoware_behavior_path_lane_change_module/src/utils/markers.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_planner/autoware_behavior_path_lane_change_module/src/utils/markers.cpp#L222

Added line #L222 was not covered by tests
for (const auto lc_m : metrics.lc_metrics) {
text_marker.text += fmt::format("{:<15}", "") + fmt::format("{:^10.3f}", lc_m.lat_accel) +
fmt::format("{:^21.3f}", lc_m.actual_lon_accel) +
fmt::format("{:^12.3f}", lc_m.velocity) +
fmt::format("{:^15.3f}", lc_m.duration) +
fmt::format("{:^15.3f}", lc_m.length) +
fmt::format("{:^17.3f}\n", metrics.max_lane_changing_length);
for (const auto & lc_m : metrics.lc_metrics) {
const auto & metric = lc_m.first;
const auto path_index = lc_m.second < 0 ? "-" : std::to_string(lc_m.second);
text_marker.text += fmt::format("{:<15}", "") + fmt::format("{:^10.3f}", metric.lat_accel) +
fmt::format("{:^21.3f}", metric.actual_lon_accel) +
fmt::format("{:^12.3f}", metric.velocity) +
fmt::format("{:^15.3f}", metric.duration) +
fmt::format("{:^15.3f}", metric.length) +
fmt::format("{:^17.3f}", metrics.max_lane_changing_length) +
fmt::format("{:^15}\n", path_index);
}
}
marker_array.markers.push_back(text_marker);
Expand Down

0 comments on commit 04d9227

Please sign in to comment.