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(autoware_ground_segmentation): grid data structure revision for efficiency improve #9297

Open
wants to merge 41 commits into
base: main
Choose a base branch
from

Conversation

technolojin
Copy link
Contributor

@technolojin technolojin commented Nov 12, 2024

Description

Change data structure of grid for calculation efficiency improvement.

  1. (Performance) Grid and grid cells are defined
  2. (Performance) The grid geometry is modeled to Concentric Zone Model (CZM) based polar grid
  3. (Refactor) The grid process is separated from node.cpp
  4. (Performance) The segmentation process is ran cell-wise (while current process is point-wise).
  5. (Performance) Replace arc tangent (atan2) to a pseudo arc tangent function for better performance (with accuracy drop, which can be acceptable)

How the efficiency is improved

  1. By replacing existing data structure, sorting is not needed.
  2. Segmentation condition (connected, disconnected, break) is determined grid cell-wise, not point-wise.
  3. Concentric Zone Model (CZM) based polar grid allows to make various grid cell density. The grid is configured to have lower number of the grids close to the ego vehicle. Less grid cells means lower cell-related calculation.
  4. The arc tangent is used for grid allocation on each points. The grid cell allocation do not require high accuracy, therefore, it can be replaced by approximation.

Drawbacks

  1. Introducing CZM polar grid requires cell geometry calculation. If the number of cell grids is large, the calculation can take longer time.
  2. Finding non-empty grid cell take calculation cost. Increase by the number of cell grids.
  3. If the grid cells contains few points, performance improvement will be limited.

Drawback mitigation

set the parameter grid_size_m to 0.5
PR autowarefoundation/autoware_launch#1223

Related links

Parent Issue:

  • Link

How was this PR tested?

Performance test (check degradation)

TIER IV INTERNAL

Processing time

Before

Computation time difference by grid size is negligible.

  • Before: grid_size_m: 0.1
🌲 Total Processing Time Tree 🌲
100.00% faster_filter: total 3118.96 [ms], avg. 12.89 [ms], run count: 242
    ├── 74.77% convertPointcloudGridScan: total 2332.12 [ms], avg. 9.64 [ms], run count: 242
    │   ├── 52.53% azimuth_angle_grouping: total 1638.31 [ms], avg. 6.77 [ms], run count: 242
    │   ├── 22.12% sort: total 690.03 [ms], avg. 2.85 [ms], run count: 242
    │   └── 0.12% rest: 3.79 [ms]
    ├── 22.85% classifyPointCloudGridScan: total 712.62 [ms], avg. 2.94 [ms], run count: 242
    ├── 1.53% extractObjectPoints: total 47.75 [ms], avg. 0.20 [ms], run count: 242
    └── 0.85% rest: 26.46 [ms]
  • Before: grid_size_m: 0.2
🌲 Total Processing Time Tree 🌲
100.00% faster_filter: total 3129.68 [ms], avg. 12.88 [ms], run count: 243
    ├── 76.50% convertPointcloudGridScan: total 2394.23 [ms], avg. 9.85 [ms], run count: 243
    │   ├── 54.11% azimuth_angle_grouping: total 1693.44 [ms], avg. 6.97 [ms], run count: 243
    │   ├── 22.28% sort: total 697.30 [ms], avg. 2.87 [ms], run count: 243
    │   └── 0.11% rest: 3.49 [ms]
    ├── 21.30% classifyPointCloudGridScan: total 666.66 [ms], avg. 2.74 [ms], run count: 243
    ├── 1.34% extractObjectPoints: total 41.92 [ms], avg. 0.17 [ms], run count: 243
    └── 0.86% rest: 26.87 [ms]
  • Before: grid_size_m: 0.5
🌲 Total Processing Time Tree 🌲
100.00% faster_filter: total 3012.68 [ms], avg. 12.66 [ms], run count: 238
    ├── 78.02% convertPointcloudGridScan: total 2350.36 [ms], avg. 9.88 [ms], run count: 238
    │   ├── 55.51% azimuth_angle_grouping: total 1672.34 [ms], avg. 7.03 [ms], run count: 238
    │   ├── 22.39% sort: total 674.44 [ms], avg. 2.83 [ms], run count: 238
    │   └── 0.12% rest: 3.58 [ms]
    ├── 19.86% classifyPointCloudGridScan: total 598.35 [ms], avg. 2.51 [ms], run count: 238
    ├── 1.28% extractObjectPoints: total 38.42 [ms], avg. 0.16 [ms], run count: 238
    └── 0.85% rest: 25.56 [ms]
  • Before: grid_size_m: 1.0
🌲 Total Processing Time Tree 🌲
100.00% faster_filter: total 3021.20 [ms], avg. 12.54 [ms], run count: 241
    ├── 78.97% convertPointcloudGridScan: total 2385.86 [ms], avg. 9.90 [ms], run count: 241
    │   ├── 55.63% azimuth_angle_grouping: total 1680.76 [ms], avg. 6.97 [ms], run count: 241
    │   ├── 23.22% sort: total 701.58 [ms], avg. 2.91 [ms], run count: 241
    │   └── 0.12% rest: 3.52 [ms]
    ├── 18.84% classifyPointCloudGridScan: total 569.28 [ms], avg. 2.36 [ms], run count: 241
    ├── 1.32% extractObjectPoints: total 39.87 [ms], avg. 0.17 [ms], run count: 241
    └── 0.87% rest: 26.19 [ms]

After

The larger grid size, the lower computation time.

  • After: grid_size_m: 0.1
🌲 Total Processing Time Tree 🌲
100.00% faster_filter: total 4829.41 [ms], avg. 19.96 [ms], run count: 242
    ├── 98.48% process: total 4755.83 [ms], avg. 19.65 [ms], run count: 242
    │   ├── 8.14% resetCells: total 392.91 [ms], avg. 1.62 [ms], run count: 242
    │   ├── 21.71% convert: total 1048.67 [ms], avg. 4.33 [ms], run count: 242
    │   ├── 10.50% preprocess: total 507.22 [ms], avg. 2.10 [ms], run count: 242
    │   │   ├── 10.49% setGridConnections: total 506.39 [ms], avg. 2.09 [ms], run count: 242
    │   │   └── 0.02% rest: 0.83 [ms]
    │   ├── 4.58% initializeGround: total 221.22 [ms], avg. 0.91 [ms], run count: 242
    │   ├── 53.39% classify: total 2578.31 [ms], avg. 10.65 [ms], run count: 242
    │   └── 0.16% rest: 7.50 [ms]
    ├── 1.17% extractObjectPoints: total 56.59 [ms], avg. 0.23 [ms], run count: 242
    └── 0.35% rest: 16.99 [ms]

  • After: grid_size_m: 0.2
🌲 Total Processing Time Tree 🌲
100.00% faster_filter: total 3486.55 [ms], avg. 14.35 [ms], run count: 243
    ├── 97.94% process: total 3414.80 [ms], avg. 14.05 [ms], run count: 243
    │   ├── 6.08% resetCells: total 212.07 [ms], avg. 0.87 [ms], run count: 243
    │   ├── 24.60% convert: total 857.85 [ms], avg. 3.53 [ms], run count: 243
    │   ├── 6.70% preprocess: total 233.55 [ms], avg. 0.96 [ms], run count: 243
    │   │   ├── 6.68% setGridConnections: total 232.85 [ms], avg. 0.96 [ms], run count: 243
    │   │   └── 0.02% rest: 0.70 [ms]
    │   ├── 3.73% initializeGround: total 130.04 [ms], avg. 0.54 [ms], run count: 243
    │   ├── 56.65% classify: total 1975.29 [ms], avg. 8.13 [ms], run count: 243
    │   └── 0.17% rest: 6.00 [ms]
    ├── 1.57% extractObjectPoints: total 54.74 [ms], avg. 0.23 [ms], run count: 243
    └── 0.49% rest: 17.01 [ms]
  • After: grid_size_m: 0.5
🌲 Total Processing Time Tree 🌲
100.00% faster_filter: total 2503.10 [ms], avg. 10.26 [ms], run count: 244
    ├── 97.29% process: total 2435.27 [ms], avg. 9.98 [ms], run count: 244
    │   ├── 3.21% resetCells: total 80.33 [ms], avg. 0.33 [ms], run count: 244
    │   ├── 29.74% convert: total 744.51 [ms], avg. 3.05 [ms], run count: 244
    │   ├── 3.09% preprocess: total 77.26 [ms], avg. 0.32 [ms], run count: 244
    │   │   ├── 3.05% setGridConnections: total 76.42 [ms], avg. 0.31 [ms], run count: 244
    │   │   └── 0.03% rest: 0.84 [ms]
    │   ├── 1.97% initializeGround: total 49.26 [ms], avg. 0.20 [ms], run count: 244
    │   ├── 59.07% classify: total 1478.57 [ms], avg. 6.06 [ms], run count: 244
    │   └── 0.21% rest: 5.35 [ms]
    ├── 1.95% extractObjectPoints: total 48.80 [ms], avg. 0.20 [ms], run count: 244
    └── 0.76% rest: 19.03 [ms]
  • After: grid_size_m: 1.0
🌲 Total Processing Time Tree 🌲
100.00% faster_filter: total 1989.49 [ms], avg. 8.22 [ms], run count: 242
    ├── 96.41% process: total 1918.08 [ms], avg. 7.93 [ms], run count: 242
    │   ├── 2.04% resetCells: total 40.52 [ms], avg. 0.17 [ms], run count: 242
    │   ├── 34.13% convert: total 679.11 [ms], avg. 2.81 [ms], run count: 242
    │   ├── 1.59% preprocess: total 31.61 [ms], avg. 0.13 [ms], run count: 242
    │   │   ├── 1.56% setGridConnections: total 31.09 [ms], avg. 0.13 [ms], run count: 242
    │   │   └── 0.03% rest: 0.52 [ms]
    │   ├── 1.71% initializeGround: total 34.12 [ms], avg. 0.14 [ms], run count: 242
    │   ├── 56.69% classify: total 1127.92 [ms], avg. 4.66 [ms], run count: 242
    │   └── 0.24% rest: 4.80 [ms]
    ├── 2.55% extractObjectPoints: total 50.80 [ms], avg. 0.21 [ms], run count: 242
    └── 1.04% rest: 20.61 [ms]

Notes for reviewers

None.

Interface changes

None.

Effects on system behavior

None.

@github-actions github-actions bot added component:perception Advanced sensor data processing and environment understanding. (auto-assigned) tag:require-cuda-build-and-test labels Nov 12, 2024
Copy link

github-actions bot commented Nov 12, 2024

Thank you for contributing to the Autoware project!

🚧 If your pull request is in progress, switch it to draft mode.

Please ensure:

Signed-off-by: Taekjin LEE <[email protected]>
… size

refactor: Update Grid class initialization to use radians for azimuth size

refactor: Update Grid class initialization to use radians for azimuth size
Signed-off-by: Taekjin LEE <[email protected]>
Signed-off-by: Taekjin LEE <[email protected]>
Signed-off-by: Taekjin LEE <[email protected]>
…nt a segmentation logic

refactor: Update Grid class initialization and reset methods, implement a segmentation logic

refactor: replace original methods
Signed-off-by: Taekjin LEE <[email protected]>
Signed-off-by: Taekjin LEE <[email protected]>
refactor: remove previous scan ground grid
Signed-off-by: Taekjin LEE <[email protected]>
fix: ground bin logic fix
Signed-off-by: Taekjin LEE <[email protected]>
fix: azimuth grid index converter bug
Signed-off-by: Taekjin LEE <[email protected]>
fix: cell connection bug fix
Signed-off-by: Taekjin LEE <[email protected]>
…onnection

Remove unused code and optimize grid radial calculation

Signed-off-by: Taekjin LEE <[email protected]>
…ection

Optimize grid radial calculation and remove unused code

Signed-off-by: Taekjin LEE <[email protected]>
Signed-off-by: Taekjin LEE <[email protected]>
@technolojin technolojin added the tag:run-build-and-test-differential Mark to enable build-and-test-differential workflow. (used-by-ci) label Nov 13, 2024
Copy link

codecov bot commented Nov 13, 2024

Codecov Report

Attention: Patch coverage is 85.46169% with 74 lines in your changes missing coverage. Please review.

Project coverage is 14.60%. Comparing base (1ab29fd) to head (980e054).
Report is 9 commits behind head on main.

Files with missing lines Patch % Lines
...tion/src/scan_ground_filter/grid_ground_filter.cpp 88.74% 14 Missing and 12 partials ⚠️
...round_segmentation/src/scan_ground_filter/grid.hpp 88.42% 7 Missing and 15 partials ⚠️
...tion/src/scan_ground_filter/grid_ground_filter.hpp 68.08% 11 Missing and 4 partials ⚠️
...round_segmentation/src/scan_ground_filter/node.cpp 72.00% 5 Missing and 2 partials ⚠️
...round_segmentation/src/scan_ground_filter/data.hpp 75.00% 1 Missing and 3 partials ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main    #9297       +/-   ##
===========================================
- Coverage   29.19%   14.60%   -14.59%     
===========================================
  Files        1333       84     -1249     
  Lines      102795     5978    -96817     
  Branches    39870     1407    -38463     
===========================================
- Hits        30008      873    -29135     
+ Misses      69926     4984    -64942     
+ Partials     2861      121     -2740     
Flag Coverage Δ
differential 14.60% <85.46%> (?)
total ?

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

@technolojin technolojin marked this pull request as ready for review November 13, 2024 06:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component:perception Advanced sensor data processing and environment understanding. (auto-assigned) tag:require-cuda-build-and-test tag:run-build-and-test-differential Mark to enable build-and-test-differential workflow. (used-by-ci)
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

1 participant