Skip to content

Commit

Permalink
fix(avoidance): output invalid avoidance path
Browse files Browse the repository at this point in the history
Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>
  • Loading branch information
satoshi-ota committed Nov 28, 2023
1 parent e3eb285 commit 7e4a740
Showing 1 changed file with 3 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ bool AvoidanceModule::isExecutionRequested() const
bool AvoidanceModule::isExecutionReady() const
{
DEBUG_PRINT("AVOIDANCE isExecutionReady");
return avoid_data_.safe && avoid_data_.comfortable;
return avoid_data_.safe && avoid_data_.comfortable && avoid_data_.valid;
}

bool AvoidanceModule::canTransitSuccessState()
Expand Down Expand Up @@ -450,15 +450,14 @@ void AvoidanceModule::fillShiftLine(AvoidancePlanningData & data, DebugData & de
* STEP1: Create candidate shift lines.
* Merge rough shift lines, and extract new shift lines.
*/
const auto processed_shift_lines = generator_.generate(data, debug);
data.new_shift_line = generator_.generate(data, debug);

/**
* Step2: Validate new shift lines.
* Output new shift lines only when the avoidance path which is generated from them doesn't have
* huge offset from ego.
*/
data.valid = isValidShiftLine(processed_shift_lines, path_shifter);
data.new_shift_line = data.valid ? processed_shift_lines : AvoidLineArray{};
data.valid = isValidShiftLine(data.new_shift_line, path_shifter);
const auto found_new_sl = data.new_shift_line.size() > 0;
const auto registered = path_shifter.getShiftLines().size() > 0;
data.found_avoidance_path = found_new_sl || registered;
Expand Down Expand Up @@ -494,17 +493,6 @@ void AvoidanceModule::fillShiftLine(AvoidancePlanningData & data, DebugData & de
void AvoidanceModule::fillEgoStatus(
AvoidancePlanningData & data, [[maybe_unused]] DebugData & debug) const
{

Check notice on line 495 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 better: Complex Method

AvoidanceModule::fillEgoStatus decreases in cyclomatic complexity from 11 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.
/**
* TODO(someone): prevent meaningless stop point insertion in other way.
* If the candidate shift line is invalid, manage all objects as unavoidable.
*/
if (!data.valid) {
std::for_each(data.target_objects.begin(), data.target_objects.end(), [](auto & o) {
o.is_avoidable = false;
o.reason = "InvalidShiftLine";
});
}

/**
* Find the nearest object that should be avoid. When the ego follows reference path,
* if the both of following two conditions are satisfied, the module surely avoid the object.
Expand Down

0 comments on commit 7e4a740

Please sign in to comment.