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

fix(obstacle_avoidance_planner): adding missing functionality for stop margin due to out of drivable area #4194

Conversation

ahmeddesokyebrahim
Copy link
Contributor

@ahmeddesokyebrahim ahmeddesokyebrahim commented Jul 7, 2023

Description

This PR is to add missing functionality of stop margin due to out of drivable area in obstacle_avoidance_planner since refactoring done in #2796

Related links

closes #4190
❗ Must be merged with autowarefoundation/autoware_launch#438

Tests performed

Same as mentioned in original PR : #2786

Notes for reviewers

Original PR : #2786
Refactoring PR : #2796

Interface changes

N.A.

Effects on system behavior

Adding a margin for stop point when the the stop point is calculated for the footprint out of drivable area.

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.

  • The PR follows the pull request guidelines.
  • The PR has been properly tested.
  • The PR has been reviewed by the code owners.

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.
  • The PR is ready for merge.

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 7, 2023
@ahmeddesokyebrahim ahmeddesokyebrahim self-assigned this Jul 7, 2023
@ahmeddesokyebrahim ahmeddesokyebrahim force-pushed the autoware/universe/4190-add-missing-func-oap-stop-margin branch 2 times, most recently from 6047a30 to d9b3f08 Compare July 11, 2023 15:10
@ahmeddesokyebrahim ahmeddesokyebrahim marked this pull request as ready for review July 11, 2023 15:26
@codecov
Copy link

codecov bot commented Jul 11, 2023

Codecov Report

Patch coverage: 6.25% and no project coverage change.

Comparison is base (37cbd8d) 15.17% compared to head (55818f4) 15.17%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4194   +/-   ##
=======================================
  Coverage   15.17%   15.17%           
=======================================
  Files        1493     1493           
  Lines      102964   102970    +6     
  Branches    31611    31613    +2     
=======================================
+ Hits        15623    15624    +1     
- Misses      70353    70358    +5     
  Partials    16988    16988           
Flag Coverage Δ *Carryforward flag
differential 39.64% <6.25%> (?)
total 15.17% <ø> (+<0.01%) ⬆️ Carriedforward from 37cbd8d

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

Impacted Files Coverage Δ
control/vehicle_cmd_gate/src/vehicle_cmd_gate.cpp 0.28% <ø> (+<0.01%) ⬆️
...nner/utils/lane_change/lane_change_module_data.hpp 0.00% <ø> (ø)
...h_planner/src/scene_module/lane_change/manager.cpp 7.14% <ø> (+0.09%) ⬆️
...th_planner/src/scene_module/lane_change/normal.cpp 4.56% <ø> (+0.01%) ⬆️
...lanner/include/obstacle_avoidance_planner/node.hpp 40.00% <ø> (ø)
planning/obstacle_avoidance_planner/src/node.cpp 38.82% <6.25%> (-1.51%) ⬇️

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

planning/obstacle_avoidance_planner/src/node.cpp Outdated Show resolved Hide resolved
Comment on lines 459 to 469
if (op_target_point) {
const auto target_point = op_target_point.get();
// confirm that target point doesn't overlap with the stop point outside drivable area
const auto dist =
tier4_autoware_utils::calcDistance2d(optimized_traj_points.at(stop_idx), target_point);
const double overlap_threshold = 1e-3;
if (dist > overlap_threshold) {
stop_idx = motion_utils::findNearestSegmentIndex(optimized_traj_points, target_point);
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you check if you can replace this code with the following function.

template <class T>
inline boost::optional<size_t> insertStopPoint(
const size_t src_segment_idx, const double distance_to_stop_point, T & points_with_twist,
const double overlap_threshold = 1e-3)

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 think functionality can be achieved by insertStopPoint(), but I do believe that it is not what we intended to do.
The main idea here is to try to find an already existing point on the current trajectory that is the nearest to the margin from stop point out of drivable area, then insert zero velocity starting from this existing point.
On the other hand, insertStopPoint() will make it stop yes, but that most probably would yield to a change to the current trajectory by adding this new point as it uses insertTargetPoint() .

Copy link
Contributor

Choose a reason for hiding this comment

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

@ahmeddesokyebrahim
insertStopPoint calls insertTargetPoint, and the function also checks if a close point to the target point already exists in the trajectory.
By using this function, the code change on this PR will be much smaller which I prefer.
Let me know if you do not agree with mine.

Btw, can I merge the following PR first?
If merging this PR first will have trouble for you, I'll wait.
#4112

Copy link
Contributor Author

Choose a reason for hiding this comment

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

got your point, thanks for the clarification.
Then I will try it with your proposal.
And go ahead for sure with merging your PR firstly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@takayuki5168 : Please have a look with current implementation using insertStopPoint().

Copy link
Contributor

Choose a reason for hiding this comment

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

Thank you so much. I added some comments.

@ahmeddesokyebrahim ahmeddesokyebrahim force-pushed the autoware/universe/4190-add-missing-func-oap-stop-margin branch 2 times, most recently from 1f5c297 to ae62120 Compare July 14, 2023 14:57
Comment on lines 452 to 466
auto stop_idx = *first_outside_idx;
const auto dist = tier4_autoware_utils::calcDistance2d(
optimized_traj_points.at(0), optimized_traj_points.at(stop_idx));
const auto dist_with_margin = dist - vehicle_stop_margin_outside_drivable_area_;
const auto first_outside_idx_with_margin =
motion_utils::insertStopPoint(dist_with_margin, optimized_traj_points);
if (first_outside_idx_with_margin) {
stop_idx = *first_outside_idx_with_margin;
}
publishVirtualWall(optimized_traj_points.at(stop_idx).pose);
for (size_t i = stop_idx; i < optimized_traj_points.size(); ++i) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you make variables private like this.

      const auto stop_idx = [&]() {
        const auto dist = tier4_autoware_utils::calcDistance2d(
          optimized_traj_points.at(0), optimized_traj_points.at(*first_outside_idx));
        const auto dist_with_margin = dist - vehicle_stop_margin_outside_drivable_area_;
        const auto first_outside_idx_with_margin =
          motion_utils::insertStopPoint(dist_with_margin, optimized_traj_points);
        if (first_outside_idx_with_margin) {
          return *first_outside_idx_with_margin;
        }
        return *first_outside_idx;
      }();

      publishVirtualWall(optimized_traj_points.at(stop_idx).pose);
      for (size_t i = stop_idx; i < optimized_traj_points.size(); ++i) {

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, even if enable_outside_drivable_area_stop_ is false, we wanna call publishVirtualWall.
So the following would be better.

if (first_outside_idx) {
    const auto stop_idx = ...;
    publishVirtualWall(optimized_traj_points.at(stop_idx).pose);
    if (enable_outside_drivable_area_stop_) {
        for (size_t i = stop_idx; i < optimized_traj_points.size(); ++i) {
            ...
        }
    }
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you so much @takayuki5168 for the valuable comments 👍 .
I have updated the code, please have a look.

@ahmeddesokyebrahim ahmeddesokyebrahim force-pushed the autoware/universe/4190-add-missing-func-oap-stop-margin branch from f4ec531 to b09ee48 Compare July 18, 2023 20:55
motion_utils::insertStopPoint(dist_with_margin, optimized_traj_points);
if (first_outside_idx_with_margin) {
return *first_outside_idx_with_margin;
} else {
Copy link
Contributor

Choose a reason for hiding this comment

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

(Just comment. It's okay not to apply the change.)
This else can be removed. This is called early return.

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 have removed it. Thanks again for the comments!!

Copy link
Contributor

@takayuki5168 takayuki5168 left a comment

Choose a reason for hiding this comment

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

Thank you for the change. I approve.

@ahmeddesokyebrahim ahmeddesokyebrahim force-pushed the autoware/universe/4190-add-missing-func-oap-stop-margin branch from b09ee48 to 55818f4 Compare July 19, 2023 08:24
@ahmeddesokyebrahim ahmeddesokyebrahim merged commit 8c257b9 into autowarefoundation:main Jul 19, 2023
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
No open projects
Development

Successfully merging this pull request may close these issues.

Adding missing PRs to obstacle_avoidance_planner since code refactoring
2 participants