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): estimate NDT covariance in real-time with limited initial positions #5338

Merged
merged 23 commits into from
Nov 7, 2023

Conversation

KOKIAOKI
Copy link
Contributor

@KOKIAOKI KOKIAOKI commented Oct 17, 2023

Description

Calculate 2D covariance (xx, xy, yx, yy) in real time using the convergence of NDT.
I limit the arrangement of multiple initial positions based on the Hessian matrix of the NDT score function.

Related links

original paper

Tests performed

I evaluated it In a tunnel evaluation (already shared in weekly meeting).
The real-time covariance estimation obtained the same convergence tendency as offline convergence evaluation.

Notes for reviewers

Related PRs:

Interface changes

  • topic
    /localization/pose_estimator/multi_ndt_pose
    ->NDT convergence positions
    /localization/pose_estimator/multi_initial_pose
    ->NDT initial positions

  • yaml setting (ndt_scan_matcher.param.yaml)
    Category: 2D Real-time covariance estimation (output_pose_covariance is the minimum value)
    Default use_covariance_estimation is false.

Effects on system behavior

Pre-review checklist for the PR author

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

  • I've confirmed the [contribution guidelines].
  • The PR follows the [pull request guidelines].

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.

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.

Thank you for creating the PR. I found a risky code in a brief review. Please check.

Initialize Eigen::Vector2d

Co-authored-by: Kento Yabuuchi <[email protected]>
Copy link
Contributor

@kminoda kminoda left a comment

Choose a reason for hiding this comment

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

Hi, thank you for the PR 🎉
Left some minor comments so please check 🙏

@@ -141,6 +141,15 @@ NDTScanMatcher::NDTScanMatcher()
initial_pose_distance_tolerance_m_ =
this->declare_parameter<double>("initial_pose_distance_tolerance_m");

use_cov_estimation_ = this->declare_parameter("use_covariance_estimation", use_cov_estimation_);
Copy link
Contributor

Choose a reason for hiding this comment

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

Please do not use the default parameter and instead do as follow

Suggested change
use_cov_estimation_ = this->declare_parameter("use_covariance_estimation", use_cov_estimation_);
use_cov_estimation_ = this->declare_parameter<bool>("use_covariance_estimation");

Comment on lines 493 to 498
// covariance estimation
std::array<double, 36> ndt_covariance;
ndt_covariance = output_pose_covariance_;
if (is_converged && use_cov_estimation_) {
estimate_covariance(ndt_result, initial_pose_matrix, ndt_covariance, sensor_ros_time);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe this part is relatively computationally heavy, so I would recommend to move this right after the following part:

  // perform ndt scan matching
  (*state_ptr_)["state"] = "Aligning";
  const Eigen::Matrix4f initial_pose_matrix =
    pose_to_matrix4f(interpolator.get_current_pose().pose.pose);
  auto output_cloud = std::make_shared<pcl::PointCloud<PointSource>>();
  ndt_ptr_->align(*output_cloud, initial_pose_matrix);
  const pclomp::NdtResult ndt_result = ndt_ptr_->getResult();
  (*state_ptr_)["state"] = "Sleeping

This will also enable users to monitor the total execution time with exe_time as well.

@YamatoAndo
Copy link
Contributor

@KOKIAOKI Thank you for your contribution!
Could you write an explanation in the readme?
I'd also like you to include a link of your paper in the readme.

@KOKIAOKI
Copy link
Contributor Author

KOKIAOKI commented Oct 18, 2023

Thank you for checking my implementation.
Please let me test again after fixing these fixes.

@github-actions github-actions bot added the type:documentation Creating or refining documentation. (auto-assigned) label Oct 18, 2023
@KOKIAOKI
Copy link
Contributor Author

KOKIAOKI commented Oct 24, 2023

I tested the fixed source code. It worked fine in my environment.

Here are the corrections

  • I have corrected all the issues pointed out by reviewers.
    • Moved is_converged processing and processing time calculation.
  • Added "const" to all immutable variables.
  • Removed unnecessary comments

I will resolve the confliction later

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.

I added some comments. Please check it out 🙏

localization/ndt_scan_matcher/README.md Outdated Show resolved Hide resolved
localization/localization_util/src/util_func.cpp Outdated Show resolved Hide resolved
@KOKIAOKI
Copy link
Contributor Author

KOKIAOKI commented Oct 26, 2023

Sorry for the delay in reporting.
I have reflected all the reviews made by @Motsu-san and @KYabuuchi into the source code.

  • Changed the calculation of covariance to a method that uses smaller variables.
  • There were many variable names that caused misunderstandings, so I made them easier to understand.
  • Changed and added notes and explanations in README

Thank you for further reviewing!

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

codecov bot commented Oct 27, 2023

Codecov Report

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

Comparison is base (4e00bf2) 14.84% compared to head (3e31b93) 15.09%.
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5338      +/-   ##
==========================================
+ Coverage   14.84%   15.09%   +0.24%     
==========================================
  Files        1665     1661       -4     
  Lines      116231   115372     -859     
  Branches    36256    35646     -610     
==========================================
+ Hits        17259    17419     +160     
+ Misses      79473    78436    -1037     
- Partials    19499    19517      +18     
Flag Coverage Δ *Carryforward flag
differential 0.00% <0.00%> (?)
total 15.10% <ø> (+0.25%) ⬆️ Carriedforward from 5eda6c3

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

Files Coverage Δ
...ion/ndt_scan_matcher/src/ndt_scan_matcher_core.cpp 0.00% <0.00%> (ø)

... and 64 files with indirect coverage changes

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

@KOKIAOKI
Copy link
Contributor Author

@YamatoAndo @KYabuuchi
Thank you for further checks.
I created the function of eigenvector calculation and added README empty line.

…to ndt_scan_matcher.cpp, fix README line

Signed-off-by: Koki Aoki <[email protected]>
@KOKIAOKI
Copy link
Contributor Author

KOKIAOKI commented Nov 1, 2023

@YamatoAndo @KYabuuchi @SakodaShintaro
Thank you for further code checks.
Main changes are as below:

  • @SakodaShintaro Like your advice, I added parameter warning and std::exeption about Eigen::Success.
  • @SakodaShintaro Although review about util.cpp was closed, I moved two functions from util.cpp to ndt_scan_matcher.cpp.

@YamatoAndo YamatoAndo merged commit 55c615c into autowarefoundation:main Nov 7, 2023
19 of 24 checks passed
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.

6 participants