Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(goal_planner): remove enable_safety_check because it is default #10052

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
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 =

Check warning on line 65 in planning/behavior_path_planner/autoware_behavior_path_goal_planner_module/src/decision_state.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_planner/autoware_behavior_path_goal_planner_module/src/decision_state.cpp#L65

Added line #L65 was not covered by tests
((now - next_state.safe_start_time.value()).seconds() >
parameters.safety_check_params.keep_unsafe_time);

Check warning on line 67 in planning/behavior_path_planner/autoware_behavior_path_goal_planner_module/src/decision_state.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_planner/autoware_behavior_path_goal_planner_module/src/decision_state.cpp#L67

Added line #L67 was not covered by tests
}
} else {
next_state.safe_start_time = std::nullopt;
next_state.is_stable_safe = false;

Check warning on line 71 in planning/behavior_path_planner/autoware_behavior_path_goal_planner_module/src/decision_state.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_planner/autoware_behavior_path_goal_planner_module/src/decision_state.cpp#L71

Added line #L71 was not covered by tests
}

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

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) {

Check notice on line 88 in planning/behavior_path_planner/autoware_behavior_path_goal_planner_module/src/decision_state.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

✅ No longer an issue: Complex Conditional

PathDecisionStateController::get_next_state no longer has a complex conditional
RCLCPP_DEBUG(
logger_,
"[DecidingPathStatus]: NOT_DECIDED. path is not safe against dynamic objects before "
Expand Down Expand Up @@ -132,7 +127,7 @@
return next_state;
}

if (enable_safety_check && !next_state.is_stable_safe) {
if (!next_state.is_stable_safe) {

Check notice on line 130 in planning/behavior_path_planner/autoware_behavior_path_goal_planner_module/src/decision_state.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

✅ Getting better: Complex Method

PathDecisionStateController::get_next_state decreases in cyclomatic complexity from 18 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.
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
@@ -1,4 +1,4 @@
// Copyright 2023 TIER IV, Inc.

Check notice on line 1 in planning/behavior_path_planner/autoware_behavior_path_goal_planner_module/src/manager.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

✅ No longer an issue: Large Method

GoalPlannerModuleManager::initGoalPlannerParameters is no longer above the threshold for lines of code. Large functions with many lines of code are generally harder to understand and lower the code health. Avoid adding more lines to this function.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -368,6 +368,10 @@
{
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");
}

Check warning on line 374 in planning/behavior_path_planner/autoware_behavior_path_goal_planner_module/src/manager.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

❌ New issue: Complex Method

GoalPlannerModuleManager::initGoalPlannerParameters has a cyclomatic complexity of 9, 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.
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 @@ -785,10 +789,7 @@

// SafetyCheckParams
const std::string safety_check_ns = path_safety_check_ns + "safety_check_params.";
{

Check notice on line 792 in planning/behavior_path_planner/autoware_behavior_path_goal_planner_module/src/manager.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

✅ Getting better: Large Method

GoalPlannerModuleManager::updateModuleParams decreases from 353 to 350 lines of code, threshold = 70. Large functions with many lines of code are generally harder to understand and lower the code health. Avoid adding more lines to this function.
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
Loading