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

feat(goal_planner): add deciding status to check collision for for a certain period of time #6128

Merged
merged 4 commits into from
Jan 23, 2024
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 @@ -230,6 +230,13 @@
Pose pose{};
};

enum class DecidingPathStatus {
NOT_DECIDED,
DECIDING,
DECIDED,
};
using DecidingPathStatusWithStamp = std::pair<DecidingPathStatus, rclcpp::Time>;

struct PreviousPullOverData
{
struct SafetyStatus
Expand All @@ -242,12 +249,12 @@
{
found_path = false;
safety_status = SafetyStatus{};
has_decided_path = false;
deciding_path_status = DecidingPathStatusWithStamp{};

Check warning on line 252 in planning/behavior_path_goal_planner_module/include/behavior_path_goal_planner_module/goal_planner_module.hpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_goal_planner_module/include/behavior_path_goal_planner_module/goal_planner_module.hpp#L252

Added line #L252 was not covered by tests
}

bool found_path{false};
SafetyStatus safety_status{};
bool has_decided_path{false};
DecidingPathStatusWithStamp deciding_path_status{};
};

// store stop_pose_ pointer with reason string
Expand Down Expand Up @@ -439,6 +446,8 @@
bool needPathUpdate(const double path_update_duration) const;
bool isStuck();
bool hasDecidedPath() const;
bool hasNotDecidedPath() const;
DecidingPathStatusWithStamp checkDecidingPathStatus() const;
void decideVelocity();
bool foundPullOverPath() const;
void updateStatus(const BehaviorModuleOutput & output);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,13 @@ class GoalSearcher : public GoalSearcherBase

GoalCandidates search() override;
void update(GoalCandidates & goal_candidates) const override;

// todo(kosuke55): Functions for this specific use should not be in the interface,
// so it is better to consider interface design when we implement other goal searchers.
GoalCandidate getClosetGoalCandidateAlongLanes(
const GoalCandidates & goal_candidates) const override;
bool isSafeGoalWithMarginScaleFactor(
const GoalCandidate & goal_candidate, const double margin_scale_factor) const override;

private:
void countObjectsToAvoid(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ class GoalSearcherBase
virtual void update([[maybe_unused]] GoalCandidates & goal_candidates) const { return; }
virtual GoalCandidate getClosetGoalCandidateAlongLanes(
const GoalCandidates & goal_candidates) const = 0;
virtual bool isSafeGoalWithMarginScaleFactor(
const GoalCandidate & goal_candidate, const double margin_scale_factor) const = 0;

protected:
GoalPlannerParameters parameters_{};
Expand Down
105 changes: 89 additions & 16 deletions planning/behavior_path_goal_planner_module/src/goal_planner_module.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2021 Tier IV, Inc.

Check notice on line 1 in planning/behavior_path_goal_planner_module/src/goal_planner_module.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

ℹ Getting worse: Lines of Code in a Single File

The lines of code increases from 1507 to 1563, improve code health by reducing it to 1000. The number of Lines of Code in a single file. More Lines of Code lowers the code health.

Check notice on line 1 in planning/behavior_path_goal_planner_module/src/goal_planner_module.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

✅ No longer an issue: Complex Conditional

GoalPlannerModule::hasDecidedPath no longer has a complex conditional. A complex conditional is an expression inside a branch (e.g. if, for, while) which consists of multiple, logical operators such as AND/OR. The more logical operators in an expression, the more severe the code smell.

Check notice on line 1 in planning/behavior_path_goal_planner_module/src/goal_planner_module.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

ℹ New issue: Complex Conditional

GoalPlannerModule::checkDecidingPathStatus has 1 complex conditionals with 2 branches, threshold = 2. A complex conditional is an expression inside a branch (e.g. if, for, while) which consists of multiple, logical operators such as AND/OR. The more logical operators in an expression, the more severe the code smell.

Check notice on line 1 in planning/behavior_path_goal_planner_module/src/goal_planner_module.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

✅ Getting better: Overall Code Complexity

The mean cyclomatic complexity decreases from 4.81 to 4.80, threshold = 4. This file has many conditional statements (e.g. if, for, while) across its implementation, leading to lower code health. Avoid adding more conditionals.
//
// 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 @@ -806,8 +806,8 @@

if (!thread_safe_data_.foundPullOverPath()) {
// situation : not safe against static objects use stop_path
output.path = generateStopPath();
RCLCPP_WARN_THROTTLE(

Check warning on line 810 in planning/behavior_path_goal_planner_module/src/goal_planner_module.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_goal_planner_module/src/goal_planner_module.cpp#L809-L810

Added lines #L809 - L810 were not covered by tests
getLogger(), *clock_, 5000, "Not found safe pull_over path, generate stop path");
setDrivableAreaInfo(output);
return;
Expand All @@ -819,10 +819,10 @@
// insert stop point in current path if ego is able to stop with acceleration and jerk
// constraints
output.path =
generateFeasibleStopPath(thread_safe_data_.get_pull_over_path()->getCurrentPath());
RCLCPP_WARN_THROTTLE(

Check warning on line 823 in planning/behavior_path_goal_planner_module/src/goal_planner_module.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_goal_planner_module/src/goal_planner_module.cpp#L822-L823

Added lines #L822 - L823 were not covered by tests
getLogger(), *clock_, 5000, "Not safe against dynamic objects, generate stop path");
debug_stop_pose_with_info_.set(std::string("feasible stop after approval"));

Check warning on line 825 in planning/behavior_path_goal_planner_module/src/goal_planner_module.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_goal_planner_module/src/goal_planner_module.cpp#L825

Added line #L825 was not covered by tests
} else {
// situation : (safe against static and dynamic objects) or (safe against static objects and
// before approval) don't stop
Expand Down Expand Up @@ -903,36 +903,108 @@

bool GoalPlannerModule::hasDecidedPath() const
{
return checkDecidingPathStatus().first == DecidingPathStatus::DECIDED;

Check warning on line 906 in planning/behavior_path_goal_planner_module/src/goal_planner_module.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_goal_planner_module/src/goal_planner_module.cpp#L906

Added line #L906 was not covered by tests
}

bool GoalPlannerModule::hasNotDecidedPath() const

Check warning on line 909 in planning/behavior_path_goal_planner_module/src/goal_planner_module.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_goal_planner_module/src/goal_planner_module.cpp#L909

Added line #L909 was not covered by tests
{
return checkDecidingPathStatus().first == DecidingPathStatus::NOT_DECIDED;

Check warning on line 911 in planning/behavior_path_goal_planner_module/src/goal_planner_module.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_goal_planner_module/src/goal_planner_module.cpp#L911

Added line #L911 was not covered by tests
}

DecidingPathStatusWithStamp GoalPlannerModule::checkDecidingPathStatus() const

Check warning on line 914 in planning/behavior_path_goal_planner_module/src/goal_planner_module.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_goal_planner_module/src/goal_planner_module.cpp#L914

Added line #L914 was not covered by tests
{
const auto & prev_status = prev_data_.deciding_path_status;

// Once this function returns true, it will continue to return true thereafter
if (prev_data_.has_decided_path) {
return true;
if (prev_status.first == DecidingPathStatus::DECIDED) {

Check warning on line 919 in planning/behavior_path_goal_planner_module/src/goal_planner_module.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_goal_planner_module/src/goal_planner_module.cpp#L919

Added line #L919 was not covered by tests
return prev_status;
}

// if path is not safe, not decided
if (!thread_safe_data_.foundPullOverPath()) {
return false;
return {DecidingPathStatus::NOT_DECIDED, clock_->now()};

Check warning on line 925 in planning/behavior_path_goal_planner_module/src/goal_planner_module.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_goal_planner_module/src/goal_planner_module.cpp#L925

Added line #L925 was not covered by tests
}

// If it is dangerous before approval, do not determine the path.
// If it is dangerous against dynamic objects before approval, do not determine the path.
// This eliminates a unsafe path to be approved
if (
parameters_->safety_check_params.enable_safety_check && !isSafePath().first && !isActivated()) {
return false;
RCLCPP_DEBUG(

Check warning on line 932 in planning/behavior_path_goal_planner_module/src/goal_planner_module.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_goal_planner_module/src/goal_planner_module.cpp#L932

Added line #L932 was not covered by tests
getLogger(),
"[DecidingPathStatus]: NOT_DECIDED. path is not safe against dynamic objects before "
"approval");
return {DecidingPathStatus::NOT_DECIDED, clock_->now()};

Check warning on line 936 in planning/behavior_path_goal_planner_module/src/goal_planner_module.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_goal_planner_module/src/goal_planner_module.cpp#L936

Added line #L936 was not covered by tests
}

// if object recognition for path collision check is enabled, transition to DECIDED after
// DECIDING for a certain period of time if there is no collision.
const auto pull_over_path = thread_safe_data_.get_pull_over_path();
const auto current_path = pull_over_path->getCurrentPath();
if (prev_status.first == DecidingPathStatus::DECIDING) {

Check warning on line 943 in planning/behavior_path_goal_planner_module/src/goal_planner_module.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_goal_planner_module/src/goal_planner_module.cpp#L941-L943

Added lines #L941 - L943 were not covered by tests
const double hysteresis_factor = 0.9;

// check goal pose collision
goal_searcher_->setPlannerData(planner_data_);
const auto modified_goal_opt = thread_safe_data_.get_modified_goal_pose();
if (
modified_goal_opt && !goal_searcher_->isSafeGoalWithMarginScaleFactor(

Check warning on line 950 in planning/behavior_path_goal_planner_module/src/goal_planner_module.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_goal_planner_module/src/goal_planner_module.cpp#L950

Added line #L950 was not covered by tests
modified_goal_opt.value(), hysteresis_factor)) {
RCLCPP_DEBUG(getLogger(), "[DecidingPathStatus]: DECIDING->NOT_DECIDED. goal is not safe");
return {DecidingPathStatus::NOT_DECIDED, clock_->now()};

Check warning on line 953 in planning/behavior_path_goal_planner_module/src/goal_planner_module.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_goal_planner_module/src/goal_planner_module.cpp#L952-L953

Added lines #L952 - L953 were not covered by tests
}

// check current parking path collision
const auto parking_path = utils::resamplePathWithSpline(pull_over_path->getParkingPath(), 0.5);

Check warning on line 957 in planning/behavior_path_goal_planner_module/src/goal_planner_module.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_goal_planner_module/src/goal_planner_module.cpp#L957

Added line #L957 was not covered by tests
const double margin =
parameters_->object_recognition_collision_check_margin * hysteresis_factor;
if (checkObjectsCollision(parking_path, margin)) {
RCLCPP_DEBUG(

Check warning on line 961 in planning/behavior_path_goal_planner_module/src/goal_planner_module.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_goal_planner_module/src/goal_planner_module.cpp#L959-L961

Added lines #L959 - L961 were not covered by tests
getLogger(),
"[DecidingPathStatus]: DECIDING->NOT_DECIDED. path has collision with objects");
return {DecidingPathStatus::NOT_DECIDED, clock_->now()};

Check warning on line 964 in planning/behavior_path_goal_planner_module/src/goal_planner_module.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_goal_planner_module/src/goal_planner_module.cpp#L964

Added line #L964 was not covered by tests
}

// if enough time has passed since deciding status starts, transition to DECIDED
constexpr double check_collision_duration = 1.0;
const double elapsed_time_from_deciding = (clock_->now() - prev_status.second).seconds();
if (elapsed_time_from_deciding > check_collision_duration) {
RCLCPP_DEBUG(

Check warning on line 971 in planning/behavior_path_goal_planner_module/src/goal_planner_module.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_goal_planner_module/src/goal_planner_module.cpp#L969-L971

Added lines #L969 - L971 were not covered by tests
getLogger(), "[DecidingPathStatus]: DECIDING->DECIDED. has enough safe time passed");
return {DecidingPathStatus::DECIDED, clock_->now()};

Check warning on line 973 in planning/behavior_path_goal_planner_module/src/goal_planner_module.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_goal_planner_module/src/goal_planner_module.cpp#L973

Added line #L973 was not covered by tests
}

// if enough time has NOT passed since deciding status starts, keep DECIDING
RCLCPP_DEBUG(

Check warning on line 977 in planning/behavior_path_goal_planner_module/src/goal_planner_module.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_goal_planner_module/src/goal_planner_module.cpp#L977

Added line #L977 was not covered by tests
getLogger(), "[DecidingPathStatus]: keep DECIDING. elapsed_time_from_deciding: %f",
elapsed_time_from_deciding);
return prev_status;
}

// if ego is sufficiently close to the start of the nearest candidate path, the path is decided
const auto & current_pose = planner_data_->self_odometry->pose.pose;
const size_t ego_segment_idx = motion_utils::findNearestSegmentIndex(
thread_safe_data_.get_pull_over_path()->getCurrentPath().points, current_pose.position);
const size_t ego_segment_idx =
motion_utils::findNearestSegmentIndex(current_path.points, current_pose.position);

Check warning on line 986 in planning/behavior_path_goal_planner_module/src/goal_planner_module.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_goal_planner_module/src/goal_planner_module.cpp#L986

Added line #L986 was not covered by tests

const size_t start_pose_segment_idx = motion_utils::findNearestSegmentIndex(
thread_safe_data_.get_pull_over_path()->getCurrentPath().points,
thread_safe_data_.get_pull_over_path()->start_pose.position);
const size_t start_pose_segment_idx =
motion_utils::findNearestSegmentIndex(current_path.points, pull_over_path->start_pose.position);

Check warning on line 989 in planning/behavior_path_goal_planner_module/src/goal_planner_module.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_goal_planner_module/src/goal_planner_module.cpp#L989

Added line #L989 was not covered by tests
const double dist_to_parking_start_pose = calcSignedArcLength(
thread_safe_data_.get_pull_over_path()->getCurrentPath().points, current_pose.position,
ego_segment_idx, thread_safe_data_.get_pull_over_path()->start_pose.position,
start_pose_segment_idx);
return dist_to_parking_start_pose < parameters_->decide_path_distance;
current_path.points, current_pose.position, ego_segment_idx,
pull_over_path->start_pose.position, start_pose_segment_idx);
if (dist_to_parking_start_pose > parameters_->decide_path_distance) {
return {DecidingPathStatus::NOT_DECIDED, clock_->now()};

Check warning on line 994 in planning/behavior_path_goal_planner_module/src/goal_planner_module.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_goal_planner_module/src/goal_planner_module.cpp#L992-L994

Added lines #L992 - L994 were not covered by tests
}

// if object recognition for path collision check is enabled, transition to DECIDING to check
// collision for a certain period of time. Otherwise, transition to DECIDED directly.
if (parameters_->use_object_recognition) {
RCLCPP_DEBUG(

Check warning on line 1000 in planning/behavior_path_goal_planner_module/src/goal_planner_module.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_goal_planner_module/src/goal_planner_module.cpp#L999-L1000

Added lines #L999 - L1000 were not covered by tests
getLogger(),
"[DecidingPathStatus]: NOT_DECIDED->DECIDING. start checking collision for certain "
"period of time");
return {DecidingPathStatus::DECIDING, clock_->now()};

Check warning on line 1004 in planning/behavior_path_goal_planner_module/src/goal_planner_module.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_goal_planner_module/src/goal_planner_module.cpp#L1004

Added line #L1004 was not covered by tests
}
RCLCPP_DEBUG(getLogger(), "[DecidingPathStatus]: NOT_DECIDED->DECIDED");
return {DecidingPathStatus::DECIDED, clock_->now()};

Check warning on line 1007 in planning/behavior_path_goal_planner_module/src/goal_planner_module.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

❌ New issue: Complex Method

GoalPlannerModule::checkDecidingPathStatus has a cyclomatic complexity of 13, 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.

Check warning on line 1007 in planning/behavior_path_goal_planner_module/src/goal_planner_module.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_goal_planner_module/src/goal_planner_module.cpp#L1006-L1007

Added lines #L1006 - L1007 were not covered by tests
}

void GoalPlannerModule::decideVelocity()
Expand Down Expand Up @@ -993,10 +1065,11 @@
return getPreviousModuleOutput();
}

if (!hasDecidedPath() && needPathUpdate(1.0 /*path_update_duration*/)) {
if (hasNotDecidedPath() && needPathUpdate(1.0 /*path_update_duration*/)) {

Check warning on line 1068 in planning/behavior_path_goal_planner_module/src/goal_planner_module.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_goal_planner_module/src/goal_planner_module.cpp#L1068

Added line #L1068 was not covered by tests
// if the final path is not decided and enough time has passed since last path update,
// select safe path from lane parking pull over path candidates
// and set it to thread_safe_data_
RCLCPP_DEBUG(getLogger(), "Update pull over path candidates");

Check warning on line 1072 in planning/behavior_path_goal_planner_module/src/goal_planner_module.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_goal_planner_module/src/goal_planner_module.cpp#L1072

Added line #L1072 was not covered by tests

thread_safe_data_.clearPullOverPath();

Expand Down Expand Up @@ -1050,7 +1123,7 @@
path_candidate_ =
std::make_shared<PathWithLaneId>(thread_safe_data_.get_pull_over_path()->getFullPath());

updatePreviousData();

Check warning on line 1126 in planning/behavior_path_goal_planner_module/src/goal_planner_module.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_goal_planner_module/src/goal_planner_module.cpp#L1126

Added line #L1126 was not covered by tests

return output;
}
Expand All @@ -1077,13 +1150,13 @@
setStopReason(StopReason::GOAL_PLANNER, thread_safe_data_.get_pull_over_path()->getFullPath());
}

void GoalPlannerModule::updatePreviousData()

Check warning on line 1153 in planning/behavior_path_goal_planner_module/src/goal_planner_module.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_goal_planner_module/src/goal_planner_module.cpp#L1153

Added line #L1153 was not covered by tests
{
// for the next loop setOutput().
// this is used to determine whether to generate a new stop path or keep the current stop path.
prev_data_.found_path = thread_safe_data_.foundPullOverPath();

prev_data_.has_decided_path = hasDecidedPath();
prev_data_.deciding_path_status = checkDecidingPathStatus();

Check warning on line 1159 in planning/behavior_path_goal_planner_module/src/goal_planner_module.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_goal_planner_module/src/goal_planner_module.cpp#L1159

Added line #L1159 was not covered by tests

// This is related to safety check, so if it is disabled, return here.
if (!parameters_->safety_check_params.enable_safety_check) {
Expand Down Expand Up @@ -1208,7 +1281,7 @@
return std::make_pair(decel_pose.value(), "stop at search start pose");
});
if (!stop_pose_with_info) {
const auto feasible_stop_path = generateFeasibleStopPath(getPreviousModuleOutput().path);

Check warning on line 1284 in planning/behavior_path_goal_planner_module/src/goal_planner_module.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_goal_planner_module/src/goal_planner_module.cpp#L1284

Added line #L1284 was not covered by tests
// override stop pose info debug string
debug_stop_pose_with_info_.set(std::string("feasible stop: not calculate stop pose"));
return feasible_stop_path;
Expand All @@ -1223,7 +1296,7 @@
const bool is_stopped = std::abs(current_vel) < eps_vel;
const double buffer = is_stopped ? stop_distance_buffer_ : 0.0;
if (min_stop_distance && ego_to_stop_distance + buffer < *min_stop_distance) {
const auto feasible_stop_path = generateFeasibleStopPath(getPreviousModuleOutput().path);

Check warning on line 1299 in planning/behavior_path_goal_planner_module/src/goal_planner_module.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_goal_planner_module/src/goal_planner_module.cpp#L1299

Added line #L1299 was not covered by tests
debug_stop_pose_with_info_.set(
std::string("feasible stop: stop pose is closer than min_stop_distance"));
return feasible_stop_path;
Expand Down Expand Up @@ -1255,17 +1328,17 @@
return stop_path;
}

PathWithLaneId GoalPlannerModule::generateFeasibleStopPath(const PathWithLaneId & path) const

Check warning on line 1331 in planning/behavior_path_goal_planner_module/src/goal_planner_module.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_goal_planner_module/src/goal_planner_module.cpp#L1331

Added line #L1331 was not covered by tests
{
// calc minimum stop distance under maximum deceleration
const auto min_stop_distance = calcFeasibleDecelDistance(
planner_data_, parameters_->maximum_deceleration, parameters_->maximum_jerk, 0.0);
if (!min_stop_distance) {
return path;

Check warning on line 1337 in planning/behavior_path_goal_planner_module/src/goal_planner_module.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_goal_planner_module/src/goal_planner_module.cpp#L1337

Added line #L1337 was not covered by tests
}

// set stop point
auto stop_path = path;

Check warning on line 1341 in planning/behavior_path_goal_planner_module/src/goal_planner_module.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_goal_planner_module/src/goal_planner_module.cpp#L1341

Added line #L1341 was not covered by tests
const auto & current_pose = planner_data_->self_odometry->pose.pose;
const auto stop_idx =
motion_utils::insertStopPoint(current_pose, *min_stop_distance, stop_path.points);
Expand Down Expand Up @@ -1450,9 +1523,9 @@
{
const auto pull_over_lane_stop_objects =
goal_planner_utils::extractStaticObjectsInExpandedPullOverLanes(
*(planner_data_->route_handler), left_side_parking_, parameters_->backward_goal_search_length,

Check warning on line 1526 in planning/behavior_path_goal_planner_module/src/goal_planner_module.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_goal_planner_module/src/goal_planner_module.cpp#L1526

Added line #L1526 was not covered by tests
parameters_->forward_goal_search_length, parameters_->detection_bound_offset,
*(planner_data_->dynamic_object), parameters_->th_moving_object_velocity);

Check warning on line 1528 in planning/behavior_path_goal_planner_module/src/goal_planner_module.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_goal_planner_module/src/goal_planner_module.cpp#L1528

Added line #L1528 was not covered by tests

std::vector<Polygon2d> obj_polygons;
for (const auto & object : pull_over_lane_stop_objects.objects) {
Expand Down
37 changes: 37 additions & 0 deletions planning/behavior_path_goal_planner_module/src/goal_searcher.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2022 TIER IV, Inc.

Check notice on line 1 in planning/behavior_path_goal_planner_module/src/goal_searcher.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

✅ Getting better: Overall Code Complexity

The mean cyclomatic complexity decreases from 4.93 to 4.87, threshold = 4. This file has many conditional statements (e.g. if, for, while) across its implementation, leading to lower code health. Avoid adding more conditionals.
//
// 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 @@ -268,9 +268,9 @@
{
const auto pull_over_lane_stop_objects =
goal_planner_utils::extractStaticObjectsInExpandedPullOverLanes(
*(planner_data_->route_handler), left_side_parking_, parameters_.backward_goal_search_length,
parameters_.forward_goal_search_length, parameters_.detection_bound_offset,
*(planner_data_->dynamic_object), parameters_.th_moving_object_velocity);

Check warning on line 273 in planning/behavior_path_goal_planner_module/src/goal_searcher.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_goal_planner_module/src/goal_searcher.cpp#L271-L273

Added lines #L271 - L273 were not covered by tests

if (parameters_.prioritize_goals_before_objects) {
countObjectsToAvoid(goal_candidates, pull_over_lane_stop_objects);
Expand Down Expand Up @@ -312,6 +312,43 @@
}
}

// Note: this function is not just return goal_candidate.is_safe but check collision with
// current planner_data_ and margin scale factor.
// And is_safe is not updated in this function.
bool GoalSearcher::isSafeGoalWithMarginScaleFactor(

Check warning on line 318 in planning/behavior_path_goal_planner_module/src/goal_searcher.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_goal_planner_module/src/goal_searcher.cpp#L318

Added line #L318 was not covered by tests
const GoalCandidate & goal_candidate, const double margin_scale_factor) const
{
if (!parameters_.use_object_recognition) {

Check warning on line 321 in planning/behavior_path_goal_planner_module/src/goal_searcher.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_goal_planner_module/src/goal_searcher.cpp#L321

Added line #L321 was not covered by tests
return true;
}

const Pose goal_pose = goal_candidate.goal_pose;

Check warning on line 325 in planning/behavior_path_goal_planner_module/src/goal_searcher.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_goal_planner_module/src/goal_searcher.cpp#L325

Added line #L325 was not covered by tests

const auto pull_over_lane_stop_objects =
goal_planner_utils::extractStaticObjectsInExpandedPullOverLanes(
*(planner_data_->route_handler), left_side_parking_, parameters_.backward_goal_search_length,
parameters_.forward_goal_search_length, parameters_.detection_bound_offset,
*(planner_data_->dynamic_object), parameters_.th_moving_object_velocity);

Check warning on line 331 in planning/behavior_path_goal_planner_module/src/goal_searcher.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_goal_planner_module/src/goal_searcher.cpp#L329-L331

Added lines #L329 - L331 were not covered by tests

const double margin = parameters_.object_recognition_collision_check_margin * margin_scale_factor;

Check warning on line 333 in planning/behavior_path_goal_planner_module/src/goal_searcher.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_goal_planner_module/src/goal_searcher.cpp#L333

Added line #L333 was not covered by tests

if (utils::checkCollisionBetweenFootprintAndObjects(
vehicle_footprint_, goal_pose, pull_over_lane_stop_objects, margin)) {

Check warning on line 336 in planning/behavior_path_goal_planner_module/src/goal_searcher.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_goal_planner_module/src/goal_searcher.cpp#L335-L336

Added lines #L335 - L336 were not covered by tests
return false;
}

// check longitudinal margin with pull over lane objects
constexpr bool filter_inside = true;
const auto target_objects = goal_planner_utils::filterObjectsByLateralDistance(
goal_pose, planner_data_->parameters.vehicle_width, pull_over_lane_stop_objects, margin,
filter_inside);
if (checkCollisionWithLongitudinalDistance(goal_pose, target_objects)) {
return false;

Check warning on line 346 in planning/behavior_path_goal_planner_module/src/goal_searcher.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_goal_planner_module/src/goal_searcher.cpp#L343-L346

Added lines #L343 - L346 were not covered by tests
}

return true;
}

Check warning on line 350 in planning/behavior_path_goal_planner_module/src/goal_searcher.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_goal_planner_module/src/goal_searcher.cpp#L350

Added line #L350 was not covered by tests

bool GoalSearcher::checkCollision(const Pose & pose, const PredictedObjects & objects) const
{
if (parameters_.use_occupancy_grid_for_goal_search) {
Expand Down
Loading