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(start_planner): issue when ego does not straddle lane bounds and starts from 0 speed #7004

Merged
Show file tree
Hide file tree
Changes from 1 commit
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
@@ -1,4 +1,4 @@
// Copyright 2023 TIER IV, Inc.

Check notice on line 1 in planning/behavior_path_planner_common/src/turn_signal_decider.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 8.46 to 8.54, 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 @@ -731,10 +731,13 @@
return std::make_pair(TurnSignalInfo{}, true);
}

if (!straddleRoadBound(path, shift_line, current_lanelets, p.vehicle_info)) {
// Check if the ego will cross lane bounds.
// Note that pull out requires blinkers, even if the ego does not cross lane bounds
if (!is_pull_out && !straddleRoadBound(path, shift_line, current_lanelets, p.vehicle_info)) {
return std::make_pair(TurnSignalInfo{}, true);
}

// If the ego has stopped and its close to completing its shift, turn off the blinkers

Check warning on line 740 in planning/behavior_path_planner_common/src/turn_signal_decider.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

❌ Getting worse: Complex Method

TurnSignalDecider::getBehaviorTurnSignalInfo increases in cyclomatic complexity from 23 to 24, 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.
constexpr double STOPPED_THRESHOLD = 0.1; // [m/s]
if (ego_speed < STOPPED_THRESHOLD && !override_ego_stopped_check) {
if (isNearEndOfShift(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2022 TIER IV, Inc.

Check notice on line 1 in planning/behavior_path_start_planner_module/src/start_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 1352 to 1358, 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.
//
// 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 @@ -241,9 +241,12 @@
DEBUG_PRINT("StartPlannerModule::updateData() received new route, reset status");
}

constexpr double moving_velocity_threshold = 0.1;
const double & ego_velocity = planner_data_->self_odometry->twist.twist.linear.x;
if (
planner_data_->operation_mode->mode == OperationModeState::AUTONOMOUS &&
status_.driving_forward && !status_.first_engaged_and_driving_forward_time) {
status_.driving_forward && !status_.first_engaged_and_driving_forward_time &&

Check warning on line 248 in planning/behavior_path_start_planner_module/src/start_planner_module.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

❌ Getting worse: Complex Conditional

StartPlannerModule::updateData increases from 1 complex conditionals with 2 branches to 1 complex conditionals with 3 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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you keep this condition as before, and

ego_velocity > moving_velocity_threshold) {

Check notice on line 249 in planning/behavior_path_start_planner_module/src/start_planner_module.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

ℹ Getting worse: Complex Method

StartPlannerModule::updateData 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.
status_.first_engaged_and_driving_forward_time = clock_->now();
}

Expand Down Expand Up @@ -1265,8 +1268,12 @@
// In Geometric pull out, the ego stops once and then steers the wheels to the opposite direction.
// This sometimes causes the getBehaviorTurnSignalInfo method to detect the ego as stopped and
// close to complete its shift, so it wrongly turns off the blinkers, this override helps avoid
// this issue.
// this issue. Also, if the ego is not engaged (so it is stopped), the blinkers should still be
// activated.
const bool override_ego_stopped_check = std::invoke([&]() {
if (!status_.first_engaged_and_driving_forward_time) {
Copy link
Contributor

@soblin soblin May 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and change this condition to needToPrepareBlinkerBeforeStratDrivingForward() or (ego_velocity > moving_velocity_threshold) ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@soblin I cannot check the current speed, I need a check that tells me if at some point in the PAST the ego has moved faster than the threshold speed. So this approach cannot work.

return true;
}
if (status_.planner_type != PlannerType::GEOMETRIC) {
return false;
}
Expand Down
Loading