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, interpolation): improve slerp and fix yaw #1687

Merged
merged 5 commits into from
Sep 5, 2022

Conversation

angry-crab
Copy link
Contributor

@angry-crab angry-crab commented Aug 25, 2022

Signed-off-by: Xinyu Wang xinyu.wang@tier4.jp

Description

#1499 Fix yaw interpolation and improve performance.
Since the current yaw interpolation is not stable, I just switched to the implementation of fillYawInTrajectoryPoint.
This PR also somehow fixes #966 by correcting yaw afterwards.

Before

[component_container_mt-15] [INFO] [1661409128.691758302] [obstacle_avoidance_planner.time]:     generateFineTrajectoryPoints:= 3.928 [ms]
[component_container_mt-15] [INFO] [1661409128.756615001] [obstacle_avoidance_planner.time]:     generateFineTrajectoryPoints:= 2.922 [ms]
[component_container_mt-15] [INFO] [1661409128.865204451] [obstacle_avoidance_planner.time]:     generateFineTrajectoryPoints:= 5.034 [ms]
[component_container_mt-15] [INFO] [1661409128.964733989] [obstacle_avoidance_planner.time]:     generateFineTrajectoryPoints:= 5.834 [ms]
[component_container_mt-15] [INFO] [1661409129.110849547] [obstacle_avoidance_planner.time]:     generateFineTrajectoryPoints:= 4.85 [ms]
[component_container_mt-15] [INFO] [1661409129.163539277] [obstacle_avoidance_planner.time]:     generateFineTrajectoryPoints:= 3.794 [ms]
[component_container_mt-15] [INFO] [1661409129.501548288] [obstacle_avoidance_planner.time]:     generateFineTrajectoryPoints:= 25.244 [ms]
[component_container_mt-15] [INFO] [1661409129.527538449] [obstacle_avoidance_planner.time]:     generateFineTrajectoryPoints:= 22.677 [ms]
[component_container_mt-15] [INFO] [1661409129.552173786] [obstacle_avoidance_planner.time]:     generateFineTrajectoryPoints:= 7.98 [ms]

app

After

[component_container_mt-15] [INFO] [1661412920.206313216] [obstacle_avoidance_planner.time]:     generateFineTrajectoryPoints:= 0.227 [ms]
[component_container_mt-15] [INFO] [1661412920.284322723] [obstacle_avoidance_planner.time]:     generateFineTrajectoryPoints:= 0.283 [ms]
[component_container_mt-15] [INFO] [1661412920.393833142] [obstacle_avoidance_planner.time]:     generateFineTrajectoryPoints:= 0.227 [ms]
[component_container_mt-15] [INFO] [1661412920.480718442] [obstacle_avoidance_planner.time]:     generateFineTrajectoryPoints:= 0.292 [ms]
[component_container_mt-15] [INFO] [1661412920.583334207] [obstacle_avoidance_planner.time]:     generateFineTrajectoryPoints:= 0.225 [ms]
[component_container_mt-15] [INFO] [1661412920.681510785] [obstacle_avoidance_planner.time]:     generateFineTrajectoryPoints:= 0.27 [ms]
[component_container_mt-15] [INFO] [1661412920.796739779] [obstacle_avoidance_planner.time]:     generateFineTrajectoryPoints:= 0.239 [ms]
[component_container_mt-15] [INFO] [1661412920.897798668] [obstacle_avoidance_planner.time]:     generateFineTrajectoryPoints:= 0.245 [ms]
[component_container_mt-15] [INFO] [1661412920.985440207] [obstacle_avoidance_planner.time]:     generateFineTrajectoryPoints:= 0.281 [ms]
[component_container_mt-15] [INFO] [1661412921.080549138] [obstacle_avoidance_planner.time]:     generateFineTrajectoryPoints:= 0.303 [ms]
[component_container_mt-15] [INFO] [1661412921.241484633] [obstacle_avoidance_planner.time]:     generateFineTrajectoryPoints:= 0.236 [ms]

slerp

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.

Signed-off-by: Xinyu Wang <xinyu.wang@tier4.jp>
@angry-crab angry-crab changed the title fix(obstacle_avoidance_planner): improve slerp and fix yaw fix(obstacle_avoidance_planner, interpolation): improve slerp and fix yaw Aug 25, 2022
@takayuki5168
Copy link
Contributor

@angry-crab Do you know why there is large calculation cost difference between before and after? Both you set skip_optimization false?

@codecov
Copy link

codecov bot commented Aug 25, 2022

Codecov Report

Merging #1687 (d67b21d) into main (728875e) will increase coverage by 0.01%.
The diff coverage is 17.39%.

@@            Coverage Diff             @@
##             main    #1687      +/-   ##
==========================================
+ Coverage   10.39%   10.40%   +0.01%     
==========================================
  Files        1218     1218              
  Lines       87391    87547     +156     
  Branches    20228    20251      +23     
==========================================
+ Hits         9082     9108      +26     
- Misses      68856    68980     +124     
- Partials     9453     9459       +6     
Flag Coverage Δ *Carryforward flag
differential 11.53% <0.00%> (?)
total 10.37% <28.57%> (ø) Carriedforward from 728875e

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

Impacted Files Coverage Δ
...e/interpolation/spline_interpolation_points_2d.hpp 90.00% <ø> (+6.66%) ⬆️
...anner/include/obstacle_avoidance_planner/utils.hpp 0.00% <0.00%> (ø)
planning/obstacle_avoidance_planner/src/utils.cpp 0.00% <0.00%> (ø)
...terpolation/src/spline_interpolation_points_2d.cpp 58.69% <57.14%> (+5.36%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@angry-crab
Copy link
Contributor Author

@angry-crab Do you know why there is large calculation cost difference between before and after? Both you set skip_optimization ?

It has nothing to do with skip_optimization. fillYawInTrajectoryPoint performed another interpolation using the previously interpolated result, which contained a large amount of points. The second interpolation was unnecessary.

Signed-off-by: Xinyu Wang <xinyu.wang@tier4.jp>
Signed-off-by: Xinyu Wang <xinyu.wang@tier4.jp>
@shulanbushangshu
Copy link
Contributor

@angry-crab @takayuki5168
Yes,I test the cost of the function "generateFineTrajectoryPoints".
When the length of path is default value(max:300m),the cost is shown as below:
Screenshot from 2022-08-29 10-33-53
As the comment said,the calculation is heavy.

The StepPolygon of obstacle_stop_planner is shown as below:

Screenshot from 2022-08-29 11-12-31

@shulanbushangshu
Copy link
Contributor

@angry-crab
I test the changed code .It works well:
The time cost:
Screenshot from 2022-08-31 15-31-11
The result of path:
Screenshot from 2022-08-31 15-36-44

@takayuki5168
In the "fillYawInTrajectoryPoint",the most time is cost in the code("slerpYawFromPoints") as below:
std::vector yaw_vec;
for (size_t i = 0; i < points.size(); ++i) {
const double yaw = interpolator.getSplineInterpolatedYaw(i, 0.0);
yaw_vec.push_back(yaw);
}
return yaw_vec;

The code uses too much loop.
In the function"getSplineInterpolatedYaw",it can get all "diff_x"、"diff_y"in once.But"getSplineInterpolatedYaw" calculates "diff_x\diff_y" one by one.

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.

LGTM

@angry-crab angry-crab enabled auto-merge (squash) September 4, 2022 23:58
@angry-crab angry-crab merged commit 2f379a6 into autowarefoundation:main Sep 5, 2022
@angry-crab angry-crab deleted the improve_slerp branch September 5, 2022 03:58
boyali pushed a commit to boyali/autoware.universe that referenced this pull request Sep 28, 2022
… yaw (autowarefoundation#1687)

* merge slerp of x y yaw

Signed-off-by: Xinyu Wang <xinyu.wang@tier4.jp>

* ci(pre-commit): autofix

* move and rename new slerp

Signed-off-by: Xinyu Wang <xinyu.wang@tier4.jp>

* add include file

Signed-off-by: Xinyu Wang <xinyu.wang@tier4.jp>

Signed-off-by: Xinyu Wang <xinyu.wang@tier4.jp>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
boyali pushed a commit to boyali/autoware.universe that referenced this pull request Oct 3, 2022
… yaw (autowarefoundation#1687)

* merge slerp of x y yaw

Signed-off-by: Xinyu Wang <xinyu.wang@tier4.jp>

* ci(pre-commit): autofix

* move and rename new slerp

Signed-off-by: Xinyu Wang <xinyu.wang@tier4.jp>

* add include file

Signed-off-by: Xinyu Wang <xinyu.wang@tier4.jp>

Signed-off-by: Xinyu Wang <xinyu.wang@tier4.jp>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
boyali pushed a commit to boyali/autoware.universe that referenced this pull request Oct 3, 2022
… yaw (autowarefoundation#1687)

* merge slerp of x y yaw

Signed-off-by: Xinyu Wang <xinyu.wang@tier4.jp>

* ci(pre-commit): autofix

* move and rename new slerp

Signed-off-by: Xinyu Wang <xinyu.wang@tier4.jp>

* add include file

Signed-off-by: Xinyu Wang <xinyu.wang@tier4.jp>

Signed-off-by: Xinyu Wang <xinyu.wang@tier4.jp>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
yukke42 pushed a commit to tzhong518/autoware.universe that referenced this pull request Oct 14, 2022
… yaw (autowarefoundation#1687)

* merge slerp of x y yaw

Signed-off-by: Xinyu Wang <xinyu.wang@tier4.jp>

* ci(pre-commit): autofix

* move and rename new slerp

Signed-off-by: Xinyu Wang <xinyu.wang@tier4.jp>

* add include file

Signed-off-by: Xinyu Wang <xinyu.wang@tier4.jp>

Signed-off-by: Xinyu Wang <xinyu.wang@tier4.jp>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
boyali pushed a commit to boyali/autoware.universe that referenced this pull request Oct 19, 2022
… yaw (autowarefoundation#1687)

* merge slerp of x y yaw

Signed-off-by: Xinyu Wang <xinyu.wang@tier4.jp>

* ci(pre-commit): autofix

* move and rename new slerp

Signed-off-by: Xinyu Wang <xinyu.wang@tier4.jp>

* add include file

Signed-off-by: Xinyu Wang <xinyu.wang@tier4.jp>

Signed-off-by: Xinyu Wang <xinyu.wang@tier4.jp>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Yaw calculation is unstable in obstacle_avoidance_planner when skipping optimization.
3 participants