-
Notifications
You must be signed in to change notification settings - Fork 798
feat: gpu ground segmentation #11371
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
Open
anhnv3991
wants to merge
80
commits into
autowarefoundation:main
Choose a base branch
from
anhnv3991:feat/gpu_ground_seg
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
80 commits
Select commit
Hold shift + click to select a range
49bc8d8
init cuda ground segmentation node
badai-nguyen c8c5c37
feat: add cuda_scan_ground_segmentation node
badai-nguyen f372be5
fix: launch
badai-nguyen 818ea83
refactor
badai-nguyen 81e1049
refactor
badai-nguyen c3d660e
fix: atan error
badai-nguyen 2dd8863
fix: num output point host reference
badai-nguyen 4675b21
pre-commit
badai-nguyen 971ad57
feat: add ground pointcloud publish for debug
badai-nguyen f45d118
refactor
badai-nguyen ab957d2
refactor
badai-nguyen 9ba6e10
refactor
badai-nguyen a9ad968
fix: param path
badai-nguyen 63c9826
feat: add debug processing time
badai-nguyen 3d334c0
delete pointcloud preprocesor ground segmentation
badai-nguyen d6b3730
typo
badai-nguyen 0345f0e
refactoring
badai-nguyen 69f429d
refactoring
badai-nguyen e6bd38d
fix: variable type
badai-nguyen ad4f6ca
refactoring
badai-nguyen a6820a0
typo
badai-nguyen b2b439d
style(pre-commit): autofix
pre-commit-ci-lite[bot] c0c6ebd
revert launch change
badai-nguyen f8ab1ff
docs
badai-nguyen 946a005
style(pre-commit): autofix
pre-commit-ci-lite[bot] 5019c6a
revise variable type
badai-nguyen ccd469b
fix: avoid very small d_radius
badai-nguyen 1b3f0f3
docs: add README
badai-nguyen 83cfd0f
style(pre-commit): autofix
pre-commit-ci-lite[bot] 23c68a4
docs
badai-nguyen dd976e5
refactor
badai-nguyen f111fd6
style(pre-commit): autofix
pre-commit-ci-lite[bot] 501fd9b
docs: add schema
badai-nguyen 6d6d2ce
fix(recheck): classifiied local pointcloud index bug
badai-nguyen cb18f26
fix: launch
badai-nguyen be55174
remove vehicle info depend
badai-nguyen c6569e2
Adding GPU ground segmentation
da86925
Finished coding
633b9db
Fixed
914b2bd
Fixed
aea4778
Merge branch 'autowarefoundation:main' into feat/gpu_ground_seg
5408e9e
Fixed all. Debug code remains.
2634f92
Remove debug code.
fe34ef9
Merge branch 'autowarefoundation:main' into feat/gpu_ground_seg
bb0fe69
style(pre-commit): autofix
pre-commit-ci-lite[bot] c21e07e
Remove wrong code
07b099c
Merge branch 'main' into feat/gpu_ground_seg
5815d4b
Fixed pre-commit-lite
65bfa27
style(pre-commit): autofix
pre-commit-ci-lite[bot] 728d229
Fixed pre-commit-lite
547e5cf
Fix typos
0e9d6c2
Ignore CUDAH spell check
9395032
Merge branch 'main' into feat/gpu_ground_seg
cb9727b
Add license info
a7ca91e
style(pre-commit): autofix
pre-commit-ci-lite[bot] fad43b5
Merge branch 'autowarefoundation:main' into feat/gpu_ground_seg
anhnv3991 7827ffe
Replace sensor_msgs PointCloud2 by cuda_blackboard PointCloud2
5e74ea9
Merge branch 'autowarefoundation:main' into feat/gpu_ground_seg
anhnv3991 49b0dd5
style(pre-commit): autofix
pre-commit-ci-lite[bot] d61b580
Use cuda_blackboard pointcloud 2
9947dec
Merge branch 'main' into feat/gpu_ground_seg
6bf6865
style(pre-commit): autofix
pre-commit-ci-lite[bot] e143391
Merge branch 'main' into feat/gpu_ground_seg
35c6835
add launch option
badai-nguyen f39b91b
style(pre-commit): autofix
pre-commit-ci-lite[bot] 8246bc9
replace radius_max by xzy max min
badai-nguyen 9d4be4f
style(pre-commit): autofix
pre-commit-ci-lite[bot] d823019
Remove point number limit of each thread
4942b90
Merge branch 'autowarefoundation:main' into feat/gpu_ground_seg
anhnv3991 ed734dc
style(pre-commit): autofix
pre-commit-ci-lite[bot] f6b0582
Fixed build error
b7e5446
fix: input topics
badai-nguyen 35fbfa2
fix schema check
badai-nguyen 89aa7c0
style(pre-commit): autofix
pre-commit-ci-lite[bot] 2da6096
docs: update readme
badai-nguyen c951004
refactor: remove unused param
badai-nguyen 9dfd826
typo
badai-nguyen b3561cb
fix: center shift
badai-nguyen 853ff57
Fixed errors
07c0fa1
style(pre-commit): autofix
pre-commit-ci-lite[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
131 changes: 131 additions & 0 deletions
131
perception/autoware_ground_segmentation_cuda/CMakeLists.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,131 @@ | ||
| cmake_minimum_required(VERSION 3.8) | ||
| project(autoware_ground_segmentation_cuda) | ||
|
|
||
| find_package(ament_cmake_auto REQUIRED) | ||
| find_package(CUDA) | ||
| find_package(agnocastlib) | ||
|
|
||
| if(NOT ${CUDA_FOUND}) | ||
| message(WARNING "cuda was not found, so the autoware_ground_segmentation_cuda package will not be built.") | ||
| return() | ||
| elseif(CMAKE_BUILD_TYPE STREQUAL "Debug") | ||
| set(CMAKE_CUDA_FLAGS ${CMAKE_CUDA_FLAGS} "-g -G") | ||
| set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} "-g -G") | ||
| endif() | ||
|
|
||
| if(USE_AGNOCAST AND NOT agnocastlib_FOUND) | ||
| message(FATAL_ERROR "agnocastlib is required when USE_AGNOCAST is enabled") | ||
| endif() | ||
|
|
||
| ament_auto_find_build_dependencies() | ||
|
|
||
| # Default to C++17 | ||
| if(NOT CMAKE_CXX_STANDARD) | ||
| set(CMAKE_CXX_STANDARD 17) | ||
| endif() | ||
|
|
||
| if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") | ||
| add_compile_options(-Wall -Wextra -Wpedantic -Wunused-function) | ||
| endif() | ||
|
|
||
| if(USE_AGNOCAST) | ||
| add_definitions(-DUSE_AGNOCAST_ENABLED) | ||
| endif() | ||
|
|
||
| if(BUILD_TESTING) | ||
| list(APPEND AMENT_LINT_AUTO_EXCLUDE ament_cmake_uncrustify) | ||
| find_package(ament_lint_auto REQUIRED) | ||
| ament_lint_auto_find_test_dependencies() | ||
| endif() | ||
|
|
||
| include_directories( | ||
| include | ||
| SYSTEM | ||
| ${CUDA_INCLUDE_DIRS} | ||
| ) | ||
|
|
||
| # cSpell: ignore expt gencode | ||
| list(APPEND CUDA_NVCC_FLAGS "--expt-relaxed-constexpr -diag-suppress 20012") | ||
| list(APPEND CUDA_NVCC_FLAGS "-gencode arch=compute_75,code=sm_75") | ||
| list(APPEND CUDA_NVCC_FLAGS "-gencode arch=compute_86,code=sm_86") | ||
| list(APPEND CUDA_NVCC_FLAGS "-gencode arch=compute_87,code=sm_87") | ||
| list(APPEND CUDA_NVCC_FLAGS "-gencode arch=compute_89,code=sm_89") | ||
| list(APPEND CUDA_NVCC_FLAGS "-gencode arch=compute_89,code=compute_89") | ||
|
|
||
| #################### cuda_ground_segmentation ################## | ||
| cuda_add_library(cuda_ground_segmentation_lib SHARED | ||
| src/cuda_scan_ground_segmentation/cuda_scan_ground_segmentation_filter.cu | ||
| ) | ||
|
|
||
| target_link_libraries(cuda_ground_segmentation_lib | ||
| ${autoware_pointcloud_preprocessor_TARGETS} | ||
| ${autoware_cuda_pointcloud_preprocessor_TARGETS} | ||
| ) | ||
|
|
||
| target_include_directories(cuda_ground_segmentation_lib SYSTEM PRIVATE | ||
| ${autoware_pointcloud_preprocessor_INCLUDE_DIRS} | ||
| ${autoware_cuda_pointcloud_preprocessor_INCLUDE_DIRS} | ||
| ${autoware_point_types_INCLUDE_DIRS} | ||
| ${cuda_blackboard_INCLUDE_DIRS} | ||
| ${diagnostic_msgs_INCLUDE_DIRS} | ||
| ${geometry_msgs_INCLUDE_DIRS} | ||
| ${rclcpp_INCLUDE_DIRS} | ||
| ${rclcpp_components_INCLUDE_DIRS} | ||
| ${rcl_interfaces_INCLUDE_DIRS} | ||
| ${sensor_msgs_INCLUDE_DIRS} | ||
| ${tf2_INCLUDE_DIRS} | ||
| ${tf2_msgs_INCLUDE_DIRS} | ||
| ${autoware_cuda_utils_INCLUDE_DIRS} | ||
| ) | ||
|
|
||
| if(USE_AGNOCAST) | ||
| target_include_directories(cuda_ground_segmentation_lib SYSTEM PRIVATE | ||
| ${autoware_agnocast_wrapper_INCLUDE_DIRS} | ||
| ${agnocastlib_INCLUDE_DIRS} | ||
| ) | ||
| target_link_libraries(cuda_ground_segmentation_lib | ||
| ${agnocastlib_LIBRARIES} | ||
| ) | ||
| endif() | ||
|
|
||
|
|
||
| # Targets | ||
| ament_auto_add_library(cuda_ground_segmentation SHARED | ||
| src/cuda_scan_ground_segmentation/cuda_scan_ground_segmentation_filter_node.cpp | ||
| ) | ||
|
|
||
| target_link_libraries(cuda_ground_segmentation | ||
| ${CUDA_LIBRARIES} | ||
| ${diagnostic_msgs_LIBRARIES} | ||
| cuda_ground_segmentation_lib | ||
| ) | ||
|
|
||
| #=========== ScanGround Segmentation filter ======== | ||
| rclcpp_components_register_node(cuda_ground_segmentation | ||
| PLUGIN "autoware::cuda_ground_segmentation::CudaScanGroundSegmentationFilterNode" | ||
| EXECUTABLE cuda_scan_ground_segmentation_filter_node) | ||
|
|
||
| ################################################################################ | ||
| # Install | ||
| install(DIRECTORY launch config | ||
| DESTINATION share/${PROJECT_NAME} | ||
| ) | ||
|
|
||
| install( | ||
| TARGETS cuda_ground_segmentation_lib | ||
| LIBRARY DESTINATION lib | ||
| ) | ||
|
|
||
| ament_auto_package() | ||
|
|
||
| # Set ROS_DISTRO macros | ||
| set(ROS_DISTRO $ENV{ROS_DISTRO}) | ||
| if(${ROS_DISTRO} STREQUAL "rolling") | ||
| add_compile_definitions(ROS_DISTRO_ROLLING) | ||
| elseif(${ROS_DISTRO} STREQUAL "foxy") | ||
| add_compile_definitions(ROS_DISTRO_FOXY) | ||
| elseif(${ROS_DISTRO} STREQUAL "galactic") | ||
| add_compile_definitions(ROS_DISTRO_GALACTIC) | ||
| elseif(${ROS_DISTRO} STREQUAL "humble") | ||
| add_compile_definitions(ROS_DISTRO_HUMBLE) | ||
| endif() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| # autoware_ground_segmentation_cuda | ||
|
|
||
| ## Purpose | ||
|
|
||
| The `autoware_ground_segmentation` algorithms have been thoroughly tested with Autoware. However, due to latency and high computational cost when processing large pointcloud, the input pointcloud range has been limited by the `crop_box_filter` based on the ego-vehicle's `base_link`. This can cause unwanted object loss, especially before a sloped road. | ||
|
|
||
|  | ||
|
|
||
| Recently, GPU and CUDA-supported libraries such as [cuda_blackboard](https://github.com/autowarefoundation/cuda_blackboard/blob/1837689df2891f6223f07c178c21aed252566ede/README.md) and accelerated versions of [`autoware_pointcloud_preprocessor`](../../sensing/autoware_cuda_pointcloud_preprocessor/README.md) have been implemented. These can be leveraged to improve the performance of ground segmentation filter algorithms using CUDA/GPU. | ||
|
|
||
| This package reimplements the current scan_ground_filter of the ground_segmentation package to reduce latency and avoid the bottleneck caused by processing a large number of point clouds. | ||
|
|
||
| ## Inner-workings / Algorithm | ||
|
|
||
| The detailed algorithm is available in [scan-ground-filter.md](../autoware_ground_segmentation/docs/scan-ground-filter.md). | ||
|
|
||
| ## Parameters | ||
|
|
||
| {{ json_to_markdown("perception/autoware_ground_segmentation_cuda/schema/cuda_scan_ground_segmentation_filter.schema.json") }} |
19 changes: 19 additions & 0 deletions
19
.../autoware_ground_segmentation_cuda/config/cuda_scan_ground_segmentation_filter.param.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| /**: | ||
| ros__parameters: | ||
| global_slope_max_angle_deg: 10.0 | ||
| local_slope_max_angle_deg: 25.0 | ||
| non_ground_height_threshold: 0.20 | ||
| grid_size_m: 0.5 | ||
| detection_range_z_max: 3.2 | ||
| use_recheck_ground_cluster: true | ||
| recheck_start_distance: 20.0 | ||
| use_lowest_point: true | ||
| center_pcl_shift: 0.0 | ||
| sector_angle_deg: 1.0 | ||
| gnd_cell_buffer_size: 5 | ||
| min_x: -100.0 | ||
| max_x: 150.0 | ||
| min_y: -70.0 | ||
| max_y: 70.0 | ||
| max_z: 2.5 | ||
| min_z: -2.5 |
Binary file added
BIN
+84.7 KB
...tion/autoware_ground_segmentation_cuda/docs/image/ground_segmentation_issue.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 38 additions & 0 deletions
38
...e_ground_segmentation_cuda/include/autoware/cuda_scan_ground_segmentation/cuda_common.hpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| // Copyright 2025 TIER IV, Inc. | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| #ifndef AUTOWARE__CUDA_SCAN_GROUND_SEGMENTATION__CUDA_COMMON_HPP_ | ||
| #define AUTOWARE__CUDA_SCAN_GROUND_SEGMENTATION__CUDA_COMMON_HPP_ | ||
|
|
||
| #include <autoware/cuda_utils/cuda_check_error.hpp> | ||
|
|
||
| #include <cuda_runtime.h> | ||
|
|
||
| #ifndef CUDAH | ||
| #define CUDAH __forceinline__ __host__ __device__ | ||
| #endif | ||
|
|
||
| #ifndef BLOCK_SIZE_X | ||
| #define BLOCK_SIZE_X (256) | ||
| #endif | ||
|
|
||
| #ifndef WARP_SIZE | ||
| #define WARP_SIZE (32) | ||
| #endif | ||
|
|
||
| #ifndef FULL_MASK | ||
| #define FULL_MASK (0xFFFFFFFF) | ||
| #endif | ||
|
|
||
| #endif // AUTOWARE__CUDA_SCAN_GROUND_SEGMENTATION__CUDA_COMMON_HPP_ |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question:
I am not an engineering expert in CUDA coding, but I am curious about why you need to define this
CUDAHname?This name is not a good name, and it is only defined in the new codes, where we can probably find a better name for it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Owen-Liuyuxuan Sorry for my late response. CUDAH is defined in the cuda_common.hpp
It is used for declaring some class methods that can be called from both CPU and GPU code. I just do not want to re-type that long qualifier a lot. However, the spell checker keeps reporting that macro so I had to add it to the word list.
I don't like that name, either. Can you suggest a better one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@anhnv3991
I think AI is good at naming variables. I think CUDA_HD/HOST_DEV/BOTH are good names. Please select the one you like.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Owen-Liuyuxuan Thanks. That CUDA_HOSTDEV sounds good. I'll take it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you refactor the code according to the agreement here?