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(ndt_scan_matcher): implement tpe sampler in ndt_align_srv #5078

Merged

Conversation

SakodaShintaro
Copy link
Contributor

@SakodaShintaro SakodaShintaro commented Sep 22, 2023

Description

The ndt service for initial position estimation has been changed from random search to search using TPE.

Related links

autowarefoundation/autoware_launch#602

tier4/autoware-spell-check-dict#623

Summary of Changes

tpe

Tests performed

Tested by

  1. logging simulator about the sample rosbag.
  2. AWSIM

Evaluation

In AWSIM (Nishishinjuku), the initial pose estimation was performed for each method 200 times, and the final best values of ndt_align_srv are obtained.

compare_histogram_score

Method Mean Score Process Time
Random 5.938 ± 0.911 1.073 ± 0.043 [sec]
TPE 6.233 ± 0.634 1.208 ± 0.045 [sec]

Effects on system behavior

Improves the performance of initial position estimation.
Initial position estimation takes only slightly more time.

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: Shintaro Sakoda <shintaro.sakoda@tier4.jp>
Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>
Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>
Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>
Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>
Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>
Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>
Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>
Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>
Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>
Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>
Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>
Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>
Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>
Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>
Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>
Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>
Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>
Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>
Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>
Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>
Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>
Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>
Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>
Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>
Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>
Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>
Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>
Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>
Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>
Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>
@github-actions github-actions bot added the type:documentation Creating or refining documentation. (auto-assigned) label Oct 5, 2023
Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>
@SakodaShintaro
Copy link
Contributor Author

@KYabuuchi

I added test on TPE. d56c845

You can test as following commands.

colcon build --symlink-install --cmake-args -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=ON --packages-select ndt_scan_matcher
colcon test --packages-select ndt_scan_matcher
colcon test-result --verbose

The details of the result are output to directories such as autoware/log/test_2023-10-05_18-22-43/ndt_scan_matcher/stdout.log

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>
Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>
@SakodaShintaro
Copy link
Contributor Author

SakodaShintaro commented Oct 6, 2023

@Motsu-san

This is a big change. I would like to review this carefully. Could you let us know the design changes with some functional block diagrams or something?

I added "Summary of Changes" figure to pull request description.

@SakodaShintaro SakodaShintaro marked this pull request as ready for review October 6, 2023 01:15
Signed-off-by: Shintaro SAKODA <shintaro.sakoda@tier4.jp>
Signed-off-by: Shintaro SAKODA <shintaro.sakoda@tier4.jp>
Signed-off-by: Shintaro SAKODA <shintaro.sakoda@tier4.jp>
Copy link
Contributor

@KYabuuchi KYabuuchi left a comment

Choose a reason for hiding this comment

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

@SakodaShintaro This will be my final question.
Once this is resolved, I will be ready to approve.

Copy link
Contributor

@KYabuuchi KYabuuchi left a comment

Choose a reason for hiding this comment

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

LGTM

@SakodaShintaro SakodaShintaro added the run:build-and-test-differential Mark to enable build-and-test-differential workflow. (used-by-ci) label Oct 12, 2023
@codecov
Copy link

codecov bot commented Oct 12, 2023

Codecov Report

Attention: 98 lines in your changes are missing coverage. Please review.

Comparison is base (84995ec) 14.84% compared to head (e484b9f) 14.87%.
Report is 15 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5078      +/-   ##
==========================================
+ Coverage   14.84%   14.87%   +0.03%     
==========================================
  Files        1649     1652       +3     
  Lines      114166   114328     +162     
  Branches    35323    35389      +66     
==========================================
+ Hits        16943    17008      +65     
- Misses      78102    78155      +53     
- Partials    19121    19165      +44     
Flag Coverage Δ *Carryforward flag
differential 7.14% <39.87%> (?)
total 14.84% <ø> (+<0.01%) ⬆️ Carriedforward from 84995ec

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

Files Coverage Δ
..._scan_matcher/tree_structured_parzen_estimator.hpp 0.00% <0.00%> (ø)
localization/ndt_scan_matcher/test/test_tpe.cpp 54.16% <54.16%> (ø)
...n_matcher/src/tree_structured_parzen_estimator.cpp 55.31% <55.31%> (ø)
...ion/ndt_scan_matcher/src/ndt_scan_matcher_core.cpp 0.00% <0.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@SakodaShintaro SakodaShintaro merged commit 21acc28 into autowarefoundation:main Oct 13, 2023
@SakodaShintaro SakodaShintaro deleted the feat/ndt_align_service_tpe branch October 13, 2023 04:27
@kminoda
Copy link
Contributor

kminoda commented Oct 14, 2023

Just realized that it may be better to change the name of the function align_using_monte_carlo 😅

shmpwk pushed a commit to tier4/autoware.universe that referenced this pull request Nov 16, 2023
…arefoundation#5078)

* Added output_pose_with_cov_to_log

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Added logging particles

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Added TreeStructuredParzenEstimator

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* FIxed to run TPE

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Fixed initial pose

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Fixed Input type

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Fixed good condition

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Fixed operation if good_num_ == 0

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Fixed cov

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Fixed parameter

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Fixed initial

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Fixed to use good_threshold_

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Fixed to count good_num_

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Fixed stddev

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Fixed parameter

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Fixed parameters

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Removed unused functions

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Fixed to abs

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Fixed parameters

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* FIxed parameter

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* add_trial by result

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* FIxed constructor

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* FIxed to use n_startup_trials_

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Fixed parameters

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Added kTargetScore

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Fixed constants

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Removed output_pose_with_cov_to_log

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Fixed a comment

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Added a parameter "n_startup_trials"

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* style(pre-commit): autofix

* Fixed include guard

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* style(pre-commit): autofix

* Fixed hyphen to underscore

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Added sample_from_prior

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Fixed to use log_sum_exp

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Fixed acquisition_function

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Fixed n_startup_trials_

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Fixed to 99%

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Fixed n_startup_trials_

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Fixed value of n_startup_trials

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Removed log output

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Fixed default value

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Removed static distributions

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Fixed PRIOR_WEIGHT

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Fixed order

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Added operator* to Input

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Fixed parameters

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Implemented normal tpe

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Added is_loop_variable

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Organized PRIOR_WEIGHT

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Fixed PRIOR_WEIGHT 0.0

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Added CONVERT_COEFF

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Fixed n_startup_trials

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Renamed acquisition_function to compute_log_likelihood_ratio

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Changed random number generator to static variables

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Added reference

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Fixed base_stddev_ to a const variable

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Fixed to use VALUE_WIDTH

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Removed a comment

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Added `n_startup_trials` to README.md

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Added a test about tpe

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Added the license statement

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Changed default `n_startup_trials` to 20

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Fixed sqrt(2) and added comments

Signed-off-by: Shintaro SAKODA <shintaro.sakoda@tier4.jp>

* Added comments

Signed-off-by: Shintaro SAKODA <shintaro.sakoda@tier4.jp>

* Added comments

Signed-off-by: Shintaro SAKODA <shintaro.sakoda@tier4.jp>

---------

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>
Signed-off-by: Shintaro SAKODA <shintaro.sakoda@tier4.jp>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
shmpwk pushed a commit to tier4/autoware.universe that referenced this pull request Nov 16, 2023
…arefoundation#5078)

* Added output_pose_with_cov_to_log

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Added logging particles

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Added TreeStructuredParzenEstimator

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* FIxed to run TPE

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Fixed initial pose

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Fixed Input type

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Fixed good condition

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Fixed operation if good_num_ == 0

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Fixed cov

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Fixed parameter

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Fixed initial

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Fixed to use good_threshold_

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Fixed to count good_num_

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Fixed stddev

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Fixed parameter

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Fixed parameters

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Removed unused functions

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Fixed to abs

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Fixed parameters

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* FIxed parameter

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* add_trial by result

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* FIxed constructor

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* FIxed to use n_startup_trials_

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Fixed parameters

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Added kTargetScore

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Fixed constants

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Removed output_pose_with_cov_to_log

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Fixed a comment

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Added a parameter "n_startup_trials"

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* style(pre-commit): autofix

* Fixed include guard

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* style(pre-commit): autofix

* Fixed hyphen to underscore

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Added sample_from_prior

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Fixed to use log_sum_exp

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Fixed acquisition_function

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Fixed n_startup_trials_

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Fixed to 99%

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Fixed n_startup_trials_

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Fixed value of n_startup_trials

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Removed log output

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Fixed default value

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Removed static distributions

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Fixed PRIOR_WEIGHT

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Fixed order

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Added operator* to Input

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Fixed parameters

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Implemented normal tpe

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Added is_loop_variable

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Organized PRIOR_WEIGHT

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Fixed PRIOR_WEIGHT 0.0

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Added CONVERT_COEFF

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Fixed n_startup_trials

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Renamed acquisition_function to compute_log_likelihood_ratio

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Changed random number generator to static variables

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Added reference

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Fixed base_stddev_ to a const variable

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Fixed to use VALUE_WIDTH

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Removed a comment

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Added `n_startup_trials` to README.md

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Added a test about tpe

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Added the license statement

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Changed default `n_startup_trials` to 20

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>

* Fixed sqrt(2) and added comments

Signed-off-by: Shintaro SAKODA <shintaro.sakoda@tier4.jp>

* Added comments

Signed-off-by: Shintaro SAKODA <shintaro.sakoda@tier4.jp>

* Added comments

Signed-off-by: Shintaro SAKODA <shintaro.sakoda@tier4.jp>

---------

Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp>
Signed-off-by: Shintaro SAKODA <shintaro.sakoda@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
component:localization Vehicle's position determination in its environment. (auto-assigned) run:build-and-test-differential Mark to enable build-and-test-differential workflow. (used-by-ci) type:documentation Creating or refining documentation. (auto-assigned)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants