Skip to content
Open
Show file tree
Hide file tree
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 Aug 24, 2025
c8c5c37
feat: add cuda_scan_ground_segmentation node
badai-nguyen Aug 24, 2025
f372be5
fix: launch
badai-nguyen Aug 24, 2025
818ea83
refactor
badai-nguyen Aug 25, 2025
81e1049
refactor
badai-nguyen Aug 25, 2025
c3d660e
fix: atan error
badai-nguyen Aug 25, 2025
2dd8863
fix: num output point host reference
badai-nguyen Aug 25, 2025
4675b21
pre-commit
badai-nguyen Aug 25, 2025
971ad57
feat: add ground pointcloud publish for debug
badai-nguyen Aug 25, 2025
f45d118
refactor
badai-nguyen Aug 25, 2025
ab957d2
refactor
badai-nguyen Aug 26, 2025
9ba6e10
refactor
badai-nguyen Aug 26, 2025
a9ad968
fix: param path
badai-nguyen Aug 26, 2025
63c9826
feat: add debug processing time
badai-nguyen Aug 26, 2025
3d334c0
delete pointcloud preprocesor ground segmentation
badai-nguyen Aug 26, 2025
d6b3730
typo
badai-nguyen Aug 27, 2025
0345f0e
refactoring
badai-nguyen Aug 27, 2025
69f429d
refactoring
badai-nguyen Aug 27, 2025
e6bd38d
fix: variable type
badai-nguyen Aug 27, 2025
ad4f6ca
refactoring
badai-nguyen Aug 27, 2025
a6820a0
typo
badai-nguyen Aug 27, 2025
b2b439d
style(pre-commit): autofix
pre-commit-ci-lite[bot] Aug 27, 2025
c0c6ebd
revert launch change
badai-nguyen Aug 28, 2025
f8ab1ff
docs
badai-nguyen Aug 28, 2025
946a005
style(pre-commit): autofix
pre-commit-ci-lite[bot] Aug 28, 2025
5019c6a
revise variable type
badai-nguyen Aug 28, 2025
ccd469b
fix: avoid very small d_radius
badai-nguyen Aug 28, 2025
1b3f0f3
docs: add README
badai-nguyen Sep 1, 2025
83cfd0f
style(pre-commit): autofix
pre-commit-ci-lite[bot] Sep 1, 2025
23c68a4
docs
badai-nguyen Sep 1, 2025
dd976e5
refactor
badai-nguyen Sep 1, 2025
f111fd6
style(pre-commit): autofix
pre-commit-ci-lite[bot] Sep 1, 2025
501fd9b
docs: add schema
badai-nguyen Sep 1, 2025
6d6d2ce
fix(recheck): classifiied local pointcloud index bug
badai-nguyen Sep 1, 2025
cb18f26
fix: launch
badai-nguyen Sep 2, 2025
be55174
remove vehicle info depend
badai-nguyen Sep 3, 2025
c6569e2
Adding GPU ground segmentation
Sep 9, 2025
da86925
Finished coding
Sep 10, 2025
633b9db
Fixed
Sep 15, 2025
914b2bd
Fixed
Sep 15, 2025
aea4778
Merge branch 'autowarefoundation:main' into feat/gpu_ground_seg
Sep 16, 2025
5408e9e
Fixed all. Debug code remains.
Sep 16, 2025
2634f92
Remove debug code.
Sep 16, 2025
fe34ef9
Merge branch 'autowarefoundation:main' into feat/gpu_ground_seg
Sep 16, 2025
bb0fe69
style(pre-commit): autofix
pre-commit-ci-lite[bot] Sep 16, 2025
c21e07e
Remove wrong code
Sep 17, 2025
07b099c
Merge branch 'main' into feat/gpu_ground_seg
Sep 17, 2025
5815d4b
Fixed pre-commit-lite
Sep 17, 2025
65bfa27
style(pre-commit): autofix
pre-commit-ci-lite[bot] Sep 17, 2025
728d229
Fixed pre-commit-lite
Sep 17, 2025
547e5cf
Fix typos
Sep 17, 2025
0e9d6c2
Ignore CUDAH spell check
Sep 17, 2025
9395032
Merge branch 'main' into feat/gpu_ground_seg
Sep 17, 2025
cb9727b
Add license info
Sep 17, 2025
a7ca91e
style(pre-commit): autofix
pre-commit-ci-lite[bot] Sep 17, 2025
fad43b5
Merge branch 'autowarefoundation:main' into feat/gpu_ground_seg
anhnv3991 Sep 21, 2025
7827ffe
Replace sensor_msgs PointCloud2 by cuda_blackboard PointCloud2
Sep 22, 2025
5e74ea9
Merge branch 'autowarefoundation:main' into feat/gpu_ground_seg
anhnv3991 Sep 22, 2025
49b0dd5
style(pre-commit): autofix
pre-commit-ci-lite[bot] Sep 22, 2025
d61b580
Use cuda_blackboard pointcloud 2
Sep 25, 2025
9947dec
Merge branch 'main' into feat/gpu_ground_seg
Sep 25, 2025
6bf6865
style(pre-commit): autofix
pre-commit-ci-lite[bot] Sep 25, 2025
e143391
Merge branch 'main' into feat/gpu_ground_seg
Oct 1, 2025
35c6835
add launch option
badai-nguyen Oct 16, 2025
f39b91b
style(pre-commit): autofix
pre-commit-ci-lite[bot] Oct 20, 2025
8246bc9
replace radius_max by xzy max min
badai-nguyen Oct 20, 2025
9d4be4f
style(pre-commit): autofix
pre-commit-ci-lite[bot] Oct 24, 2025
d823019
Remove point number limit of each thread
Oct 29, 2025
4942b90
Merge branch 'autowarefoundation:main' into feat/gpu_ground_seg
anhnv3991 Oct 29, 2025
ed734dc
style(pre-commit): autofix
pre-commit-ci-lite[bot] Oct 29, 2025
f6b0582
Fixed build error
Oct 29, 2025
b7e5446
fix: input topics
badai-nguyen Oct 30, 2025
35fbfa2
fix schema check
badai-nguyen Oct 30, 2025
89aa7c0
style(pre-commit): autofix
pre-commit-ci-lite[bot] Oct 30, 2025
2da6096
docs: update readme
badai-nguyen Oct 30, 2025
c951004
refactor: remove unused param
badai-nguyen Oct 30, 2025
9dfd826
typo
badai-nguyen Oct 30, 2025
b3561cb
fix: center shift
badai-nguyen Oct 31, 2025
853ff57
Fixed errors
Nov 1, 2025
07c0fa1
style(pre-commit): autofix
pre-commit-ci-lite[bot] Nov 1, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
"planning/behavior_velocity_planner/autoware_behavior_velocity_intersection_module/scripts/**"
],
"ignoreRegExpList": [],
"words": ["dltype", "tvmgen", "fromarray", "soblin", "brkay54", "libtensorrt", "TRTBEV"]
"words": ["dltype", "tvmgen", "fromarray", "soblin", "brkay54", "libtensorrt", "TRTBEV", "CUDAH"]
Copy link
Contributor

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 CUDAH name?

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.

Copy link
Author

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

#ifndef CUDAH
#define CUDAH __forceinline__ __host__ __device__
#endif 

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?

Copy link
Contributor

Choose a reason for hiding this comment

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

@anhnv3991

image

I think AI is good at naming variables. I think CUDA_HD/HOST_DEV/BOTH are good names. Please select the one you like.

Copy link
Author

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.

Copy link
Contributor

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?

}
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@
context
)
self.use_time_series_filter = LaunchConfiguration("use_time_series_filter").perform(context)
self.use_cuda_ground_segmentation = (
LaunchConfiguration("use_cuda_ground_segmentation").perform(context).lower() == "true"
)
# check if self.use_single_frame_filter is bool
if isinstance(self.use_single_frame_filter, str):
self.use_single_frame_filter = self.use_single_frame_filter.lower() == "true"
Expand Down Expand Up @@ -176,7 +179,7 @@
name="short_height_obstacle_detection_area_filter",
namespace="plane_fitting",
remappings=[
("input", "concatenated/pointcloud"),
("input", "concat/pointcloud"),
("output", "detection_area/pointcloud"),
],
parameters=[
Expand Down Expand Up @@ -535,6 +538,46 @@
pipeline = GroundSegmentationPipeline(context)

components = []
if pipeline.use_cuda_ground_segmentation:
ground_segmentation_node_param = ParameterFile(
param_file=LaunchConfiguration("cuda_ground_segmentation_node_param_path").perform(
context
),
allow_substs=True,
)
components.append(
ComposableNode(
package="autoware_ground_segmentation_cuda",
plugin="autoware::cuda_ground_segmentation::CudaScanGroundSegmentationFilterNode",
name="cuda_scan_ground_segmentation_filter",
remappings=[
("~/input/pointcloud", "/sensing/lidar/concatenated/pointcloud"),
("~/input/pointcloud/cuda", "/sensing/lidar/concatenated/pointcloud/cuda"),
("~/output/pointcloud", "/perception/obstacle_segmentation/pointcloud"),
(
"~/output/pointcloud/cuda",
"/perception/obstacle_segmentation/pointcloud/cuda",
),
(
"~/output/ground_pointcloud",
"/perception/obstacle_segmentation/ground_pointcloud",
),
(
"~/output/ground_pointcloud/cuda",
"/perception/obstacle_segmentation/ground_pointcloud/cuda",
),
],
parameters=[ground_segmentation_node_param],
extra_arguments=[],
)
)
return [
LoadComposableNodes(
composable_node_descriptions=components,
target_container=LaunchConfiguration("pointcloud_container_name"),
)
]

Check warning on line 580 in launch/tier4_perception_launch/launch/obstacle_segmentation/ground_segmentation/ground_segmentation.launch.py

View check run for this annotation

CodeScene Delta Analysis / CodeScene Code Health Review (main)

❌ New issue: Large Method

launch_setup has 87 lines, threshold = 70. Large functions with many lines of code are generally harder to understand and lower the code health. Avoid adding more lines to this function.
components.extend(
pipeline.create_single_frame_obstacle_segmentation_components(
input_topic=LaunchConfiguration("input/pointcloud"),
Expand Down Expand Up @@ -594,13 +637,21 @@
add_launch_arg("use_intra_process", "True")
add_launch_arg("pointcloud_container_name", "pointcloud_container")
add_launch_arg("input/pointcloud", "/sensing/lidar/concatenated/pointcloud")
add_launch_arg("use_cuda_ground_segmentation", "False")
add_launch_arg(
"ogm_outlier_filter_param_path",
[
FindPackageShare("autoware_launch"),
"/config/perception/obstacle_segmentation/occupancy_grid_based_outlier_filter/occupancy_grid_map_outlier_filter.param.yaml",
],
)
add_launch_arg(
"cuda_ground_segmentation_node_param_path",
[
FindPackageShare("autoware_ground_segmentation_cuda"),
"/config/cuda_scan_ground_segmentation_filter.param.yaml",
],
)

set_container_executable = SetLaunchConfiguration(
"container_executable",
Expand Down
2 changes: 2 additions & 0 deletions launch/tier4_perception_launch/launch/perception.launch.xml
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@
<arg name="use_perception_analytics_publisher" default="true" description="use perception analytics publisher"/>
<arg name="use_obstacle_segmentation_single_frame_filter" description="use single frame filter at the ground segmentation"/>
<arg name="use_obstacle_segmentation_time_series_filter" description="use time series filter at the ground segmentation"/>
<arg name="use_cuda_ground_segmentation" default="false" description="use cuda ground segmentation filter at the ground segmentation"/>

<!-- traffic light recognition options to switch launch function/module -->
<arg name="use_traffic_light_recognition"/>
Expand Down Expand Up @@ -225,6 +226,7 @@
<arg name="obstacle_segmentation_ground_segmentation_param_path" value="$(var obstacle_segmentation_ground_segmentation_param_path)"/>
<arg name="use_single_frame_filter" value="$(var use_obstacle_segmentation_single_frame_filter)"/>
<arg name="use_time_series_filter" value="$(var use_obstacle_segmentation_time_series_filter)"/>
<arg name="use_cuda_ground_segmentation" value="$(var use_cuda_ground_segmentation)"/>
</include>
</group>

Expand Down
131 changes: 131 additions & 0 deletions perception/autoware_ground_segmentation_cuda/CMakeLists.txt
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()
19 changes: 19 additions & 0 deletions perception/autoware_ground_segmentation_cuda/README.md
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.

![ground_segmentation_pipeline issue](./docs/image/ground_segmentation_issue.png)

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") }}
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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_
Loading
Loading