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 Dec 1, 2023
1 parent 981fc10 commit b5b5bb3
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 @@ -231,6 +231,10 @@
stop_buffer: 1.0 # [m]

policy:
# policy for rtc request. select "per_shift_line" or "per_avoidance_maneuver".
# "per_shift_line": request approval for each shift line.
# "per_avoidance_maneuver": request approval for avoidance maneuver (avoid + return).
make_approval_request: "per_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 @@ -285,6 +285,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 @@ -292,6 +292,7 @@ AvoidanceModuleManager::AvoidanceModuleManager(
// policy
{
std::string ns = "avoidance.policy.";
p.policy_approval = getOrDeclareParameter<std::string>(*node, ns + "approval");

Check warning on line 295 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 288 to 289. 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
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ bool isBestEffort(const std::string & policy)
return policy == "best_effort";
}

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

AvoidLine merge(const AvoidLine & line1, const AvoidLine & line2, const UUID id)
{
AvoidLine ret{};
Expand Down Expand Up @@ -1213,11 +1218,18 @@ AvoidLineArray ShiftLineGenerator::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;
}

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

const auto new_shift_lines = get_subsequent_shift(i);
debug.step4_new_shift_line = new_shift_lines;
return new_shift_lines;

Check warning on line 1232 in planning/behavior_path_planner/src/utils/avoidance/shift_line_generator.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

❌ Getting worse: Complex Method

ShiftLineGenerator::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.
}

return {};
Expand Down

0 comments on commit b5b5bb3

Please sign in to comment.