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(start_planner): define collision check margin as list #5994

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
8afbca4
remove collision check in pull out planner
kyoichi-sugahara Dec 25, 2023
d55775a
check collision when search start pose
kyoichi-sugahara Dec 26, 2023
5021b0c
Merge branch 'main' into feat/check_collision_outside_of_plan
kyoichi-sugahara Dec 27, 2023
a30eb25
Refactor collision check in GeometricPullOut::plan()
kyoichi-sugahara Dec 27, 2023
6f30ca4
Refactor collision check path extraction in StartPlannerModule
kyoichi-sugahara Dec 27, 2023
6b88e3b
change filterStopObjectsInShoulderLanes
kyoichi-sugahara Dec 27, 2023
c0c6cf8
Merge branch 'main' into feat/apply_offset_colission_check_segment
kyoichi-sugahara Dec 27, 2023
61f992e
Update collision check parameters
kyoichi-sugahara Dec 27, 2023
e680b56
Merge branch 'main' into feat/keep_distance_against_front_objects
kyoichi-sugahara Dec 27, 2023
294c1fe
Merge branch 'main' into feat/keep_distance_against_front_objects
kyoichi-sugahara Dec 27, 2023
b90ea45
Merge branch 'main' into feat/check_collision_outside_of_plan
kyoichi-sugahara Dec 28, 2023
e5717ad
change order of extract stop objects function
kyoichi-sugahara Dec 28, 2023
8f0089f
Merge branch 'main' into feat/apply_offset_colission_check_segment
kyoichi-sugahara Dec 28, 2023
50ee603
Merge branch 'feat/check_collision_outside_of_plan' into feat/apply_o…
kyoichi-sugahara Dec 28, 2023
ab448e8
Merge branch 'feat/apply_offset_colission_check_segment' into feat/ke…
kyoichi-sugahara Dec 28, 2023
55e18db
define collision check margins list in start planner module
kyoichi-sugahara Dec 28, 2023
3708271
Merge branch 'main' into feat/apply_offset_colission_check_segment
kyoichi-sugahara Dec 28, 2023
7fefeef
Merge branch 'feat/apply_offset_colission_check_segment' into feat/ke…
kyoichi-sugahara Dec 28, 2023
d19f6dc
Merge branch 'feat/keep_distance_against_front_objects' into feat/def…
kyoichi-sugahara Dec 28, 2023
a3da397
Merge branch 'main' into feat/define_collision_check_margin_as_list
kyoichi-sugahara Jan 10, 2024
75a4767
Merge branch 'main' into feat/define_collision_check_margin_as_list
kyoichi-sugahara Jan 10, 2024
8377566
Update collision check objects in pull out lanes
kyoichi-sugahara Jan 10, 2024
9c9f661
Merge branch 'main' into feat/define_collision_check_margin_as_list
kyoichi-sugahara Jan 11, 2024
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 @@ -41,6 +41,8 @@ struct StartGoalPlannerData

Pose refined_start_pose;
std::vector<Pose> start_pose_candidates;
size_t selected_start_pose_candidate_index;
double margin_for_start_pose_candidate;
Comment on lines +44 to +45
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better to separate start planner specific data

};

} // namespace behavior_path_planner
Expand Down
26 changes: 13 additions & 13 deletions planning/behavior_path_start_planner_module/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,19 +65,19 @@ PullOutPath --o PullOutPlannerBase

## General parameters for start_planner

| Name | Unit | Type | Description | Default value |
| :---------------------------------------------------------- | :---- | :----- | :-------------------------------------------------------------------------- | :------------ |
| th_arrived_distance_m | [m] | double | distance threshold for arrival of path termination | 1.0 |
| th_distance_to_middle_of_the_road | [m] | double | distance threshold to determine if the vehicle is on the middle of the road | 0.1 |
| th_stopped_velocity_mps | [m/s] | double | velocity threshold for arrival of path termination | 0.01 |
| th_stopped_time_sec | [s] | double | time threshold for arrival of path termination | 1.0 |
| th_turn_signal_on_lateral_offset | [m] | double | lateral distance threshold for turning on blinker | 1.0 |
| intersection_search_length | [m] | double | check if intersections exist within this length | 30.0 |
| length_ratio_for_turn_signal_deactivation_near_intersection | [m] | double | deactivate turn signal of this module near intersection | 0.5 |
| collision_check_margin | [m] | double | Obstacle collision check margin | 1.0 |
| collision_check_distance_from_end | [m] | double | collision check distance from end shift end pose | 1.0 |
| collision_check_margin_from_front_object | [m] | double | collision check margin from front object | 5.0 |
| center_line_path_interval | [m] | double | reference center line path point interval | 1.0 |
| Name | Unit | Type | Description | Default value |
| :---------------------------------------------------------- | :---- | :------- | :-------------------------------------------------------------------------- | :-------------- |
| th_arrived_distance_m | [m] | double | distance threshold for arrival of path termination | 1.0 |
| th_distance_to_middle_of_the_road | [m] | double | distance threshold to determine if the vehicle is on the middle of the road | 0.1 |
| th_stopped_velocity_mps | [m/s] | double | velocity threshold for arrival of path termination | 0.01 |
| th_stopped_time_sec | [s] | double | time threshold for arrival of path termination | 1.0 |
| th_turn_signal_on_lateral_offset | [m] | double | lateral distance threshold for turning on blinker | 1.0 |
| intersection_search_length | [m] | double | check if intersections exist within this length | 30.0 |
| length_ratio_for_turn_signal_deactivation_near_intersection | [m] | double | deactivate turn signal of this module near intersection | 0.5 |
| collision_check_margins | [m] | [double] | Obstacle collision check margins list | [2.0, 1.5, 1.0] |
| collision_check_distance_from_end | [m] | double | collision check distance from end shift end pose | 1.0 |
| collision_check_margin_from_front_object | [m] | double | collision check margin from front object | 5.0 |
| center_line_path_interval | [m] | double | reference center line path point interval | 1.0 |

## Safety check with static obstacles

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
th_arrived_distance: 1.0
th_stopped_velocity: 0.01
th_stopped_time: 1.0
collision_check_margin: 1.0
collision_check_margins: [2.0, 1.5, 1.0]
collision_check_distance_from_end: 1.0
collision_check_margin_from_front_object: 5.0
th_moving_object_velocity: 1.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ class StartPlannerModule : public SceneModuleInterface
const std::string & search_priority, const size_t start_pose_candidates_num);
bool findPullOutPath(
const Pose & start_pose_candidate, const std::shared_ptr<PullOutPlannerBase> & planner,
const Pose & refined_start_pose, const Pose & goal_pose);
const Pose & refined_start_pose, const Pose & goal_pose, const double collision_check_margin);

PathWithLaneId extractCollisionCheckSection(const PullOutPath & path);
void updateStatusWithCurrentPath(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ struct StartPlannerParameters
double th_distance_to_middle_of_the_road{0.0};
double intersection_search_length{0.0};
double length_ratio_for_turn_signal_deactivation_near_intersection{0.0};
double collision_check_margin{0.0};
std::vector<double> collision_check_margins{};
double collision_check_distance_from_end{0.0};
double collision_check_margin_from_front_object{0.0};
double th_moving_object_velocity{0.0};
Expand Down
3 changes: 2 additions & 1 deletion planning/behavior_path_start_planner_module/src/manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,12 @@
p.intersection_search_length = node->declare_parameter<double>(ns + "intersection_search_length");
p.length_ratio_for_turn_signal_deactivation_near_intersection = node->declare_parameter<double>(
ns + "length_ratio_for_turn_signal_deactivation_near_intersection");
p.collision_check_margin = node->declare_parameter<double>(ns + "collision_check_margin");
p.collision_check_margins =
node->declare_parameter<std::vector<double>>(ns + "collision_check_margins");

Check warning on line 47 in planning/behavior_path_start_planner_module/src/manager.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

❌ Getting worse: Large Method

StartPlannerModuleManager::init increases from 263 to 264 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.

Check warning on line 47 in planning/behavior_path_start_planner_module/src/manager.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_start_planner_module/src/manager.cpp#L47

Added line #L47 was not covered by tests
p.collision_check_distance_from_end =
node->declare_parameter<double>(ns + "collision_check_distance_from_end");
p.collision_check_margin_from_front_object =
node->declare_parameter<double>(ns + "collision_check_margin_from_front_object");

Check warning on line 51 in planning/behavior_path_start_planner_module/src/manager.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_start_planner_module/src/manager.cpp#L50-L51

Added lines #L50 - L51 were not covered by tests
p.th_moving_object_velocity = node->declare_parameter<double>(ns + "th_moving_object_velocity");
p.center_line_path_interval = node->declare_parameter<double>(ns + "center_line_path_interval");
// shift pull out
Expand Down
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_start_planner_module/src/start_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 1153 to 1161, 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.
//
// 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 @@ -585,9 +585,16 @@
const PriorityOrder order_priority =
determinePriorityOrder(search_priority, start_pose_candidates.size());

for (const auto & [index, planner] : order_priority) {
if (findPullOutPath(start_pose_candidates[index], planner, refined_start_pose, goal_pose))
return;
for (const auto & collision_check_margin : parameters_->collision_check_margins) {
for (const auto & [index, planner] : order_priority) {
if (findPullOutPath(
start_pose_candidates[index], planner, refined_start_pose, goal_pose,

Check warning on line 591 in planning/behavior_path_start_planner_module/src/start_planner_module.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_start_planner_module/src/start_planner_module.cpp#L588-L591

Added lines #L588 - L591 were not covered by tests
collision_check_margin)) {
start_planner_data_.selected_start_pose_candidate_index = index;
start_planner_data_.margin_for_start_pose_candidate = collision_check_margin;

Check warning on line 594 in planning/behavior_path_start_planner_module/src/start_planner_module.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_start_planner_module/src/start_planner_module.cpp#L593-L594

Added lines #L593 - L594 were not covered by tests
return;
}
}
}

updateStatusIfNoSafePathFound();
Expand Down Expand Up @@ -618,35 +625,35 @@

bool StartPlannerModule::findPullOutPath(
const Pose & start_pose_candidate, const std::shared_ptr<PullOutPlannerBase> & planner,
const Pose & refined_start_pose, const Pose & goal_pose)
const Pose & refined_start_pose, const Pose & goal_pose, const double collision_check_margin)
{
const auto & dynamic_objects = planner_data_->dynamic_object;
const auto pull_out_lanes = start_planner_utils::getPullOutLanes(
planner_data_, planner_data_->parameters.backward_path_length + parameters_->max_back_distance);
const auto & vehicle_footprint = createVehicleFootprint(vehicle_info_);
// extract stop objects in pull out lane for collision check
const auto stop_objects = utils::path_safety_checker::filterObjectsByVelocity(
*dynamic_objects, parameters_->th_moving_object_velocity);
const auto [pull_out_lane_stop_objects, others] =
utils::path_safety_checker::separateObjectsByLanelets(
stop_objects, pull_out_lanes, utils::path_safety_checker::isPolygonOverlapLanelet);

// if start_pose_candidate is far from refined_start_pose, backward driving is necessary
const bool backward_is_unnecessary =
tier4_autoware_utils::calcDistance2d(start_pose_candidate, refined_start_pose) < 0.01;

planner->setPlannerData(planner_data_);
const auto pull_out_path = planner->plan(start_pose_candidate, goal_pose);

// If no path is found, return false
if (!pull_out_path) {
return false;
}

// check collision
if (utils::checkCollisionBetweenPathFootprintsAndObjects(
vehicle_footprint, extractCollisionCheckSection(*pull_out_path), pull_out_lane_stop_objects,

Check warning on line 655 in planning/behavior_path_start_planner_module/src/start_planner_module.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_start_planner_module/src/start_planner_module.cpp#L655

Added line #L655 was not covered by tests
parameters_->collision_check_margin)) {
collision_check_margin)) {

Check warning on line 656 in planning/behavior_path_start_planner_module/src/start_planner_module.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

❌ New issue: Excess Number of Function Arguments

StartPlannerModule::findPullOutPath has 5 arguments, threshold = 4. This function has too many arguments, indicating a lack of encapsulation. Avoid adding more arguments.
return false;
}

Expand All @@ -660,30 +667,28 @@
return true;
}

PathWithLaneId StartPlannerModule::extractCollisionCheckSection(const PullOutPath & path)

Check warning on line 670 in planning/behavior_path_start_planner_module/src/start_planner_module.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_start_planner_module/src/start_planner_module.cpp#L670

Added line #L670 was not covered by tests
{
PathWithLaneId combined_path;
for (const auto & partial_path : path.partial_paths) {
combined_path.points.insert(
combined_path.points.end(), partial_path.points.begin(), partial_path.points.end());
}

// calculate collision check end idx
size_t collision_check_end_idx = 0;
const auto collision_check_end_pose = motion_utils::calcLongitudinalOffsetPose(
combined_path.points, path.end_pose.position, parameters_->collision_check_distance_from_end);

if (collision_check_end_pose) {
collision_check_end_idx =
motion_utils::findNearestIndex(combined_path.points, collision_check_end_pose->position);
}
const size_t collision_check_end_idx = std::invoke([&]() {
const auto collision_check_end_pose = motion_utils::calcLongitudinalOffsetPose(
combined_path.points, path.end_pose.position, parameters_->collision_check_distance_from_end);

Check warning on line 680 in planning/behavior_path_start_planner_module/src/start_planner_module.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_start_planner_module/src/start_planner_module.cpp#L678-L680

Added lines #L678 - L680 were not covered by tests

if (collision_check_end_pose) {
return motion_utils::findNearestIndex(
combined_path.points, collision_check_end_pose->position);

Check warning on line 684 in planning/behavior_path_start_planner_module/src/start_planner_module.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_start_planner_module/src/start_planner_module.cpp#L682-L684

Added lines #L682 - L684 were not covered by tests
} else {
return combined_path.points.size() - 1;

Check warning on line 686 in planning/behavior_path_start_planner_module/src/start_planner_module.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_start_planner_module/src/start_planner_module.cpp#L686

Added line #L686 was not covered by tests
}
});
// remove the point behind of collision check end pose
if (collision_check_end_idx + 1 < combined_path.points.size()) {
combined_path.points.erase(
combined_path.points.begin() + collision_check_end_idx + 1, combined_path.points.end());
}

combined_path.points.erase(

Check warning on line 690 in planning/behavior_path_start_planner_module/src/start_planner_module.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_start_planner_module/src/start_planner_module.cpp#L690

Added line #L690 was not covered by tests
combined_path.points.begin() + collision_check_end_idx + 1, combined_path.points.end());
return combined_path;
}

Expand Down Expand Up @@ -914,7 +919,7 @@

const auto front_stop_objects_in_pull_out_lanes = filterStopObjectsInPullOutLanes(
pull_out_lanes, start_pose.position, parameters_->th_moving_object_velocity, 0,
std::numeric_limits<double>::max());

Check warning on line 922 in planning/behavior_path_start_planner_module/src/start_planner_module.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_start_planner_module/src/start_planner_module.cpp#L922

Added line #L922 was not covered by tests

// Set the maximum backward distance less than the distance from the vehicle's base_link to the
// lane's rearmost point to prevent lane departure.
Expand All @@ -928,9 +933,9 @@
back_distance += parameters_->backward_search_resolution) {
const auto backed_pose = calcLongitudinalOffsetPose(
back_path_from_start_pose.points, start_pose.position, -back_distance);
if (!backed_pose) continue;

Check warning on line 936 in planning/behavior_path_start_planner_module/src/start_planner_module.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_start_planner_module/src/start_planner_module.cpp#L936

Added line #L936 was not covered by tests

if (utils::checkCollisionBetweenFootprintAndObjects(

Check warning on line 938 in planning/behavior_path_start_planner_module/src/start_planner_module.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_start_planner_module/src/start_planner_module.cpp#L938

Added line #L938 was not covered by tests
local_vehicle_footprint, *backed_pose, front_stop_objects_in_pull_out_lanes,
parameters_->collision_check_margin_from_front_object))
continue;
Expand All @@ -950,7 +955,7 @@

if (utils::checkCollisionBetweenFootprintAndObjects(
local_vehicle_footprint, *backed_pose, stop_objects_in_pull_out_lanes,
parameters_->collision_check_margin)) {
parameters_->collision_check_margins.back())) {
break; // poses behind this has a collision, so break.
}

Expand Down
Loading