Skip to content

Commit

Permalink
remove is_go_out_ variable
Browse files Browse the repository at this point in the history
Signed-off-by: Mamoru Sobue <[email protected]>
  • Loading branch information
soblin committed Oct 15, 2023
1 parent 66a699b commit c964c17
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -876,11 +876,6 @@ bool IntersectionModule::modifyPathVelocity(PathWithLaneId * path, StopReason *
activated_, occlusion_activated_, decision_result, planner_param_, baselink2front, path,
stop_reason, &velocity_factor_, &debug_data_);

if (!activated_ || !occlusion_activated_) {
is_go_out_ = false;
} else {
is_go_out_ = true;
}
RCLCPP_DEBUG(logger_, "===== plan end =====");
return true;
}
Expand Down Expand Up @@ -1071,6 +1066,13 @@ IntersectionModule::DecisionResult IntersectionModule::modifyPathVelocityDetail(
planning_utils::getAheadPose(pass_judge_line_idx, baselink2front, *path);
const bool is_over_pass_judge_line =
util::isOverTargetIndex(*path, closest_idx, current_pose, pass_judge_line_idx);
/* NEW
if (
planner_param_.collision_detection.pass_judge.judge_before_default_stop_line &&
is_over_pass_judge_line) {
return IntersectionModule::Indecisive{"over the pass judge line. no plan needed"};
}
*/
const bool is_over_default_stop_line =
util::isOverTargetIndex(*path, closest_idx, current_pose, default_stop_line_idx);
const double vel_norm = std::hypot(
Expand All @@ -1085,13 +1087,13 @@ IntersectionModule::DecisionResult IntersectionModule::modifyPathVelocityDetail(
logger_, "is_over_default_stop_line && !is_over_pass_judge_line && keep_detection");
// do nothing
} else if (
(was_safe && is_over_default_stop_line && is_over_pass_judge_line && is_go_out_) ||
is_permanent_go_) {
// is_go_out_: previous RTC approval
(was_safe && is_over_default_stop_line && is_over_pass_judge_line) || is_permanent_go_) {

Check notice on line 1090 in planning/behavior_velocity_intersection_module/src/scene_intersection.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

✅ Getting better: Complex Conditional

IntersectionModule::modifyPathVelocityDetail decreases from 2 complex conditionals with 6 branches to 2 complex conditionals with 5 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.
// activated_: current RTC approval
is_permanent_go_ = true;
return IntersectionModule::Indecisive{"over the pass judge line. no plan needed"};
}
const bool was_going_out =
(was_safe || std::holds_alternative<IntersectionModule::Indecisive>(prev_decision_result_));

// occlusion stop line is generated from the intersection of ego footprint along the path with the
// attention area, so if this is null, eog has already passed the intersection
Expand Down Expand Up @@ -1161,7 +1163,7 @@ IntersectionModule::DecisionResult IntersectionModule::modifyPathVelocityDetail(
}

// calculate dynamic collision around attention area
const double time_to_restart = (is_go_out_ || is_prioritized)
const double time_to_restart = (was_going_out || is_prioritized)

Check warning on line 1166 in planning/behavior_velocity_intersection_module/src/scene_intersection.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

❌ Getting worse: Complex Method

IntersectionModule::modifyPathVelocityDetail already has high cyclomatic complexity, and now it increases in Lines of Code from 295 to 296. 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.
? 0.0
: (planner_param_.collision_detection.state_transit_margin_time -
collision_state_machine_.getDuration());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,6 @@ class IntersectionModule : public SceneModuleInterface
const std::string turn_direction_;
const bool has_traffic_light_;

bool is_go_out_{false};
bool is_permanent_go_{false};
DecisionResult prev_decision_result_{Indecisive{""}};

Expand Down

0 comments on commit c964c17

Please sign in to comment.