Skip to content

Commit 5fe824e

Browse files
committed
fix: fixed rounding errors that caused illegal memory address
Signed-off-by: Kenzo Lobos-Tsunekawa <kenzo.lobos@tier4.jp>
1 parent 1586372 commit 5fe824e

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

perception/autoware_lidar_centerpoint/lib/preprocess/preprocess_kernel.cu

+2
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,8 @@ __global__ void generateVoxels_random_kernel(
148148

149149
int voxel_idx = floorf((point.x - min_x_range) / pillar_x_size);
150150
int voxel_idy = floorf((point.y - min_y_range) / pillar_y_size);
151+
voxel_idx = voxel_idx < 0 ? 0 : voxel_idx >= grid_x_size ? grid_x_size - 1 : voxel_idx;
152+
voxel_idy = voxel_idy < 0 ? 0 : voxel_idy >= grid_y_size ? grid_y_size - 1 : voxel_idy;
151153
unsigned int voxel_index = (grid_x_size - 1 - voxel_idx) * grid_y_size + voxel_idy;
152154

153155
unsigned int point_id = atomicAdd(&(mask[voxel_index]), 1);

0 commit comments

Comments
 (0)