Skip to content

Commit

Permalink
feat(avoidance): keep stopping until all shift lines are registered
Browse files Browse the repository at this point in the history
Signed-off-by: satoshi-ota <[email protected]>
  • Loading branch information
satoshi-ota committed Nov 23, 2023
1 parent c171d1c commit abf7691
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,10 @@
stop_buffer: 1.0 # [m]

policy:
# policy for rtc request. select "shift_line" or "maneuver".
# "shift_line": request approval for each shift line.
# "maneuver": request approval for avoidance maneuver (avoid + return).
approval: "shift_line"
# policy for vehicle slow down behavior. select "best_effort" or "reliable".
# "best_effort": slow down deceleration & jerk are limited by constraints.
# but there is a possibility that the vehicle can't stop in front of the vehicle.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,9 @@ struct AvoidanceParameters
// policy
bool use_shorten_margin_immediately{false};

// policy
std::string policy_approval{"shift_line"};

// policy
std::string policy_deceleration{"best_effort"};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ bool isBestEffort(const std::string & policy)
return policy == "best_effort";
}

bool perManeuver(const std::string & policy)
{
return policy == "maneuver";
}

AvoidLine merge(const AvoidLine & line1, const AvoidLine & line2, const uint64_t id)
{
AvoidLine ret{};
Expand Down Expand Up @@ -2434,11 +2439,18 @@ AvoidLineArray AvoidanceModule::findNewShiftLine(
break;
}

if (!is_ignore_shift(candidate)) {
const auto new_shift_lines = get_subsequent_shift(i);
debug.step4_new_shift_line = new_shift_lines;
return new_shift_lines;
if (is_ignore_shift(candidate)) {
continue;

Check warning on line 2443 in planning/behavior_path_planner/src/scene_module/avoidance/avoidance_module.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_planner/src/scene_module/avoidance/avoidance_module.cpp#L2443

Added line #L2443 was not covered by tests
}

if (perManeuver(parameters_->policy_approval)) {
debug.step4_new_shift_line = shift_lines;
return shift_lines;

Check warning on line 2448 in planning/behavior_path_planner/src/scene_module/avoidance/avoidance_module.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_planner/src/scene_module/avoidance/avoidance_module.cpp#L2447-L2448

Added lines #L2447 - L2448 were not covered by tests
}

const auto new_shift_lines = get_subsequent_shift(i);

Check warning on line 2451 in planning/behavior_path_planner/src/scene_module/avoidance/avoidance_module.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_planner/src/scene_module/avoidance/avoidance_module.cpp#L2451

Added line #L2451 was not covered by tests
debug.step4_new_shift_line = new_shift_lines;
return new_shift_lines;

Check warning on line 2453 in planning/behavior_path_planner/src/scene_module/avoidance/avoidance_module.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

❌ Getting worse: Complex Method

AvoidanceModule::findNewShiftLine increases in cyclomatic complexity from 13 to 15, 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.
}

DEBUG_PRINT("No new shift point exists.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ AvoidanceModuleManager::AvoidanceModuleManager(
// policy
{
std::string ns = "avoidance.policy.";
p.policy_approval = getOrDeclareParameter<std::string>(*node, ns + "approval");

Check warning on line 260 in planning/behavior_path_planner/src/scene_module/avoidance/manager.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

❌ Getting worse: Complex Method

AvoidanceModuleManager::AvoidanceModuleManager already has high cyclomatic complexity, and now it increases in Lines of Code from 257 to 258. 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.
p.policy_deceleration = getOrDeclareParameter<std::string>(*node, ns + "deceleration");
p.policy_lateral_margin = getOrDeclareParameter<std::string>(*node, ns + "lateral_margin");
p.use_shorten_margin_immediately =
Expand Down

0 comments on commit abf7691

Please sign in to comment.