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): transition from IDLE to WAITING APPROVAL #6051

Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,6 @@ class AvoidanceModule : public SceneModuleInterface

bool canTransitFailureState() override { return false; }

bool canTransitIdleToRunningState() override { return true; }

/**
* @brief update RTC status for candidate shift line.
* @param candidate path.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@

bool canTransitFailureState() override { return false; }

bool canTransitIdleToRunningState() override { return false; }
ModuleStatus setInitState() const override { return ModuleStatus::IDLE; }

Check warning on line 348 in planning/behavior_path_dynamic_avoidance_module/include/behavior_path_dynamic_avoidance_module/scene.hpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_dynamic_avoidance_module/include/behavior_path_dynamic_avoidance_module/scene.hpp#L348

Added line #L348 was not covered by tests

bool isLabelTargetObstacle(const uint8_t label) const;
void updateTargetObjects();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,6 @@ class GoalPlannerModule : public SceneModuleInterface
// If terminating it, it may switch to lane following and could generate an inappropriate path.
bool canTransitSuccessState() override { return false; }
bool canTransitFailureState() override { return false; }
bool canTransitIdleToRunningState() override { return true; }

mutable StartGoalPlannerData goal_planner_data_;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2021 Tier IV, Inc.

Check notice on line 1 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: Lines of Code in a Single File

The lines of code increases from 1585 to 1588, improve code health by reducing it to 1000. The number of Lines of Code in a single file. More Lines of Code lowers the code health.

Check notice on line 1 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: Overall Code Complexity

The mean cyclomatic complexity increases from 4.80 to 4.82, 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.
//
// 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 @@ -1863,6 +1863,9 @@

std::pair<bool, bool> GoalPlannerModule::isSafePath() const
{
if (!thread_safe_data_.get_pull_over_path()) {
return {false, false};

Check warning on line 1867 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#L1866-L1867

Added lines #L1866 - L1867 were not covered by tests
}

Check warning on line 1868 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)

❌ New issue: Complex Method

GoalPlannerModule::isSafePath has a cyclomatic complexity of 9, 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.
const auto pull_over_path = thread_safe_data_.get_pull_over_path()->getCurrentPath();
const auto & current_pose = planner_data_->self_odometry->pose.pose;
const double current_velocity = std::hypot(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@

bool canTransitFailureState() override;

bool canTransitIdleToRunningState() override;
ModuleStatus setInitState() const override { return ModuleStatus::WAITING_APPROVAL; };

Check warning on line 129 in planning/behavior_path_lane_change_module/include/behavior_path_lane_change_module/interface.hpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_lane_change_module/include/behavior_path_lane_change_module/interface.hpp#L129

Added line #L129 was not covered by tests

void updateDebugMarker() const;

Expand Down
23 changes: 0 additions & 23 deletions planning/behavior_path_lane_change_module/src/interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,29 +297,6 @@ bool LaneChangeInterface::canTransitFailureState()
return false;
}

bool LaneChangeInterface::canTransitIdleToRunningState()
{
updateDebugMarker();

auto log_debug_throttled = [&](std::string_view message) -> void {
RCLCPP_DEBUG(getLogger(), "%s", message.data());
};

log_debug_throttled(__func__);

if (!isActivated() || isWaitingApproval()) {
if (module_type_->specialRequiredCheck()) {
return true;
}
log_debug_throttled("Module is idling.");
return false;
}

log_debug_throttled("Can lane change safely. Executing lane change.");
module_type_->toNormalState();
return true;
}

void LaneChangeInterface::updateDebugMarker() const
{
if (!parameters_->publish_debug_marker) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -373,13 +373,10 @@ class SceneModuleInterface
RCLCPP_DEBUG(getLogger(), "%s", message.data());
};
if (current_state_ == ModuleStatus::IDLE) {
if (canTransitIdleToRunningState()) {
log_debug_throttled("transiting from IDLE to RUNNING");
return ModuleStatus::RUNNING;
}

log_debug_throttled("transiting from IDLE to IDLE");
return ModuleStatus::IDLE;
auto init_state = setInitState();
RCLCPP_DEBUG(
getLogger(), "transiting from IDLE to %s", magic_enum::enum_name(init_state).data());
return init_state;
}

if (current_state_ == ModuleStatus::RUNNING) {
Expand Down Expand Up @@ -460,9 +457,9 @@ class SceneModuleInterface
virtual bool canTransitFailureState() = 0;

/**
* @brief State transition condition IDLE -> RUNNING
* @brief Explicitly set the initial state
*/
virtual bool canTransitIdleToRunningState() = 0;
virtual ModuleStatus setInitState() const { return ModuleStatus::RUNNING; }

/**
* @brief Get candidate path. This information is used for external judgement.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,6 @@ class SideShiftModule : public SceneModuleInterface

bool canTransitFailureState() override { return false; }

bool canTransitIdleToRunningState() override { return true; }

void initVariables();

// non-const methods
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,6 @@ class StartPlannerModule : public SceneModuleInterface

bool canTransitFailureState() override { return false; }

bool canTransitIdleToRunningState() override { return true; }

/**
* @brief init member variables.
*/
Expand Down
Loading