-
Notifications
You must be signed in to change notification settings - Fork 680
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
6047a30
to
d9b3f08
Compare
Codecov ReportPatch coverage:
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
*This pull request uses carry forward flags. Click here to find out more.
☔ View full report in Codecov by Sentry. |
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); | ||
} | ||
} |
There was a problem hiding this comment.
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.
autoware.universe/common/motion_utils/include/motion_utils/trajectory/trajectory.hpp
Lines 1196 to 1199 in 6bf539b
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) |
There was a problem hiding this comment.
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()
.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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()
.
There was a problem hiding this comment.
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.
1f5c297
to
ae62120
Compare
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) { |
There was a problem hiding this comment.
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) {
There was a problem hiding this comment.
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) {
...
}
}
}
There was a problem hiding this comment.
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.
f4ec531
to
b09ee48
Compare
motion_utils::insertStopPoint(dist_with_margin, optimized_traj_points); | ||
if (first_outside_idx_with_margin) { | ||
return *first_outside_idx_with_margin; | ||
} else { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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!!
There was a problem hiding this 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.
…p margin due to out of drivable area Signed-off-by: AhmedEbrahim <[email protected]>
…when footprint is going out of drivable area Signed-off-by: AhmedEbrahim <[email protected]>
Signed-off-by: AhmedEbrahim <[email protected]>
Signed-off-by: AhmedEbrahim <[email protected]>
…rent logic Signed-off-by: AhmedEbrahim <[email protected]>
…e index with margin cannot be calculated Signed-off-by: AhmedEbrahim <[email protected]>
…alculation Signed-off-by: AhmedEbrahim <[email protected]>
… early return Signed-off-by: AhmedEbrahim <[email protected]>
b09ee48
to
55818f4
Compare
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 #2796Related 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.
Post-review checklist for the PR author
The PR author must check the checkboxes below before merging.
After all checkboxes are checked, anyone who has write access can merge the PR.