From 675ea0b5e4300e01db9491f664539432c94a3301 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Thu, 18 Jan 2024 21:33:20 -0500 Subject: [PATCH] allow use as component or node (#858) Backport #852 to Iron --- depth_image_proc/CMakeLists.txt | 51 +++++++++++++++++++++++++------- image_proc/CMakeLists.txt | 40 +++++++++++++++---------- stereo_image_proc/CMakeLists.txt | 1 + 3 files changed, 66 insertions(+), 26 deletions(-) diff --git a/depth_image_proc/CMakeLists.txt b/depth_image_proc/CMakeLists.txt index 97501d322..1a0dc88e1 100644 --- a/depth_image_proc/CMakeLists.txt +++ b/depth_image_proc/CMakeLists.txt @@ -36,17 +36,46 @@ ament_auto_add_library(${PROJECT_NAME} SHARED src/register.cpp ) -rclcpp_components_register_nodes(${PROJECT_NAME} - "${PROJECT_NAME}::ConvertMetricNode" - "${PROJECT_NAME}::CropForemostNode" - "${PROJECT_NAME}::DisparityNode" - "${PROJECT_NAME}::PointCloudXyzNode" - "${PROJECT_NAME}::PointCloudXyzRadialNode" - "${PROJECT_NAME}::PointCloudXyziNode" - "${PROJECT_NAME}::PointCloudXyziRadialNode" - "${PROJECT_NAME}::PointCloudXyzrgbNode" - "${PROJECT_NAME}::PointCloudXyzrgbRadialNode" - "${PROJECT_NAME}::RegisterNode" +# Register individual components and also build standalone nodes for each +rclcpp_components_register_node(${PROJECT_NAME} + PLUGIN "depth_image_proc::ConvertMetricNode" + EXECUTABLE convert_metric_node +) +rclcpp_components_register_node(${PROJECT_NAME} + PLUGIN "depth_image_proc::CropForemostNode" + EXECUTABLE crop_foremost_node +) +rclcpp_components_register_node(${PROJECT_NAME} + PLUGIN "depth_image_proc::DisparityNode" + EXECUTABLE disparity_node +) +rclcpp_components_register_node(${PROJECT_NAME} + PLUGIN "depth_image_proc::PointCloudXyzNode" + EXECUTABLE point_cloud_xyz_node +) +rclcpp_components_register_node(${PROJECT_NAME} + PLUGIN "depth_image_proc::PointCloudXyzrgbNode" + EXECUTABLE point_cloud_xyzrgb_node +) +rclcpp_components_register_node(${PROJECT_NAME} + PLUGIN "depth_image_proc::PointCloudXyziNode" + EXECUTABLE point_cloud_xyzi_node +) +rclcpp_components_register_node(${PROJECT_NAME} + PLUGIN "depth_image_proc::PointCloudXyzRadialNode" + EXECUTABLE point_cloud_xyz_radial_node +) +rclcpp_components_register_node(${PROJECT_NAME} + PLUGIN "depth_image_proc::PointCloudXyziRadialNode" + EXECUTABLE point_cloud_xyzi_radial_node +) +rclcpp_components_register_node(${PROJECT_NAME} + PLUGIN "depth_image_proc::PointCloudXyziRadialNode" + EXECUTABLE point_cloud_xyzrgb_radial_node +) +rclcpp_components_register_node(${PROJECT_NAME} + PLUGIN "depth_image_proc::RegisterNode" + EXECUTABLE register_node ) target_link_libraries(${PROJECT_NAME} ${OpenCV_LIBRARIES}) diff --git a/image_proc/CMakeLists.txt b/image_proc/CMakeLists.txt index 4570eb74d..c11a7d071 100644 --- a/image_proc/CMakeLists.txt +++ b/image_proc/CMakeLists.txt @@ -26,16 +26,18 @@ target_link_libraries(${PROJECT_NAME} ${OpenCV_LIBRARIES} ) -# rectify library +# rectify component and node ament_auto_add_library(rectify SHARED src/rectify.cpp) target_compile_definitions(rectify PRIVATE "COMPOSITION_BUILDING_DLL" ) -rclcpp_components_register_nodes(rectify "image_proc::RectifyNode") -set(node_plugins "${node_plugins}image_proc::RectifyNode;$\n") +rclcpp_components_register_node(rectify + PLUGIN "image_proc::RectifyNode" + EXECUTABLE rectify_node +) -# debayer library +# debayer component and node ament_auto_add_library(debayer SHARED src/debayer.cpp src/edge_aware.cpp @@ -43,38 +45,46 @@ ament_auto_add_library(debayer SHARED target_compile_definitions(debayer PRIVATE "COMPOSITION_BUILDING_DLL" ) -rclcpp_components_register_nodes(debayer "image_proc::DebayerNode") -set(node_plugins "${node_plugins}image_proc::DebayerNode;$\n") +rclcpp_components_register_node(debayer + PLUGIN "image_proc::DebayerNode" + EXECUTABLE debayer_node +) -# resize library +# resize component and node ament_auto_add_library(resize SHARED src/resize.cpp ) target_compile_definitions(resize PRIVATE "COMPOSITION_BUILDING_DLL" ) -rclcpp_components_register_nodes(resize "image_proc::ResizeNode") -set(node_plugins "${node_plugins}image_proc::ResizeNode;$\n") +rclcpp_components_register_node(resize + PLUGIN "image_proc::ResizeNode" + EXECUTABLE resize_node +) -# crop_decimate library +# crop_decimate component and node ament_auto_add_library(crop_decimate SHARED src/crop_decimate.cpp ) target_compile_definitions(crop_decimate PRIVATE "COMPOSITION_BUILDING_DLL" ) -rclcpp_components_register_nodes(crop_decimate "image_proc::CropDecimateNode") -set(node_plugins "${node_plugins}image_proc::CropDecimateNode;$\n") +rclcpp_components_register_node(crop_decimate + PLUGIN "image_proc::CropDecimateNode" + EXECUTABLE crop_decimate_node +) -# crop_non_zero library +# crop_non_zero component and node ament_auto_add_library(crop_non_zero SHARED src/crop_non_zero.cpp ) target_compile_definitions(crop_non_zero PRIVATE "COMPOSITION_BUILDING_DLL" ) -rclcpp_components_register_nodes(crop_non_zero "image_proc::CropNonZeroNode") -set(node_plugins "${node_plugins}image_proc::CropNonZeroNode;$\n") +rclcpp_components_register_node(crop_non_zero + PLUGIN "image_proc::CropNonZeroNode" + EXECUTABLE crop_non_zero_node +) # image_proc example node ament_auto_add_executable(image_proc_exe diff --git a/stereo_image_proc/CMakeLists.txt b/stereo_image_proc/CMakeLists.txt index 83862806d..6afd9bb8b 100644 --- a/stereo_image_proc/CMakeLists.txt +++ b/stereo_image_proc/CMakeLists.txt @@ -26,6 +26,7 @@ target_link_libraries(${PROJECT_NAME} ${OpenCV_LIBRARIES} ) +# Register individual components and also build standalone nodes for each rclcpp_components_register_node(${PROJECT_NAME} PLUGIN "stereo_image_proc::DisparityNode" EXECUTABLE disparity_node