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(ndt_scan_matcher): fixed a lock scope in update_ndt #5951

Conversation

SakodaShintaro
Copy link
Contributor

@SakodaShintaro SakodaShintaro commented Dec 25, 2023

Description

In this pull request, the data race for ndt_ptr_ has been fixed.

Context

In the traditional code, within the update_ndt() of the map_update_module, a copy of the ndt_ptr_ was obtained and changes were applied to this copy then it was written back.

However, the class NormalDistributionsTransform, which was copied, internally contains a shared_ptr as a member variable. As a result, a simple copy resulted in a shallow copy.

Consequently, when the map update of NDT and the pose estimation by NDT occurred simultaneously, it led to data race issues.

Changes

Because the shared_ptr is deeply used in the NormalDistributionsTransform, implementing a deep copy is difficult.

So the lock scope has been expanded. As a result, it is no longer necessary to make a copy of ndt_ptr_, and updates are now applied directly to the original object. Converting the type of the additional points is a heavy process, so this is now pre-calculated outside of the lock scope.

Tests performed

It has been confirmed that the logging_simulator runs with the same accuracy as before on AWSIM data with GT.

Process time

Since the lock scope is larger than previously thought, the time to stop pose estimation by ndt will also be longer.

The time taken to update the map was measured.

Environment : ThinkPad X1 Extreme Gen 4 (11th Gen Intel(R) Core(TM) i7-11800H @ 2.30GHz)

process_time

The first time is adding a new map, so it takes a lot of time to ndt_ptr_->addTarget.

From the second time, a differential update is done, and typically, createVoxelKdtree is the time-consuming part. If there are many points to add, the ndt_ptr_->addTarget also takes time.

In the future, it may be better to recreate NormalDistributionsTransform to enable deep copy.

endurance test

I ran logging_simulator 170 times for about 12 hours and confirmed that ndt_scan_matcher did not crash even once.

Effects on system behavior

The issue of the node potentially crashing during dynamic map loading is resolved.

However, pose estimation by ndt has a slight delay when the map is differential updated.

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>
@github-actions github-actions bot added the component:localization Vehicle's position determination in its environment. (auto-assigned) label Dec 25, 2023
@SakodaShintaro SakodaShintaro self-assigned this Dec 25, 2023
@SakodaShintaro SakodaShintaro added the tag:run-build-and-test-differential Mark to enable build-and-test-differential workflow. (used-by-ci) label Dec 25, 2023
Copy link

codecov bot commented Dec 25, 2023

Codecov Report

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

Comparison is base (83d316c) 15.28% compared to head (1c16bfd) 15.28%.

Files Patch % Lines
...ization/ndt_scan_matcher/src/map_update_module.cpp 0.00% 9 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5951   +/-   ##
=======================================
  Coverage   15.28%   15.28%           
=======================================
  Files        1750     1750           
  Lines      120435   120435           
  Branches    36731    36731           
=======================================
  Hits        18405    18405           
  Misses      81378    81378           
  Partials    20652    20652           
Flag Coverage Δ *Carryforward flag
differential 3.07% <0.00%> (?)
total 15.28% <ø> (+<0.01%) ⬆️ Carriedforward from 83d316c

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

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

@SakodaShintaro
Copy link
Contributor Author

I ran logging_simulator 170 times for about 12 hours and confirmed that ndt_scan_matcher did not crash even once.

@YamatoAndo
Could you review this pull request?

@SakodaShintaro SakodaShintaro merged commit 306c7c3 into autowarefoundation:main Dec 26, 2023
42 of 43 checks passed
@SakodaShintaro SakodaShintaro deleted the fix/lock_scope_in_update_ndt branch December 26, 2023 08:28
0x126 pushed a commit to tier4/autoware.universe that referenced this pull request Jan 14, 2024
…dation#5951)

Fixed the lock scope in update_ndt

Signed-off-by: Shintaro SAKODA <shintaro.sakoda@tier4.jp>
saka1-s pushed a commit to saka1-s/autoware.universe that referenced this pull request Feb 2, 2024
…dation#5951)

Fixed the lock scope in update_ndt

Signed-off-by: Shintaro SAKODA <shintaro.sakoda@tier4.jp>
TomohitoAndo pushed a commit to tier4/autoware.universe that referenced this pull request Feb 21, 2024
…dation#5951)

Fixed the lock scope in update_ndt

Signed-off-by: Shintaro SAKODA <shintaro.sakoda@tier4.jp>
saka1-s added a commit to tier4/autoware.universe that referenced this pull request Mar 11, 2024
* feat(avoidance): keep stopping until all shift lines are registered

Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>

* feat(map_loader): display curbstone as marker array (autowarefoundation#4958)

display curbstone as marker array

Signed-off-by: Shohei Sakai <saka1s.jp@gmail.com>
Co-authored-by: kminoda <44218668+kminoda@users.noreply.github.com>

* revert refactoring due to cherry-pick

* feat(ndt_scan_matcher): use glog (autowarefoundation#5465) (#1031)

* feat(ndt_scan_matcher): use glog



* style(pre-commit): autofix

* update



* style(pre-commit): autofix

---------

Signed-off-by: kminoda <koji.minoda@tier4.jp>
Co-authored-by: kminoda <44218668+kminoda@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* feat(out_of_lane): improve reuse of previous decision (#1017)

* Do not directly reuse a prev stop point but project it on the new path

Signed-off-by: Maxime CLEMENT <maxime.clement@tier4.jp>

* Improve reuse of the previously inserted stop point

Signed-off-by: Maxime CLEMENT <maxime.clement@tier4.jp>

* Fix precision of inserted stop point

Signed-off-by: Maxime CLEMENT <maxime.clement@tier4.jp>

---------

Signed-off-by: Maxime CLEMENT <maxime.clement@tier4.jp>

* fix(system_monitor): output command line (autowarefoundation#5430) (#1057)

* fix(system_monitor): output command line



* style(pre-commit): autofix

---------

Signed-off-by: takeshi.iwanari <takeshi.iwanari@tier4.jp>
Co-authored-by: takeshi-iwanari <takeshi.iwanari@tier4.jp>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* chore: pull tracking object merger from awf/main

Signed-off-by: yoshiri <yoshiyoshidetteiu@gmail.com>

* feat(intersection): check path margin for overshoot vehicles on red light (autowarefoundation#5394) (#1056)

Co-authored-by: Mamoru Sobue <mamoru.sobue@tier4.jp>

* fix(ndt_scan_matcher): delete diagnostics thread (autowarefoundation#5532)

Signed-off-by: yamato-ando <Yamato ANDO>
Co-authored-by: yamato-ando <Yamato ANDO>

* fix(ndt_scan_matcher): delete unmerged feature

* fix(ndt_scan_matcher): fixed a lock scope in update_ndt (autowarefoundation#5951)

Fixed the lock scope in update_ndt

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

* fix(static_drivable_area_expansion): fix bug in expansion logic for hatched road marking (autowarefoundation#5842) (#1075)

fix(utils): fix drivable area expansion logic for zebra zone

Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>

* fix(bvp): traffic light state debug (#1083)

Signed-off-by: Mehmet Dogru <mdogru@leodrive.ai>

* fix(traffic_light): stop if the traffic light signal timed out (autowarefoundation#5819) (#1124)

* fix(traffic_light): stop if the traffic light signal timed out



* fix(traffic_light): fix README format



---------

Signed-off-by: Fumiya Watanabe <rej55.g@gmail.com>
Signed-off-by: Tomohito Ando <tomohito.ando@tier4.jp>
Co-authored-by: Fumiya Watanabe <rej55.g@gmail.com>

* refactor(mpc_lateral_controller): add debug info of qp solver (autowarefoundation#5459) (#1098)

* add debug info of qp solver



* no info for EigenLeastSquareLLT



* return 0 in base class

---------

Signed-off-by: kyoichi-sugahara <kyoichi.sugahara@tier4.jp>
Co-authored-by: Kyoichi Sugahara <kyoichi.sugahara@tier4.jp>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

---------

Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>
Signed-off-by: Shohei Sakai <saka1s.jp@gmail.com>
Signed-off-by: kminoda <koji.minoda@tier4.jp>
Signed-off-by: Maxime CLEMENT <maxime.clement@tier4.jp>
Signed-off-by: takeshi.iwanari <takeshi.iwanari@tier4.jp>
Signed-off-by: yoshiri <yoshiyoshidetteiu@gmail.com>
Signed-off-by: yamato-ando <Yamato ANDO>
Signed-off-by: Shintaro SAKODA <shintaro.sakoda@tier4.jp>
Signed-off-by: Mehmet Dogru <mdogru@leodrive.ai>
Signed-off-by: Fumiya Watanabe <rej55.g@gmail.com>
Signed-off-by: Tomohito Ando <tomohito.ando@tier4.jp>
Signed-off-by: kyoichi-sugahara <kyoichi.sugahara@tier4.jp>
Co-authored-by: satoshi-ota <satoshi.ota928@gmail.com>
Co-authored-by: kminoda <44218668+kminoda@users.noreply.github.com>
Co-authored-by: Tomohito ANDO <tomohito.ando@tier4.jp>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Maxime CLEMENT <78338830+maxime-clem@users.noreply.github.com>
Co-authored-by: takeshi-iwanari <takeshi.iwanari@tier4.jp>
Co-authored-by: yoshiri <yoshiyoshidetteiu@gmail.com>
Co-authored-by: Mamoru Sobue <mamoru.sobue@tier4.jp>
Co-authored-by: Yamato Ando <yamato.ando@gmail.com>
Co-authored-by: Shinnosuke Hirakawa <shinnosuke.hirakawa@tier4.jp>
Co-authored-by: SakodaShintaro <shintaro.sakoda@tier4.jp>
Co-authored-by: Satoshi OTA <44889564+satoshi-ota@users.noreply.github.com>
Co-authored-by: Mehmet Dogru <48479081+mehmetdogru@users.noreply.github.com>
Co-authored-by: Fumiya Watanabe <rej55.g@gmail.com>
Co-authored-by: Kyoichi Sugahara <kyoichi.sugahara@tier4.jp>
karishma1911 pushed a commit to Interplai/autoware.universe that referenced this pull request May 26, 2024
…dation#5951)

Fixed the lock scope in update_ndt

Signed-off-by: Shintaro SAKODA <shintaro.sakoda@tier4.jp>
karishma1911 pushed a commit to Interplai/autoware.universe that referenced this pull request May 28, 2024
…dation#5951)

Fixed the lock scope in update_ndt

Signed-off-by: Shintaro SAKODA <shintaro.sakoda@tier4.jp>
karishma1911 pushed a commit to Interplai/autoware.universe that referenced this pull request May 28, 2024
…dation#5951)

Fixed the lock scope in update_ndt

Signed-off-by: Shintaro SAKODA <shintaro.sakoda@tier4.jp>
karishma1911 pushed a commit to Interplai/autoware.universe that referenced this pull request Jun 3, 2024
…dation#5951)

Fixed the lock scope in update_ndt

Signed-off-by: Shintaro SAKODA <shintaro.sakoda@tier4.jp>
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) tag:run-build-and-test-differential Mark to enable build-and-test-differential workflow. (used-by-ci)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants