Skip to content

Commit

Permalink
fix(goal_planner): fix deviated path update
Browse files Browse the repository at this point in the history
Signed-off-by: kosuke55 <[email protected]>
  • Loading branch information
kosuke55 committed Jan 30, 2024
1 parent ba21eec commit f3d2bfa
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,7 @@ class GoalPlannerModule : public SceneModuleInterface
std::optional<BehaviorModuleOutput> last_previous_module_output_{};
bool hasPreviousModulePathShapeChanged() const;
bool hasDeviatedFromLastPreviousModulePath() const;
bool hasDeviatedFromCurrentPreviousModulePath() const;

// timer for generating pull over path candidates in a separate thread
void onTimer();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,13 @@ bool GoalPlannerModule::hasDeviatedFromLastPreviousModulePath() const
planner_data_->self_odometry->pose.pose.position)) > 0.3;
}

bool GoalPlannerModule::hasDeviatedFromCurrentPreviousModulePath() const

Check warning on line 164 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#L164

Added line #L164 was not covered by tests
{
return std::abs(motion_utils::calcLateralOffset(
getPreviousModuleOutput().path.points,
planner_data_->self_odometry->pose.pose.position)) > 0.3;

Check warning on line 168 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#L166-L168

Added lines #L166 - L168 were not covered by tests
}

// generate pull over candidate paths
void GoalPlannerModule::onTimer()
{
Expand All @@ -179,6 +186,10 @@ void GoalPlannerModule::onTimer()

// check if new pull over path candidates are needed to be generated
const bool need_update = std::invoke([&]() {
if (hasDeviatedFromCurrentPreviousModulePath()) {
RCLCPP_ERROR(getLogger(), "has deviated from current previous module path");
return false;

Check warning on line 191 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#L189-L191

Added lines #L189 - L191 were not covered by tests
}

Check warning on line 192 in planning/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::onTimer increases in cyclomatic complexity from 25 to 26, 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 (thread_safe_data_.get_pull_over_path_candidates().empty()) {
return true;
}
Expand Down

0 comments on commit f3d2bfa

Please sign in to comment.