Skip to content

Commit

Permalink
refactor(lidar_centerpoint)!: fix namespace and directory structure (#…
Browse files Browse the repository at this point in the history
…8049)

* add prefix in lidar_centerpoint

Signed-off-by: MasatoSaeki <masato.saeki@tier4.jp>

* add .gitignore

Signed-off-by: MasatoSaeki <masato.saeki@tier4.jp>

* change include package name in image_projection_based fusion

Signed-off-by: MasatoSaeki <masato.saeki@tier4.jp>

* fix

Signed-off-by: MasatoSaeki <masato.saeki@tier4.jp>

* change in codeowner

Signed-off-by: MasatoSaeki <masato.saeki@tier4.jp>

* delete package

Signed-off-by: MasatoSaeki <masato.saeki@tier4.jp>

* style(pre-commit): autofix

* style(pre-commit): autofix

* solve conflict too

Signed-off-by: MasatoSaeki <masato.saeki@tier4.jp>

* fix include file

Signed-off-by: MasatoSaeki <masato.saeki@tier4.jp>

* fix typo in launch file

Signed-off-by: MasatoSaeki <masato.saeki@tier4.jp>

* add prefix in README

Signed-off-by: MasatoSaeki <masato.saeki@tier4.jp>

* fix bugs by conflict

Signed-off-by: MasatoSaeki <masato.saeki@tier4.jp>

* style(pre-commit): autofix

* change namespace from  to

Signed-off-by: MasatoSaeki <masato.saeki@tier4.jp>

* style(pre-commit): autofix

---------

Signed-off-by: MasatoSaeki <masato.saeki@tier4.jp>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Kenzo Lobos Tsunekawa <kenzo.lobos@tier4.jp>
  • Loading branch information
3 people authored Jul 23, 2024
1 parent a595b36 commit fec9d42
Show file tree
Hide file tree
Showing 65 changed files with 293 additions and 280 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ perception/image_projection_based_fusion/** dai.nguyen@tier4.jp koji.minoda@tier
perception/lidar_apollo_instance_segmentation/** yoshi.ri@tier4.jp yukihiro.saito@tier4.jp
perception/lidar_apollo_segmentation_tvm/** ambroise.vincent@arm.com yoshi.ri@tier4.jp
perception/lidar_apollo_segmentation_tvm_nodes/** ambroise.vincent@arm.com yoshi.ri@tier4.jp
perception/lidar_centerpoint/** kenzo.lobos@tier4.jp koji.minoda@tier4.jp
perception/autoware_lidar_centerpoint/** kenzo.lobos@tier4.jp koji.minoda@tier4.jp
perception/occupancy_grid_map_outlier_filter/** abrahammonrroy@yahoo.com yoshi.ri@tier4.jp yukihiro.saito@tier4.jp
perception/probabilistic_occupancy_grid_map/** mamoru.sobue@tier4.jp yoshi.ri@tier4.jp yukihiro.saito@tier4.jp
perception/radar_tracks_msgs_converter/** satoshi.tanaka@tier4.jp shunsuke.miura@tier4.jp taekjin.lee@tier4.jp yoshi.ri@tier4.jp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@
<!-- CenterPoint -->
<group if="$(eval &quot;'$(var lidar_detection_model)'=='centerpoint'&quot;)">
<push-ros-namespace namespace="centerpoint"/>
<arg name="lidar_model_param_path" default="$(find-pkg-share lidar_centerpoint)/config"/>
<arg name="lidar_model_param_path" default="$(find-pkg-share autoware_lidar_centerpoint)/config"/>

<group>
<include file="$(find-pkg-share lidar_centerpoint)/launch/lidar_centerpoint.launch.xml">
<include file="$(find-pkg-share autoware_lidar_centerpoint)/launch/lidar_centerpoint.launch.xml">
<arg name="input/pointcloud" value="$(var input/pointcloud)"/>
<arg name="output/objects" value="$(var output/objects)"/>
<arg name="model_name" value="$(var centerpoint_model_name)"/>
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
cmake_minimum_required(VERSION 3.14)
project(lidar_centerpoint)
project(autoware_lidar_centerpoint)

find_package(autoware_cmake REQUIRED)
autoware_package()

# TODO(lidar_centerpoint): Remove once upgrading to TensorRT 8.5 is complete
# TODO(autoware_lidar_centerpoint): Remove once upgrading to TensorRT 8.5 is complete
add_compile_options(-Wno-deprecated-declarations)

option(CUDA_VERBOSE "Verbose output of CUDA modules" OFF)
Expand Down Expand Up @@ -79,7 +79,7 @@ if(TRT_AVAIL AND CUDA_AVAIL AND CUDNN_AVAIL)
)

### centerpoint ###
ament_auto_add_library(centerpoint_lib SHARED
ament_auto_add_library(${PROJECT_NAME}_lib SHARED
lib/centerpoint_trt.cpp
lib/detection_class_remapper.cpp
lib/utils.cpp
Expand All @@ -91,48 +91,48 @@ if(TRT_AVAIL AND CUDA_AVAIL AND CUDNN_AVAIL)
lib/preprocess/voxel_generator.cpp
)

cuda_add_library(centerpoint_cuda_lib SHARED
cuda_add_library(${PROJECT_NAME}_cuda_lib SHARED
lib/postprocess/circle_nms_kernel.cu
lib/postprocess/postprocess_kernel.cu
lib/network/scatter_kernel.cu
lib/preprocess/preprocess_kernel.cu
)

target_link_libraries(centerpoint_lib
target_link_libraries(${PROJECT_NAME}_lib
${NVINFER}
${NVONNXPARSER}
${CUDA_LIBRARIES}
${CUBLAS_LIBRARIES}
${CUDA_curand_LIBRARY}
${CUDNN_LIBRARY}
centerpoint_cuda_lib
${PROJECT_NAME}_cuda_lib
)

target_include_directories(centerpoint_lib
target_include_directories(${PROJECT_NAME}_lib
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)

# To suppress unknown-pragmas error. The root-cause is CUB library in CUDA 11.6.
# This issue was fixed by https://github.com/NVIDIA/cub/commit/7d608bf1dc14553e2fb219eabeed80b76621b6fe
target_include_directories(centerpoint_lib
target_include_directories(${PROJECT_NAME}_lib
SYSTEM PUBLIC
${CUDA_INCLUDE_DIRS}
)

## node ##
ament_auto_add_library(lidar_centerpoint_component SHARED
ament_auto_add_library(${PROJECT_NAME}_component SHARED
src/node.cpp
)

target_link_libraries(lidar_centerpoint_component
centerpoint_lib
target_link_libraries(${PROJECT_NAME}_component
${PROJECT_NAME}_lib
)

rclcpp_components_register_node(lidar_centerpoint_component
PLUGIN "centerpoint::LidarCenterPointNode"
EXECUTABLE lidar_centerpoint_node
rclcpp_components_register_node(${PROJECT_NAME}_component
PLUGIN "autoware::lidar_centerpoint::LidarCenterPointNode"
EXECUTABLE ${PROJECT_NAME}_node
)

ament_export_dependencies(ament_cmake_python)
Expand All @@ -144,7 +144,7 @@ if(TRT_AVAIL AND CUDA_AVAIL AND CUDNN_AVAIL)
)

install(
TARGETS centerpoint_cuda_lib
TARGETS ${PROJECT_NAME}_cuda_lib
DESTINATION lib
)

Expand Down Expand Up @@ -176,7 +176,7 @@ if(TRT_AVAIL AND CUDA_AVAIL AND CUDNN_AVAIL)
# )
#
# target_link_libraries(test_preprocess_kernel
# centerpoint_cuda_lib
# ${PROJECT_NAME}_cuda_lib
# gtest
# gtest_main
# )
Expand All @@ -196,7 +196,7 @@ if(TRT_AVAIL AND CUDA_AVAIL AND CUDNN_AVAIL)
# )
#
# target_link_libraries(test_postprocess_kernel
# centerpoint_cuda_lib
# ${PROJECT_NAME}_cuda_lib
# gtest
# gtest_main
# )
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# lidar_centerpoint
# autoware_lidar_centerpoint

## Purpose

lidar_centerpoint is a package for detecting dynamic 3D objects.
autoware_lidar_centerpoint is a package for detecting dynamic 3D objects.

## Inner-workings / Algorithms

Expand Down Expand Up @@ -49,11 +49,11 @@ We trained the models using <https://github.com/open-mmlab/mmdetection3d>.

### The `build_only` option

The `lidar_centerpoint` node has `build_only` option to build the TensorRT engine file from the ONNX file.
The `autoware_lidar_centerpoint` node has `build_only` option to build the TensorRT engine file from the ONNX file.
Although it is preferred to move all the ROS parameters in `.param.yaml` file in Autoware Universe, the `build_only` option is not moved to the `.param.yaml` file for now, because it may be used as a flag to execute the build as a pre-task. You can execute with the following command:

```bash
ros2 launch lidar_centerpoint lidar_centerpoint.launch.xml model_name:=centerpoint_tiny model_path:=/home/autoware/autoware_data/lidar_centerpoint model_param_path:=$(ros2 pkg prefix lidar_centerpoint --share)/config/centerpoint_tiny.param.yaml build_only:=true
ros2 launch autoware_lidar_centerpoint lidar_centerpoint.launch.xml model_name:=centerpoint_tiny model_path:=/home/autoware/autoware_data/lidar_centerpoint model_param_path:=$(ros2 pkg prefix autoware_lidar_centerpoint --share)/config/centerpoint_tiny.param.yaml build_only:=true
```

## Assumptions / Known limits
Expand Down Expand Up @@ -225,7 +225,7 @@ the base link location of the vehicle.

#### Convert CenterPoint PyTorch model to ONNX Format

The lidar_centerpoint implementation requires two ONNX models as input the voxel encoder and the backbone-neck-head of the CenterPoint model, other aspects of the network,
The autoware_lidar_centerpoint implementation requires two ONNX models as input the voxel encoder and the backbone-neck-head of the CenterPoint model, other aspects of the network,
such as preprocessing operations, are implemented externally. Under the fork of the mmdetection3d repository,
we have included a script that converts the CenterPoint model to Autoware compatible ONNX format.
You can find it in `mmdetection3d/projects/AutowareCenterPoint` file.
Expand All @@ -236,7 +236,7 @@ python projects/AutowareCenterPoint/centerpoint_onnx_converter.py --cfg projects

#### Create the config file for the custom model

Create a new config file named **centerpoint_custom.param.yaml** under the config file directory of the lidar_centerpoint node. Sets the parameters of the config file like
Create a new config file named **centerpoint_custom.param.yaml** under the config file directory of the autoware_lidar_centerpoint node. Sets the parameters of the config file like
point_cloud_range, point_feature_size, voxel_size, etc. according to the training config file.

```yaml
Expand All @@ -262,7 +262,7 @@ point_cloud_range, point_feature_size, voxel_size, etc. according to the trainin
```bash
cd /YOUR/AUTOWARE/PATH/Autoware
source install/setup.bash
ros2 launch lidar_centerpoint lidar_centerpoint.launch.xml model_name:=centerpoint_custom model_path:=/PATH/TO/ONNX/FILE/
ros2 launch autoware_lidar_centerpoint lidar_centerpoint.launch.xml model_name:=centerpoint_custom model_path:=/PATH/TO/ONNX/FILE/
```

### Changelog
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef LIDAR_CENTERPOINT__CENTERPOINT_CONFIG_HPP_
#define LIDAR_CENTERPOINT__CENTERPOINT_CONFIG_HPP_
#ifndef AUTOWARE__LIDAR_CENTERPOINT__CENTERPOINT_CONFIG_HPP_
#define AUTOWARE__LIDAR_CENTERPOINT__CENTERPOINT_CONFIG_HPP_

#include <cstddef>
#include <vector>

namespace centerpoint
namespace autoware::lidar_centerpoint
{
class CenterPointConfig
{
Expand Down Expand Up @@ -132,6 +132,6 @@ class CenterPointConfig
std::size_t down_grid_size_y_ = grid_size_y_ / downsample_factor_;
};

} // namespace centerpoint
} // namespace autoware::lidar_centerpoint

#endif // LIDAR_CENTERPOINT__CENTERPOINT_CONFIG_HPP_
#endif // AUTOWARE__LIDAR_CENTERPOINT__CENTERPOINT_CONFIG_HPP_
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef LIDAR_CENTERPOINT__CENTERPOINT_TRT_HPP_
#define LIDAR_CENTERPOINT__CENTERPOINT_TRT_HPP_
#ifndef AUTOWARE__LIDAR_CENTERPOINT__CENTERPOINT_TRT_HPP_
#define AUTOWARE__LIDAR_CENTERPOINT__CENTERPOINT_TRT_HPP_

#include "lidar_centerpoint/cuda_utils.hpp"
#include "lidar_centerpoint/network/network_trt.hpp"
#include "lidar_centerpoint/postprocess/postprocess_kernel.hpp"
#include "lidar_centerpoint/preprocess/voxel_generator.hpp"
#include "autoware/lidar_centerpoint/cuda_utils.hpp"
#include "autoware/lidar_centerpoint/network/network_trt.hpp"
#include "autoware/lidar_centerpoint/postprocess/postprocess_kernel.hpp"
#include "autoware/lidar_centerpoint/preprocess/voxel_generator.hpp"
#include "pcl/point_cloud.h"
#include "pcl/point_types.h"

Expand All @@ -29,7 +29,7 @@
#include <utility>
#include <vector>

namespace centerpoint
namespace autoware::lidar_centerpoint
{
class NetworkParam
{
Expand Down Expand Up @@ -107,6 +107,6 @@ class CenterPointTRT
cuda::unique_ptr<unsigned int[]> num_voxels_d_{nullptr};
};

} // namespace centerpoint
} // namespace autoware::lidar_centerpoint

#endif // LIDAR_CENTERPOINT__CENTERPOINT_TRT_HPP_
#endif // AUTOWARE__LIDAR_CENTERPOINT__CENTERPOINT_TRT_HPP_
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
* https://creativecommons.org/publicdomain/zero/1.0/deed.en
*/

#ifndef LIDAR_CENTERPOINT__CUDA_UTILS_HPP_
#define LIDAR_CENTERPOINT__CUDA_UTILS_HPP_
#ifndef AUTOWARE__LIDAR_CENTERPOINT__CUDA_UTILS_HPP_
#define AUTOWARE__LIDAR_CENTERPOINT__CUDA_UTILS_HPP_

#include "cuda_runtime_api.h"

Expand Down Expand Up @@ -117,4 +117,4 @@ inline T * get_next_ptr(size_t num_elem, void *& workspace, size_t & workspace_s

} // namespace cuda

#endif // LIDAR_CENTERPOINT__CUDA_UTILS_HPP_
#endif // AUTOWARE__LIDAR_CENTERPOINT__CUDA_UTILS_HPP_
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef LIDAR_CENTERPOINT__DETECTION_CLASS_REMAPPER_HPP_
#define LIDAR_CENTERPOINT__DETECTION_CLASS_REMAPPER_HPP_
#ifndef AUTOWARE__LIDAR_CENTERPOINT__DETECTION_CLASS_REMAPPER_HPP_
#define AUTOWARE__LIDAR_CENTERPOINT__DETECTION_CLASS_REMAPPER_HPP_

#include <Eigen/Core>

Expand All @@ -24,7 +24,7 @@

#include <vector>

namespace centerpoint
namespace autoware::lidar_centerpoint
{

class DetectionClassRemapper
Expand All @@ -42,6 +42,6 @@ class DetectionClassRemapper
int num_labels_;
};

} // namespace centerpoint
} // namespace autoware::lidar_centerpoint

#endif // LIDAR_CENTERPOINT__DETECTION_CLASS_REMAPPER_HPP_
#endif // AUTOWARE__LIDAR_CENTERPOINT__DETECTION_CLASS_REMAPPER_HPP_
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef LIDAR_CENTERPOINT__NETWORK__NETWORK_TRT_HPP_
#define LIDAR_CENTERPOINT__NETWORK__NETWORK_TRT_HPP_
#ifndef AUTOWARE__LIDAR_CENTERPOINT__NETWORK__NETWORK_TRT_HPP_
#define AUTOWARE__LIDAR_CENTERPOINT__NETWORK__NETWORK_TRT_HPP_

#include "lidar_centerpoint/centerpoint_config.hpp"
#include "lidar_centerpoint/network/tensorrt_wrapper.hpp"
#include "autoware/lidar_centerpoint/centerpoint_config.hpp"
#include "autoware/lidar_centerpoint/network/tensorrt_wrapper.hpp"

#include <vector>

namespace centerpoint
namespace autoware::lidar_centerpoint
{
class VoxelEncoderTRT : public TensorRTWrapper
{
Expand Down Expand Up @@ -48,6 +48,6 @@ class HeadTRT : public TensorRTWrapper
std::vector<std::size_t> out_channel_sizes_;
};

} // namespace centerpoint
} // namespace autoware::lidar_centerpoint

#endif // LIDAR_CENTERPOINT__NETWORK__NETWORK_TRT_HPP_
#endif // AUTOWARE__LIDAR_CENTERPOINT__NETWORK__NETWORK_TRT_HPP_
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef LIDAR_CENTERPOINT__NETWORK__SCATTER_KERNEL_HPP_
#define LIDAR_CENTERPOINT__NETWORK__SCATTER_KERNEL_HPP_
#ifndef AUTOWARE__LIDAR_CENTERPOINT__NETWORK__SCATTER_KERNEL_HPP_
#define AUTOWARE__LIDAR_CENTERPOINT__NETWORK__SCATTER_KERNEL_HPP_

#include "cuda.h"
#include "cuda_runtime_api.h"

namespace centerpoint
namespace autoware::lidar_centerpoint
{
cudaError_t scatterFeatures_launch(
const float * pillar_features, const int * coords, const unsigned int * num_pillars,
const std::size_t max_voxel_size, const std::size_t encoder_out_feature_size,
const std::size_t grid_size_x, const std::size_t grid_size_y, float * scattered_features,
cudaStream_t stream);

} // namespace centerpoint
} // namespace autoware::lidar_centerpoint

#endif // LIDAR_CENTERPOINT__NETWORK__SCATTER_KERNEL_HPP_
#endif // AUTOWARE__LIDAR_CENTERPOINT__NETWORK__SCATTER_KERNEL_HPP_
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef LIDAR_CENTERPOINT__NETWORK__TENSORRT_WRAPPER_HPP_
#define LIDAR_CENTERPOINT__NETWORK__TENSORRT_WRAPPER_HPP_
#ifndef AUTOWARE__LIDAR_CENTERPOINT__NETWORK__TENSORRT_WRAPPER_HPP_
#define AUTOWARE__LIDAR_CENTERPOINT__NETWORK__TENSORRT_WRAPPER_HPP_

#include "NvInfer.h"
#include "lidar_centerpoint/centerpoint_config.hpp"
#include "autoware/lidar_centerpoint/centerpoint_config.hpp"
#include "tensorrt_common/tensorrt_common.hpp"

#include <iostream>
#include <memory>
#include <string>

namespace centerpoint
namespace autoware::lidar_centerpoint
{

class TensorRTWrapper
Expand Down Expand Up @@ -62,6 +62,6 @@ class TensorRTWrapper
tensorrt_common::TrtUniquePtr<nvinfer1::ICudaEngine> engine_{nullptr};
};

} // namespace centerpoint
} // namespace autoware::lidar_centerpoint

#endif // LIDAR_CENTERPOINT__NETWORK__TENSORRT_WRAPPER_HPP_
#endif // AUTOWARE__LIDAR_CENTERPOINT__NETWORK__TENSORRT_WRAPPER_HPP_
Loading

0 comments on commit fec9d42

Please sign in to comment.