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(bpp): overwrite turn signal by latter module #6543

Closed
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions planning/behavior_path_avoidance_module/src/scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -888,7 +888,7 @@
updatePathShifter(data.safe_shift_line);

if (data.success) {
removeRegisteredShiftLines();
return getPreviousModuleOutput();
}

if (data.yield_required) {
Expand Down Expand Up @@ -942,7 +942,7 @@
linear_shift_path, path_shifter_.getShiftLines().front(), helper_->getEgoShift(), avoid_data_,
planner_data_);
const auto current_seg_idx = planner_data_->findEgoSegmentIndex(spline_shift_path.path.points);
output.turn_signal_info = planner_data_->turn_signal_decider.use_prior_turn_signal(
output.turn_signal_info = planner_data_->turn_signal_decider.overwrite_turn_signal(

Check warning on line 945 in planning/behavior_path_avoidance_module/src/scene.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_avoidance_module/src/scene.cpp#L945

Added line #L945 was not covered by tests
spline_shift_path.path, getEgoPose(), current_seg_idx, original_signal, new_signal,
planner_data_->parameters.ego_nearest_dist_threshold,
planner_data_->parameters.ego_nearest_yaw_threshold);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -971,7 +971,7 @@
const auto original_signal = getPreviousModuleOutput().turn_signal_info;
const auto new_signal = calcTurnSignalInfo();
const auto current_seg_idx = planner_data_->findEgoSegmentIndex(output.path.points);
output.turn_signal_info = planner_data_->turn_signal_decider.use_prior_turn_signal(
output.turn_signal_info = planner_data_->turn_signal_decider.overwrite_turn_signal(

Check warning on line 974 in planning/behavior_path_goal_planner_module/src/goal_planner_module.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_goal_planner_module/src/goal_planner_module.cpp#L974

Added line #L974 was not covered by tests
output.path, getEgoPose(), current_seg_idx, original_signal, new_signal,
planner_data_->parameters.ego_nearest_dist_threshold,
planner_data_->parameters.ego_nearest_yaw_threshold);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ TurnSignalInfo LaneChangeInterface::getCurrentTurnSignalInfo(
}

// check the priority of turn signals
return module_type_->getTurnSignalDecider().use_prior_turn_signal(
return module_type_->getTurnSignalDecider().overwrite_turn_signal(
path, current_pose, current_nearest_seg_idx, original_turn_signal_info,
current_turn_signal_info, nearest_dist_threshold, nearest_yaw_threshold);
}
Expand Down
6 changes: 3 additions & 3 deletions planning/behavior_path_lane_change_module/src/scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@
output.turn_signal_info = prev_turn_signal_info_;
extendOutputDrivableArea(output);
const auto current_seg_idx = planner_data_->findEgoSegmentIndex(output.path.points);
output.turn_signal_info = planner_data_->turn_signal_decider.use_prior_turn_signal(
output.turn_signal_info = planner_data_->turn_signal_decider.overwrite_turn_signal(

Check warning on line 151 in planning/behavior_path_lane_change_module/src/scene.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_lane_change_module/src/scene.cpp#L151

Added line #L151 was not covered by tests
output.path, getEgoPose(), current_seg_idx, prev_turn_signal_info_, output.turn_signal_info,
planner_data_->parameters.ego_nearest_dist_threshold,
planner_data_->parameters.ego_nearest_yaw_threshold);
Expand Down Expand Up @@ -183,7 +183,7 @@
extendOutputDrivableArea(output);

const auto current_seg_idx = planner_data_->findEgoSegmentIndex(output.path.points);
output.turn_signal_info = planner_data_->turn_signal_decider.use_prior_turn_signal(
output.turn_signal_info = planner_data_->turn_signal_decider.overwrite_turn_signal(

Check warning on line 186 in planning/behavior_path_lane_change_module/src/scene.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_lane_change_module/src/scene.cpp#L186

Added line #L186 was not covered by tests
output.path, getEgoPose(), current_seg_idx, prev_turn_signal_info_, output.turn_signal_info,
planner_data_->parameters.ego_nearest_dist_threshold,
planner_data_->parameters.ego_nearest_yaw_threshold);
Expand Down Expand Up @@ -226,7 +226,7 @@
extendOutputDrivableArea(output);

const auto current_seg_idx = planner_data_->findEgoSegmentIndex(output.path.points);
output.turn_signal_info = planner_data_->turn_signal_decider.use_prior_turn_signal(
output.turn_signal_info = planner_data_->turn_signal_decider.overwrite_turn_signal(

Check warning on line 229 in planning/behavior_path_lane_change_module/src/scene.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_lane_change_module/src/scene.cpp#L229

Added line #L229 was not covered by tests
output.path, getEgoPose(), current_seg_idx, prev_turn_signal_info_, output.turn_signal_info,
planner_data_->parameters.ego_nearest_dist_threshold,
planner_data_->parameters.ego_nearest_yaw_threshold);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ class TurnSignalDecider
const TurnSignalInfo & intersection_signal_info, const TurnSignalInfo & behavior_signal_info,
const double nearest_dist_threshold, const double nearest_yaw_threshold);

TurnSignalInfo overwrite_turn_signal(
const PathWithLaneId & path, const Pose & current_pose, const size_t current_seg_idx,
const TurnSignalInfo & original_signal, const TurnSignalInfo & new_signal,
const double nearest_dist_threshold, const double nearest_yaw_threshold);

TurnSignalInfo use_prior_turn_signal(
const PathWithLaneId & path, const Pose & current_pose, const size_t current_seg_idx,
const TurnSignalInfo & original_signal, const TurnSignalInfo & new_signal,
Expand Down
26 changes: 26 additions & 0 deletions planning/behavior_path_planner_common/src/turn_signal_decider.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 TIER IV, Inc.

Check warning on line 1 in planning/behavior_path_planner_common/src/turn_signal_decider.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

❌ New issue: Missing Arguments Abstractions

The average number of function arguments in this module is 4.15 across 13 functions. The average arguments threshold is 4.00. The functions in this file have too many arguments, indicating a lack of encapsulation or too many responsibilities in the same functions. Avoid adding more.

Check notice on line 1 in planning/behavior_path_planner_common/src/turn_signal_decider.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 7.25 to 6.92, 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.

Check notice on line 1 in planning/behavior_path_planner_common/src/turn_signal_decider.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

✅ Getting better: Primitive Obsession

The ratio of primitive types in function arguments decreases from 34.04% to 33.33%, threshold = 30.0%. The functions in this file have too many primitive types (e.g. int, double, float) in their function argument lists. Using many primitive types lead to the code smell Primitive Obsession. Avoid adding more primitive arguments.
//
// 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 @@ -392,6 +392,32 @@
return intersection_signal_info.turn_signal;
}

TurnSignalInfo TurnSignalDecider::overwrite_turn_signal(

Check warning on line 395 in planning/behavior_path_planner_common/src/turn_signal_decider.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_planner_common/src/turn_signal_decider.cpp#L395

Added line #L395 was not covered by tests
const PathWithLaneId & path, const Pose & current_pose, const size_t current_seg_idx,
const TurnSignalInfo & original_signal, const TurnSignalInfo & new_signal,
const double nearest_dist_threshold, const double nearest_yaw_threshold)
{
const auto get_distance = [&](const Pose & input_point) {
const size_t nearest_seg_idx = motion_utils::findFirstNearestSegmentIndexWithSoftConstraints(
path.points, input_point, nearest_dist_threshold, nearest_yaw_threshold);
return motion_utils::calcSignedArcLength(
path.points, current_pose.position, current_seg_idx, input_point.position, nearest_seg_idx);
};

Check warning on line 405 in planning/behavior_path_planner_common/src/turn_signal_decider.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_planner_common/src/turn_signal_decider.cpp#L400-L405

Added lines #L400 - L405 were not covered by tests

const auto & new_desired_start_point = new_signal.desired_start_point;
const auto & new_required_start_point = new_signal.required_start_point;

Check warning on line 408 in planning/behavior_path_planner_common/src/turn_signal_decider.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_planner_common/src/turn_signal_decider.cpp#L407-L408

Added lines #L407 - L408 were not covered by tests

const double dist_to_new_desired_start = get_distance(new_desired_start_point) - base_link2front_;

Check warning on line 410 in planning/behavior_path_planner_common/src/turn_signal_decider.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_planner_common/src/turn_signal_decider.cpp#L410

Added line #L410 was not covered by tests
const double dist_to_new_required_start =
get_distance(new_required_start_point) - base_link2front_;

Check warning on line 412 in planning/behavior_path_planner_common/src/turn_signal_decider.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_planner_common/src/turn_signal_decider.cpp#L412

Added line #L412 was not covered by tests

if (dist_to_new_desired_start > 0.0 && dist_to_new_required_start > 0.0) {
return original_signal;

Check warning on line 415 in planning/behavior_path_planner_common/src/turn_signal_decider.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_planner_common/src/turn_signal_decider.cpp#L415

Added line #L415 was not covered by tests
}

return new_signal;

Check warning on line 418 in planning/behavior_path_planner_common/src/turn_signal_decider.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_planner_common/src/turn_signal_decider.cpp#L418

Added line #L418 was not covered by tests
}

Check notice on line 419 in planning/behavior_path_planner_common/src/turn_signal_decider.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

ℹ New issue: Excess Number of Function Arguments

TurnSignalDecider::overwrite_turn_signal has 7 arguments, threshold = 4. This function has too many arguments, indicating a lack of encapsulation. Avoid adding more arguments.

TurnSignalInfo TurnSignalDecider::use_prior_turn_signal(
const PathWithLaneId & path, const Pose & current_pose, const size_t current_seg_idx,
const TurnSignalInfo & original_signal, const TurnSignalInfo & new_signal,
Expand Down
Loading