Skip to content

Commit

Permalink
move to updatedata
Browse files Browse the repository at this point in the history
Signed-off-by: kosuke55 <[email protected]>
  • Loading branch information
kosuke55 committed Nov 10, 2023
1 parent 9a705dc commit 504d1ae
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,10 @@ class ThreadSafeData
bool incrementPathIndex()
{
const std::lock_guard<std::recursive_mutex> lock(mutex_);
if (!pull_over_path_) {
return false;
}

if (pull_over_path_->incrementPathIndex()) {
last_path_idx_increment_time_ = clock_->now();
return true;
Expand Down Expand Up @@ -242,7 +246,6 @@ class ThreadSafeData
#undef DEFINE_GETTER_WITH_MUTEX
#undef DEFINE_SETTER_GETTER_WITH_MUTEX


struct FreespacePlannerDebugData
{
bool is_planning{false};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,20 @@ void GoalPlannerModule::updateData()
updateOccupancyGrid();

generateGoalCandidates();

if (!isActivated()) {
return;
}

if (hasFinishedCurrentPath()) {
thread_safe_data_.incrementPathIndex();

Check warning on line 265 in planning/behavior_path_planner/src/scene_module/goal_planner/goal_planner_module.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_planner/src/scene_module/goal_planner/goal_planner_module.cpp#L265

Added line #L265 was not covered by tests
}

if (!last_approval_data_) {
last_approval_data_ =
std::make_unique<LastApprovalData>(clock_->now(), planner_data_->self_odometry->pose.pose);
decideVelocity();

Check warning on line 271 in planning/behavior_path_planner/src/scene_module/goal_planner/goal_planner_module.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_planner/src/scene_module/goal_planner/goal_planner_module.cpp#L271

Added line #L271 was not covered by tests
}
}

void GoalPlannerModule::initializeOccupancyGridMap()
Expand Down Expand Up @@ -932,16 +946,6 @@ BehaviorModuleOutput GoalPlannerModule::planWithGoalModification()

setStopReason(StopReason::GOAL_PLANNER, thread_safe_data_.get_pull_over_path()->getFullPath());

if (hasFinishedCurrentPath()) {
thread_safe_data_.incrementPathIndex();
}

if (isActivated() && !last_approval_data_) {
last_approval_data_ =
std::make_unique<LastApprovalData>(clock_->now(), planner_data_->self_odometry->pose.pose);
decideVelocity();
}

updateStatus(output);

Check notice on line 950 in planning/behavior_path_planner/src/scene_module/goal_planner/goal_planner_module.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

✅ No longer an issue: Complex Method

GoalPlannerModule::planWithGoalModification 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.
return output;
Expand Down Expand Up @@ -1248,7 +1252,7 @@ bool GoalPlannerModule::isStuck()

bool GoalPlannerModule::hasFinishedCurrentPath()
{
if (!isActivated() || !last_approval_data_) {
if (!last_approval_data_) {
return false;
}

Expand Down

0 comments on commit 504d1ae

Please sign in to comment.