Skip to content

Commit

Permalink
feat(avoidance): output unconfortable path with unsafe state
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 Aug 8, 2023
1 parent 9ac8faf commit dfb242f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,15 @@ class AvoidanceModule : public SceneModuleInterface
*/
bool isSafePath(ShiftedPath & shifted_path, DebugData & debug) const;

bool isComfortable(const AvoidLineArray & shift_lines) const
{
return std::all_of(shift_lines.begin(), shift_lines.end(), [&](const auto & line) {
return PathShifter::calcJerkFromLatLonDistance(
line.getRelativeLength(), line.getRelativeLongitudinal(),
helper_.getAvoidanceEgoSpeed()) < helper_.getLateralMaxJerkLimit();
});
}

// post process

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,8 @@ struct AvoidancePlanningData

bool safe{false};

bool comfortable{false};

bool avoid_required{false};

bool yield_required{false};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ bool AvoidanceModule::isExecutionRequested() const
bool AvoidanceModule::isExecutionReady() const
{
DEBUG_PRINT("AVOIDANCE isExecutionReady");
return avoidance_data_.safe;
return avoidance_data_.safe && avoidance_data_.comfortable;
}

bool AvoidanceModule::canTransitSuccessState()
Expand Down Expand Up @@ -448,6 +448,7 @@ void AvoidanceModule::fillShiftLine(AvoidancePlanningData & data, DebugData & de
* Check avoidance path safety. For each target objects and the objects in adjacent lanes,
* check that there is a certain amount of margin in the lateral and longitudinal direction.
*/
data.comfortable = isComfortable(data.unapproved_new_sl);
data.safe = isSafePath(data.candidate_path, debug);
}

Expand Down Expand Up @@ -2369,13 +2370,6 @@ AvoidLineArray AvoidanceModule::findNewShiftLine(const AvoidLineArray & candidat
return subsequent;
};

// check jerk limit.
const auto is_large_jerk = [this](const auto & s) {
const auto jerk = PathShifter::calcJerkFromLatLonDistance(
s.getRelativeLength(), s.getRelativeLongitudinal(), helper_.getAvoidanceEgoSpeed());
return jerk > helper_.getLateralMaxJerkLimit();
};

// check ignore or not.
const auto is_ignore_shift = [this](const auto & s) {
return std::abs(helper_.getRelativeShiftToPath(s)) < parameters_->lateral_execution_threshold;
Expand All @@ -2392,10 +2386,6 @@ AvoidLineArray AvoidanceModule::findNewShiftLine(const AvoidLineArray & candidat
}

if (!is_ignore_shift(candidate)) {
if (is_large_jerk(candidate)) {
break;
}

return get_subsequent_shift(i);
}
}
Expand Down

0 comments on commit dfb242f

Please sign in to comment.