Skip to content

Commit

Permalink
refactor(goal_planner): remove enable_safety_check because it is defa…
Browse files Browse the repository at this point in the history
…ult (#10052)

Signed-off-by: Mamoru Sobue <[email protected]>
  • Loading branch information
soblin authored Jan 31, 2025
1 parent 74f4390 commit 46ec581
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,6 @@ In addition, the safety check has a time hysteresis, and if the path is judged "

| Name | Unit | Type | Description | Default value |
| :----------------------------------- | :---- | :----- | :------------------------------------------------------------------------------------------------------- | :--------------------------- |
| enable_safety_check | [-] | bool | flag whether to use safety check | true |
| method | [-] | string | method for safety check. `RSS` or `integral_predicted_polygon` | `integral_predicted_polygon` |
| keep_unsafe_time | [s] | double | safety check Hysteresis time. if the path is judged "safe" for the time it is finally treated as "safe". | 3.0 |
| check_all_predicted_path | - | bool | Flag to check all predicted paths | true |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,22 +57,18 @@ PathDecisionState PathDecisionStateController::get_next_state(
auto next_state = current_state_;

// update safety
if (!parameters.safety_check_params.enable_safety_check) {
next_state.is_stable_safe = true;
} else {
if (is_current_safe) {
if (!next_state.safe_start_time) {
next_state.safe_start_time = now;
next_state.is_stable_safe = false;
} else {
next_state.is_stable_safe =
((now - next_state.safe_start_time.value()).seconds() >
parameters.safety_check_params.keep_unsafe_time);
}
} else {
next_state.safe_start_time = std::nullopt;
if (is_current_safe) {
if (!next_state.safe_start_time) {
next_state.safe_start_time = now;
next_state.is_stable_safe = false;
} else {
next_state.is_stable_safe =
((now - next_state.safe_start_time.value()).seconds() >
parameters.safety_check_params.keep_unsafe_time);
}
} else {
next_state.safe_start_time = std::nullopt;
next_state.is_stable_safe = false;
}

// Once this function returns true, it will continue to return true thereafter
Expand All @@ -87,10 +83,9 @@ PathDecisionState PathDecisionStateController::get_next_state(
}

const auto & pull_over_path = pull_over_path_opt.value();
const bool enable_safety_check = parameters.safety_check_params.enable_safety_check;
// If it is dangerous against dynamic objects before approval, do not determine the path.
// This eliminates a unsafe path to be approved
if (enable_safety_check && !next_state.is_stable_safe && !is_activated) {
if (!next_state.is_stable_safe && !is_activated) {
RCLCPP_DEBUG(
logger_,
"[DecidingPathStatus]: NOT_DECIDED. path is not safe against dynamic objects before "
Expand Down Expand Up @@ -132,7 +127,7 @@ PathDecisionState PathDecisionStateController::get_next_state(
return next_state;
}

if (enable_safety_check && !next_state.is_stable_safe) {
if (!next_state.is_stable_safe) {
RCLCPP_DEBUG(
logger_,
"[DecidingPathStatus]: DECIDING->NOT_DECIDED. path is not safe against dynamic objects");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,6 @@ GoalPlannerModule::GoalPlannerModule(
is_lane_parking_cb_running_{false},
is_freespace_parking_cb_running_{false}
{
// TODO(soblin): remove safety_check_params.enable_safety_check because it does not make sense
if (!parameters_.safety_check_params.enable_safety_check) {
throw std::domain_error("goal_planner never works without safety check");
}

occupancy_grid_map_ = std::make_shared<OccupancyGridBasedCollisionDetector>();

// planner when goal modification is not allowed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,10 @@ GoalPlannerParameters GoalPlannerModuleManager::initGoalPlannerParameters(
{
p.safety_check_params.enable_safety_check =
node->declare_parameter<bool>(safety_check_ns + "enable_safety_check");
// NOTE(soblin): remove safety_check_params.enable_safety_check because it does not make sense
if (!p.safety_check_params.enable_safety_check) {
throw std::domain_error("goal_planner never works without safety check");
}
p.safety_check_params.keep_unsafe_time =
node->declare_parameter<double>(safety_check_ns + "keep_unsafe_time");
p.safety_check_params.method = node->declare_parameter<std::string>(safety_check_ns + "method");
Expand Down Expand Up @@ -786,9 +790,6 @@ void GoalPlannerModuleManager::updateModuleParams(
// SafetyCheckParams
const std::string safety_check_ns = path_safety_check_ns + "safety_check_params.";
{
updateParam<bool>(
parameters, safety_check_ns + "enable_safety_check",
p->safety_check_params.enable_safety_check);
updateParam<double>(
parameters, safety_check_ns + "keep_unsafe_time", p->safety_check_params.keep_unsafe_time);
updateParam<std::string>(parameters, safety_check_ns + "method", p->safety_check_params.method);
Expand Down

0 comments on commit 46ec581

Please sign in to comment.