Skip to content

Commit

Permalink
fix(goal_planner): fix freespace planning chattering
Browse files Browse the repository at this point in the history
Signed-off-by: kosuke55 <kosuke.tnp@gmail.com>
  • Loading branch information
kosuke55 committed Sep 27, 2024
1 parent 21f547d commit 297d780
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1329,9 +1329,12 @@ BehaviorModuleOutput GoalPlannerModule::planPullOverAsOutput(
return getPreviousModuleOutput();
}

const bool is_freespace =
thread_safe_data_.getPullOverPlannerType() == PullOverPlannerType::FREESPACE;
if (
path_decision_controller_.get_current_state().state ==
PathDecisionState::DecisionKind::NOT_DECIDED &&
!is_freespace &&

Check warning on line 1337 in planning/behavior_path_planner/autoware_behavior_path_goal_planner_module/src/goal_planner_module.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

❌ New issue: Complex Conditional

GoalPlannerModule::planPullOverAsOutput has 1 complex conditionals with 2 branches, threshold = 2. A complex conditional is an expression inside a branch (e.g. if, for, while) which consists of multiple, logical operators such as AND/OR. The more logical operators in an expression, the more severe the code smell.
needPathUpdate(
planner_data_->self_odometry->pose.pose, 1.0 /*path_update_duration*/, *parameters_)) {
// if the final path is not decided and enough time has passed since last path update,
Expand Down Expand Up @@ -1370,9 +1373,7 @@ BehaviorModuleOutput GoalPlannerModule::planPullOverAsOutput(
setOutput(context_data, output);

// return to lane parking if it is possible
if (
thread_safe_data_.getPullOverPlannerType() == PullOverPlannerType::FREESPACE &&
canReturnToLaneParking(context_data)) {
if (is_freespace && canReturnToLaneParking(context_data)) {

Check notice on line 1376 in planning/behavior_path_planner/autoware_behavior_path_goal_planner_module/src/goal_planner_module.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

ℹ Getting worse: Complex Method

GoalPlannerModule::planPullOverAsOutput increases in cyclomatic complexity from 9 to 10, 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.
thread_safe_data_.set_pull_over_path(thread_safe_data_.get_lane_parking_pull_over_path());
}

Expand Down

0 comments on commit 297d780

Please sign in to comment.