Skip to content

Commit

Permalink
feat(safety_check): add hysteresis factor in safety check logic (auto…
Browse files Browse the repository at this point in the history
…warefoundation#4735)

* feat(safety_check): add hysteresis factor

Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>

* feat(lane_change): add hysteresis factor

Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>

* feat(avoidance): add hysteresis factor

Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>

* feat(avoidance): add time series hysteresis

Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>

---------

Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>
  • Loading branch information
satoshi-ota authored and kyoichi-sugahara committed Aug 28, 2023
1 parent c36d861 commit 2119309
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,8 @@
time_resolution: 0.5 # [s]
time_horizon: 10.0 # [s]
safety_check_backward_distance: 100.0 # [m]
safety_check_hysteresis_factor: 2.0 # [-]
hysteresis_factor_expand_rate: 2.0 # [-]
hysteresis_factor_safe_count: 10 # [-]
# rss parameters
expected_front_deceleration: -1.0 # [m/ss]
expected_rear_deceleration: -1.0 # [m/ss]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,8 @@ class AvoidanceModule : public SceneModuleInterface

bool arrived_path_end_{false};

bool safe_{true};

std::shared_ptr<AvoidanceParameters> parameters_;

helper::avoidance::AvoidanceHelper helper_;
Expand All @@ -576,6 +578,8 @@ class AvoidanceModule : public SceneModuleInterface

ObjectDataArray registered_objects_;

mutable size_t safe_count_{0};

mutable ObjectDataArray ego_stopped_objects_;

mutable ObjectDataArray stopped_objects_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,8 @@ struct AvoidanceParameters
double safety_check_backward_distance;

// transit hysteresis (unsafe to safe)
double safety_check_hysteresis_factor;
size_t hysteresis_factor_safe_count;
double hysteresis_factor_expand_rate;

// keep target velocity in yield maneuver
double yield_velocity;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ bool checkCollision(
const ExtendedPredictedObject & target_object,
const PredictedPathWithPolygon & target_object_path,
const BehaviorPathPlannerParameters & common_parameters, const RSSparams & rss_parameters,
CollisionCheckDebug & debug);
const double hysteresis_factor, CollisionCheckDebug & debug);

/**
* @brief Check collision between ego path footprints with extra longitudinal stopping margin and
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1869,6 +1869,8 @@ bool AvoidanceModule::isSafePath(
return true;
}

const auto hysteresis_factor = safe_ ? 1.0 : parameters_->hysteresis_factor_expand_rate;

const auto safety_check_target_objects = utils::avoidance::getSafetyCheckTargetObjects(
avoid_data_, planner_data_, parameters_, is_right_shift.value());

Expand All @@ -1879,13 +1881,16 @@ bool AvoidanceModule::isSafePath(
CollisionCheckDebug collision{};
if (!utils::path_safety_checker::checkCollision(
shifted_path.path, ego_predicted_path, object, obj_path, p, parameters_->rss_params,
collision)) {
hysteresis_factor, collision)) {
safe_count_ = 0;
return false;
}
}
}

return true;
safe_count_++;

return safe_ || safe_count_ > parameters_->hysteresis_factor_safe_count;
}

void AvoidanceModule::generateExtendedDrivableArea(BehaviorModuleOutput & output) const
Expand Down Expand Up @@ -2505,6 +2510,8 @@ void AvoidanceModule::updateData()

// update rtc status.
updateRTCData();

safe_ = avoid_data_.safe;
}

void AvoidanceModule::processOnEntry()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,9 @@ AvoidanceModuleManager::AvoidanceModuleManager(
p.safety_check_time_resolution = get_parameter<double>(node, ns + "time_resolution");
p.safety_check_backward_distance =
get_parameter<double>(node, ns + "safety_check_backward_distance");
p.safety_check_hysteresis_factor =
get_parameter<double>(node, ns + "safety_check_hysteresis_factor");
p.hysteresis_factor_expand_rate =
get_parameter<double>(node, ns + "hysteresis_factor_expand_rate");
p.hysteresis_factor_safe_count = get_parameter<int>(node, ns + "hysteresis_factor_safe_count");
}

// safety check rss params
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,8 @@ AvoidanceByLaneChangeModuleManager::AvoidanceByLaneChangeModuleManager(
// safety check
{
std::string ns = "avoidance.safety_check.";
p.safety_check_hysteresis_factor =
get_parameter<double>(node, ns + "safety_check_hysteresis_factor");
p.hysteresis_factor_expand_rate =
get_parameter<double>(node, ns + "hysteresis_factor_expand_rate");
}

avoidance_parameters_ = std::make_shared<AvoidanceByLCParameters>(p);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1380,7 +1380,7 @@ PathSafetyStatus NormalLaneChange::isLaneChangePathSafe(
obj, lane_change_parameters_->use_all_predicted_path);
for (const auto & obj_path : obj_predicted_paths) {
if (!utils::path_safety_checker::checkCollision(
path, ego_predicted_path, obj, obj_path, common_parameters, rss_params,
path, ego_predicted_path, obj, obj_path, common_parameters, rss_params, 1.0,
current_debug_data.second)) {
path_safety_status.is_safe = false;
updateDebugInfo(current_debug_data, path_safety_status.is_safe);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -771,7 +771,7 @@ void fillAvoidanceNecessity(
}

// TRUE -> ? (check with hysteresis factor)
object_data.avoid_required = check_necessity(parameters->safety_check_hysteresis_factor);
object_data.avoid_required = check_necessity(parameters->hysteresis_factor_expand_rate);
}

void fillObjectStoppableJudge(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ bool checkCollision(
const ExtendedPredictedObject & target_object,
const PredictedPathWithPolygon & target_object_path,
const BehaviorPathPlannerParameters & common_parameters, const RSSparams & rss_parameters,
CollisionCheckDebug & debug)
double hysteresis_factor, CollisionCheckDebug & debug)
{
debug.lerped_path.reserve(target_object_path.path.size());

Expand Down Expand Up @@ -286,8 +286,8 @@ bool checkCollision(
const auto min_lon_length =
calcMinimumLongitudinalLength(front_object_velocity, rear_object_velocity, rss_parameters);

const auto & lon_offset = std::max(rss_dist, min_lon_length);
const auto & lat_margin = rss_parameters.lateral_distance_max_threshold;
const auto & lon_offset = std::max(rss_dist, min_lon_length) * hysteresis_factor;
const auto & lat_margin = rss_parameters.lateral_distance_max_threshold * hysteresis_factor;
const auto & extended_ego_polygon =
is_object_front
? createExtendedPolygon(ego_pose, ego_vehicle_info, lon_offset, lat_margin, debug)
Expand Down

0 comments on commit 2119309

Please sign in to comment.