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(avoidance): use intersection area #4206

Merged

Conversation

satoshi-ota
Copy link
Contributor

@satoshi-ota satoshi-ota commented Jul 9, 2023

Description

🤖 Generated by Copilot at 48eabc2

This pull request refactors and improves the code for generating and using the drivable area in the behavior path planner. It removes redundant code, adds new parameters and flags, and simplifies the logic for expanding the drivable area by polygons such as hatched road markings and intersection areas. It also makes the functions for drivable area calculation more consistent and flexible. The changes affect several files in the planning/behavior_path_planner directory, such as utils.hpp, utils.cpp, planner_manager.cpp, and avoidance.param.yaml.

Please approve ⬇️ before this PR.
autowarefoundation/autoware_launch#439

image

image

Tests performed

Psim

image

image

Effects on system behavior

Not applicable.

Pre-review checklist for the PR author

The PR author must check the checkboxes below when creating the PR.

In-review checklist for the PR reviewers

The PR reviewers must check the checkboxes below before approval.

Post-review checklist for the PR author

The PR author must check the checkboxes below before merging.

  • There are no open discussions or they are tracked via tickets.

After all checkboxes are checked, anyone who has write access can merge the PR.

@github-actions github-actions bot added the component:planning Route planning, decision-making, and navigation. (auto-assigned) label Jul 9, 2023
@satoshi-ota satoshi-ota force-pushed the feat/use-intersection-area branch 2 times, most recently from 54cc40b to e6c69d0 Compare July 10, 2023 01:55
@codecov
Copy link

codecov bot commented Jul 10, 2023

Codecov Report

Patch coverage: 4.16% and project coverage change: +0.01 🎉

Comparison is base (8c982e5) 14.16% compared to head (0c21706) 14.18%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4206      +/-   ##
==========================================
+ Coverage   14.16%   14.18%   +0.01%     
==========================================
  Files        1586     1586              
  Lines      109537   109417     -120     
  Branches    31451    31391      -60     
==========================================
+ Hits        15518    15519       +1     
+ Misses      77130    77015     -115     
+ Partials    16889    16883       -6     
Flag Coverage Δ *Carryforward flag
differential 13.64% <4.16%> (?)
total 14.19% <ø> (+0.02%) ⬆️ Carriedforward from 8c982e5

*This pull request uses carry forward flags. Click here to find out more.

Impacted Files Coverage Δ
...r4_planning_rviz_plugin/src/tools/max_velocity.cpp 0.00% <ø> (ø)
...ner/include/behavior_path_planner/data_manager.hpp 37.50% <ø> (ø)
...lanner/scene_module/avoidance/avoidance_module.hpp 0.00% <ø> (ø)
...nner/scene_module/lane_change/external_request.hpp 0.00% <ø> (ø)
...ath_planner/scene_module/lane_change/interface.hpp 100.00% <ø> (+50.00%) ⬆️
...r_path_planner/scene_module/lane_change/normal.hpp 0.00% <ø> (ø)
...cene_module/start_planner/start_planner_module.hpp 0.00% <ø> (ø)
..._planner/utils/avoidance/avoidance_module_data.hpp 0.00% <ø> (ø)
...nner/include/behavior_path_planner/utils/utils.hpp 45.45% <ø> (ø)
...or_path_planner/src/behavior_path_planner_node.cpp 27.13% <0.00%> (+0.15%) ⬆️
... and 19 more

... and 4 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.


// expand drivable area by intersection areas.
const std::string id = bound_lane.attributeOr("intersection_area", "else");
if (enable_expanding_intersection_areas && id != "else") {
Copy link
Contributor

Choose a reason for hiding this comment

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

    const bool isIntersectionArea = enable_expanding_intersection_areas && intersection_area != "else";

    // expand drivable area by intersection areas.
    if (isIntersectionArea) {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for your advice! I fixed in 1e60bcb.

Comment on lines 1147 to 1175
if (use_hatched_road_markings) {
for (const auto & point : target_line) {
const auto new_polygon_candidate =
utils::getPolygonByPoint(rh, point, "hatched_road_markings");
if (!new_polygon_candidate) {
continue;
}

bool is_new_polygon{true};
for (const auto & polygon : expandable_polygons) {
if (polygon.id() == new_polygon_candidate->id()) {
is_new_polygon = false;
break;
}
}

if (is_new_polygon) {
expandable_polygons.push_back(*new_polygon_candidate);
}
}
}

if (use_intersection_areas) {
const std::string area_id_str = overhang_lanelet.attributeOr("intersection_area", "else");

if (is_new_polygon) {
expandable_polygons.push_back(*new_polygon_candidate);
if (area_id_str != "else") {
expandable_polygons.push_back(
rh->getLaneletMapPtr()->polygonLayer.get(std::atoi(area_id_str.c_str())));
}
}

if (expandable_polygons.empty()) {
return to_road_shoulder_distance;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

  auto polygonExistsIn = [](const auto &polygons, const auto &new_polygon) {
    return std::any_of(polygons.begin(), polygons.end(), [&](const auto &polygon){
      return polygon.id() == new_polygon.id();
    });
  };

  if (use_hatched_road_markings) {
    for (const auto & point : target_line) {
      const auto new_polygon_candidate = utils::getPolygonByPoint(rh, point, "hatched_road_markings");

      if (new_polygon_candidate && !polygonExistsIn(expandable_polygons, *new_polygon_candidate)) {
        expandable_polygons.push_back(*new_polygon_candidate);
      }
    }
  }

  if (use_intersection_areas) {
    const std::string area_id_str = overhang_lanelet.attributeOr("intersection_area", "else");

    if (area_id_str != "else") {
      expandable_polygons.push_back(
        rh->getLaneletMapPtr()->polygonLayer.get(std::atoi(area_id_str.c_str())));
    }
  }

  if (expandable_polygons.empty()) {
    return to_road_shoulder_distance;
  }

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I fixed in 1e60bcb.

@kyoichi-sugahara kyoichi-sugahara self-assigned this Jul 11, 2023
Copy link
Contributor

@kyoichi-sugahara kyoichi-sugahara left a comment

Choose a reason for hiding this comment

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

LGTM
(suggest a minor modification but it's not necessarly condidered.)

Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>
Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>
Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>
@satoshi-ota satoshi-ota force-pushed the feat/use-intersection-area branch from 0c21706 to 1e60bcb Compare July 11, 2023 01:53
@satoshi-ota satoshi-ota enabled auto-merge (squash) July 11, 2023 02:57
@satoshi-ota satoshi-ota merged commit 51fd4c5 into autowarefoundation:main Jul 11, 2023
@satoshi-ota satoshi-ota deleted the feat/use-intersection-area branch July 11, 2023 03:09
SaltUhey pushed a commit to SaltUhey/autoware.universe that referenced this pull request Apr 11, 2024
…4206)

Signed-off-by: M. Fatih Cırıt <mfc@leodrive.ai>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component:planning Route planning, decision-making, and navigation. (auto-assigned)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants