Skip to content

Commit 5935138

Browse files
feat(yabloc_image_processing): componentize yabloc_image_processing nodes (autowarefoundation#7196)
* replace executable with component Signed-off-by: Kento Yabuuchi <kento.yabuuchi.2@tier4.jp> * modify launch Signed-off-by: Kento Yabuuchi <kento.yabuuchi.2@tier4.jp> * fix line_segments_overlay namespace & node_name Signed-off-by: Kento Yabuuchi <kento.yabuuchi.2@tier4.jp> * style(pre-commit): autofix * uncomment lanelet2_overlay Signed-off-by: Kento Yabuuchi <kento.yabuuchi.2@tier4.jp> --------- Signed-off-by: Kento Yabuuchi <kento.yabuuchi.2@tier4.jp> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent bc8c08b commit 5935138

File tree

20 files changed

+83
-187
lines changed

20 files changed

+83
-187
lines changed

localization/yabloc/yabloc_image_processing/CMakeLists.txt

+42-43
Original file line numberDiff line numberDiff line change
@@ -14,56 +14,55 @@ find_package(OpenCV REQUIRED)
1414
# PCL
1515
find_package(PCL REQUIRED COMPONENTS common)
1616

17+
ament_auto_add_library(${PROJECT_NAME} SHARED
18+
src/line_segment_detector/line_segment_detector_core.cpp
19+
src/graph_segment/graph_segment_core.cpp
20+
src/graph_segment/similar_area_searcher.cpp
21+
src/segment_filter/segment_filter_core.cpp
22+
src/undistort/undistort_node.cpp
23+
src/line_segments_overlay/line_segments_overlay_core.cpp
24+
src/lanelet2_overlay/lanelet2_overlay_core.cpp
25+
)
26+
target_include_directories(${PROJECT_NAME} PUBLIC include ${EIGEN3_INCLUDE_DIRS} ${PCL_INCLUDE_DIRS})
27+
target_link_libraries(${PROJECT_NAME} ${PCL_LIBRARIES} ${OpenCV_LIBS})
28+
1729
# ===================================================
1830
# Executable
19-
# line segment detector
20-
set(TARGET line_segment_detector_node)
21-
ament_auto_add_executable(${TARGET}
22-
src/line_segment_detector/line_segment_detector_node.cpp
23-
src/line_segment_detector/line_segment_detector_core.cpp)
24-
target_include_directories(${TARGET} PUBLIC include)
25-
target_include_directories(${TARGET} SYSTEM PUBLIC ${EIGEN3_INCLUDE_DIRS})
26-
target_link_libraries(${TARGET} ${OpenCV_LIBS})
31+
rclcpp_components_register_node(${PROJECT_NAME}
32+
PLUGIN "yabloc::graph_segment::GraphSegment"
33+
EXECUTABLE yabloc_graph_segment_node
34+
EXECUTOR SingleThreadedExecutor
35+
)
2736

28-
# graph based segmentation
29-
set(TARGET graph_segment_node)
30-
ament_auto_add_executable(${TARGET}
31-
src/graph_segment/graph_segment_node.cpp
32-
src/graph_segment/graph_segment_core.cpp
33-
src/graph_segment/similar_area_searcher.cpp)
34-
target_include_directories(${TARGET} PUBLIC include)
35-
target_include_directories(${TARGET} SYSTEM PUBLIC ${EIGEN3_INCLUDE_DIRS})
36-
target_link_libraries(${TARGET} ${OpenCV_LIBS})
37+
rclcpp_components_register_node(${PROJECT_NAME}
38+
PLUGIN "yabloc::lanelet2_overlay::Lanelet2Overlay"
39+
EXECUTABLE yabloc_lanelet2_overlay_node
40+
EXECUTOR SingleThreadedExecutor
41+
)
3742

38-
# segment filter
39-
set(TARGET segment_filter_node)
40-
ament_auto_add_executable(${TARGET}
41-
src/segment_filter/segment_filter_node.cpp
42-
src/segment_filter/segment_filter_core.cpp)
43-
target_include_directories(${TARGET} PUBLIC include ${EIGEN3_INCLUDE_DIRS} ${PCL_INCLUDE_DIRS})
44-
target_link_libraries(${TARGET} ${PCL_LIBRARIES} ${OpenCV_LIBS})
43+
rclcpp_components_register_node(${PROJECT_NAME}
44+
PLUGIN "yabloc::line_segment_detector::LineSegmentDetector"
45+
EXECUTABLE yabloc_line_segment_detector_node
46+
EXECUTOR SingleThreadedExecutor
47+
)
4548

46-
# undistort
47-
set(TARGET undistort_node)
48-
ament_auto_add_executable(${TARGET}
49-
src/undistort/undistort_node.cpp)
50-
target_link_libraries(${TARGET} ${OpenCV_LIBS})
49+
rclcpp_components_register_node(${PROJECT_NAME}
50+
PLUGIN "yabloc::line_segments_overlay::LineSegmentsOverlay"
51+
EXECUTABLE yabloc_line_segments_overlay_node
52+
EXECUTOR SingleThreadedExecutor
53+
)
5154

52-
# line_segments_overlay
53-
set(TARGET line_segments_overlay_node)
54-
ament_auto_add_executable(${TARGET}
55-
src/line_segments_overlay/line_segments_overlay_core.cpp
56-
src/line_segments_overlay/line_segments_overlay_node.cpp)
57-
target_include_directories(${TARGET} PUBLIC include ${EIGEN_INCLUDE_DIRS} ${PCL_INCLUDE_DIRS})
58-
target_link_libraries(${TARGET} ${PCL_LIBRARIES})
55+
rclcpp_components_register_node(${PROJECT_NAME}
56+
PLUGIN "yabloc::segment_filter::SegmentFilter"
57+
EXECUTABLE yabloc_segment_filter_node
58+
EXECUTOR SingleThreadedExecutor
59+
)
5960

60-
# lanelet2_overlay
61-
set(TARGET lanelet2_overlay_node)
62-
ament_auto_add_executable(${TARGET}
63-
src/lanelet2_overlay/lanelet2_overlay_core.cpp
64-
src/lanelet2_overlay/lanelet2_overlay_node.cpp)
65-
target_include_directories(${TARGET} PUBLIC include ${EIGEN_INCLUDE_DIRS} ${PCL_INCLUDE_DIRS})
66-
target_link_libraries(${TARGET} ${PCL_LIBRARIES})
61+
rclcpp_components_register_node(${PROJECT_NAME}
62+
PLUGIN "yabloc::undistort::UndistortNode"
63+
EXECUTABLE yabloc_undistort_node
64+
EXECUTOR SingleThreadedExecutor
65+
)
6766

6867
# ===================================================
6968
ament_auto_package(INSTALL_TO_SHARE config launch)

localization/yabloc/yabloc_image_processing/include/yabloc_image_processing/graph_segment/graph_segment.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class GraphSegment : public rclcpp::Node
3232
public:
3333
using PointCloud2 = sensor_msgs::msg::PointCloud2;
3434
using Image = sensor_msgs::msg::Image;
35-
GraphSegment();
35+
explicit GraphSegment(const rclcpp::NodeOptions & options = rclcpp::NodeOptions());
3636

3737
private:
3838
const float target_height_ratio_;

localization/yabloc/yabloc_image_processing/include/yabloc_image_processing/lanelet2_overlay/lanelet2_overlay.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class Lanelet2Overlay : public rclcpp::Node
4747
using Image = sensor_msgs::msg::Image;
4848
using Float32Array = std_msgs::msg::Float32MultiArray;
4949

50-
Lanelet2Overlay();
50+
explicit Lanelet2Overlay(const rclcpp::NodeOptions & options = rclcpp::NodeOptions());
5151

5252
private:
5353
common::StaticTfSubscriber tf_subscriber_;

localization/yabloc/yabloc_image_processing/include/yabloc_image_processing/line_segment_detector/line_segment_detector.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class LineSegmentDetector : public rclcpp::Node
4242
using Image = sensor_msgs::msg::Image;
4343
using PointCloud2 = sensor_msgs::msg::PointCloud2;
4444

45-
LineSegmentDetector();
45+
explicit LineSegmentDetector(const rclcpp::NodeOptions & options = rclcpp::NodeOptions());
4646

4747
private:
4848
rclcpp::Subscription<Image>::SharedPtr sub_image_;

localization/yabloc/yabloc_image_processing/include/yabloc_image_processing/line_segments_overlay/line_segments_overlay.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class LineSegmentsOverlay : public rclcpp::Node
3434
using Image = sensor_msgs::msg::Image;
3535
using LineSegment = pcl::PointXYZLNormal;
3636
using LineSegments = pcl::PointCloud<LineSegment>;
37-
LineSegmentsOverlay();
37+
explicit LineSegmentsOverlay(const rclcpp::NodeOptions & options = rclcpp::NodeOptions());
3838

3939
private:
4040
void on_image(const Image::ConstSharedPtr & img_msg);

localization/yabloc/yabloc_image_processing/include/yabloc_image_processing/segment_filter/segment_filter.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class SegmentFilter : public rclcpp::Node
3939
using PointCloud2 = sensor_msgs::msg::PointCloud2;
4040
using Image = sensor_msgs::msg::Image;
4141

42-
SegmentFilter();
42+
explicit SegmentFilter(const rclcpp::NodeOptions & options = rclcpp::NodeOptions());
4343

4444
private:
4545
using ProjectFunc = std::function<std::optional<Eigen::Vector3f>(const Eigen::Vector3f &)>;

localization/yabloc/yabloc_image_processing/launch/image_processing.launch.xml

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<arg name="resized_info" default="/sensing/camera/undistorted/camera_info"/>
66

77
<!-- undistort -->
8-
<node name="undistort" pkg="yabloc_image_processing" exec="undistort_node" output="screen" args="--ros-args --log-level warn">
8+
<node pkg="yabloc_image_processing" exec="yabloc_undistort_node" output="both">
99
<param from="$(var undistort_param_path)"/>
1010

1111
<remap from="~/input/image_raw" to="$(var src_image)"/>
@@ -18,7 +18,7 @@
1818
<!-- line segment detector -->
1919
<arg name="output_image_with_line_segments" default="image_with_line_segments"/>
2020
<arg name="output_line_segments_cloud" default="line_segments_cloud"/>
21-
<node name="line_segment_detector" pkg="yabloc_image_processing" exec="line_segment_detector_node" output="screen" args="--ros-args --log-level warn">
21+
<node pkg="yabloc_image_processing" exec="yabloc_line_segment_detector_node" output="both">
2222
<remap from="~/input/image_raw" to="$(var resized_image)"/>
2323
<remap from="~/debug/image_with_line_segments" to="$(var output_image_with_line_segments)"/>
2424
<remap from="~/output/line_segments_cloud" to="$(var output_line_segments_cloud)"/>
@@ -27,7 +27,7 @@
2727
<!-- graph based segmentation -->
2828
<arg name="output_graph_segmented" default="graph_segmented"/>
2929
<arg name="output_segmented_image" default="segmented_image"/>
30-
<node name="graph_segment" pkg="yabloc_image_processing" exec="graph_segment_node" output="screen" args="--ros-args --log-level warn">
30+
<node pkg="yabloc_image_processing" exec="yabloc_graph_segment_node" output="both">
3131
<param from="$(var graph_segment_param_path)"/>
3232
<remap from="~/input/image_raw" to="$(var resized_image)"/>
3333
<remap from="~/output/mask_image" to="$(var output_graph_segmented)"/>
@@ -40,7 +40,7 @@
4040
<arg name="output_projected_line_segments_cloud" default="projected_line_segments_cloud"/>
4141
<arg name="output_projected_image" default="projected_image"/>
4242
<arg name="output_debug_line_segments" default="debug/line_segments_cloud"/>
43-
<node name="segment_filter" pkg="yabloc_image_processing" exec="segment_filter_node" output="screen" args="--ros-args --log-level info">
43+
<node pkg="yabloc_image_processing" exec="yabloc_segment_filter_node" output="both">
4444
<param from="$(var segment_filter_param_path)"/>
4545

4646
<remap from="~/input/line_segments_cloud" to="$(var input_line_segments_cloud)"/>

localization/yabloc/yabloc_image_processing/launch/overlay.launch.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<arg name="resized_info" description=""/>
1111

1212
<!-- lanelet2 overlay monitor -->
13-
<node name="lanelet2_overlay" pkg="yabloc_image_processing" exec="lanelet2_overlay_node" output="screen" args="--ros-args --log-level warn">
13+
<node pkg="yabloc_image_processing" exec="yabloc_lanelet2_overlay_node" output="both">
1414
<remap from="~/input/image_raw" to="$(var resized_image)"/>
1515
<remap from="~/input/camera_info" to="$(var resized_info)"/>
1616
<remap from="~/input/pose" to="$(var input_overlaid_pose)"/>
@@ -23,7 +23,7 @@
2323
</node>
2424

2525
<!-- line segments overlay monitor -->
26-
<node name="line_segments_overlay" pkg="yabloc_image_processing" exec="line_segments_overlay_node" output="screen">
26+
<node pkg="yabloc_image_processing" exec="yabloc_line_segments_overlay_node" output="both">
2727
<remap from="~/input/image_raw" to="$(var resized_image)"/>
2828
<remap from="~/input/line_segments" to="$(var input_debug_line_segments)"/>
2929
<remap from="~/debug/image_with_colored_line_segments" to="$(var output_image_with_colored_line_segments)"/>

localization/yabloc/yabloc_image_processing/package.xml

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
<depend>cv_bridge</depend>
2020
<depend>pcl_conversions</depend>
2121
<depend>rclcpp</depend>
22+
<depend>rclcpp_components</depend>
2223
<depend>sensor_msgs</depend>
2324
<depend>std_msgs</depend>
2425
<depend>tier4_autoware_utils</depend>

localization/yabloc/yabloc_image_processing/src/graph_segment/graph_segment_core.cpp

+5-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323

2424
namespace yabloc::graph_segment
2525
{
26-
GraphSegment::GraphSegment()
27-
: Node("graph_segment"),
26+
GraphSegment::GraphSegment(const rclcpp::NodeOptions & options)
27+
: Node("graph_segment", options),
2828
target_height_ratio_(declare_parameter<float>("target_height_ratio")),
2929
target_candidate_box_width_(declare_parameter<int>("target_candidate_box_width"))
3030
{
@@ -159,3 +159,6 @@ void GraphSegment::draw_and_publish_image(
159159
}
160160

161161
} // namespace yabloc::graph_segment
162+
163+
#include <rclcpp_components/register_node_macro.hpp>
164+
RCLCPP_COMPONENTS_REGISTER_NODE(yabloc::graph_segment::GraphSegment)

localization/yabloc/yabloc_image_processing/src/graph_segment/graph_segment_node.cpp

-23
This file was deleted.

localization/yabloc/yabloc_image_processing/src/lanelet2_overlay/lanelet2_overlay_core.cpp

+5-2
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828

2929
namespace yabloc::lanelet2_overlay
3030
{
31-
Lanelet2Overlay::Lanelet2Overlay()
32-
: Node("lanelet2_overlay"), tf_subscriber_(get_clock()), pose_buffer_{40}
31+
Lanelet2Overlay::Lanelet2Overlay(const rclcpp::NodeOptions & options)
32+
: Node("lanelet2_overlay", options), tf_subscriber_(get_clock()), pose_buffer_{40}
3333
{
3434
using std::placeholders::_1;
3535

@@ -211,3 +211,6 @@ void Lanelet2Overlay::make_vis_marker(
211211
}
212212

213213
} // namespace yabloc::lanelet2_overlay
214+
215+
#include <rclcpp_components/register_node_macro.hpp>
216+
RCLCPP_COMPONENTS_REGISTER_NODE(yabloc::lanelet2_overlay::Lanelet2Overlay)

localization/yabloc/yabloc_image_processing/src/lanelet2_overlay/lanelet2_overlay_node.cpp

-23
This file was deleted.

localization/yabloc/yabloc_image_processing/src/line_segment_detector/line_segment_detector_core.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323

2424
namespace yabloc::line_segment_detector
2525
{
26-
LineSegmentDetector::LineSegmentDetector() : Node("line_detector")
26+
LineSegmentDetector::LineSegmentDetector(const rclcpp::NodeOptions & options)
27+
: Node("line_detector", options)
2728
{
2829
using std::placeholders::_1;
2930

@@ -106,3 +107,6 @@ std::vector<cv::Mat> LineSegmentDetector::remove_too_outer_elements(
106107
}
107108

108109
} // namespace yabloc::line_segment_detector
110+
111+
#include <rclcpp_components/register_node_macro.hpp>
112+
RCLCPP_COMPONENTS_REGISTER_NODE(yabloc::line_segment_detector::LineSegmentDetector)

localization/yabloc/yabloc_image_processing/src/line_segment_detector/line_segment_detector_node.cpp

-23
This file was deleted.

localization/yabloc/yabloc_image_processing/src/line_segments_overlay/line_segments_overlay_core.cpp

+5-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323

2424
namespace yabloc::line_segments_overlay
2525
{
26-
LineSegmentsOverlay::LineSegmentsOverlay()
27-
: Node("overlay_lanelet2"),
26+
LineSegmentsOverlay::LineSegmentsOverlay(const rclcpp::NodeOptions & options)
27+
: Node("line_segments_overlay", options),
2828
max_buffer_size_(static_cast<size_t>(declare_parameter<int>("max_buffer_size", 5)))
2929
{
3030
using std::placeholders::_1;
@@ -90,3 +90,6 @@ void LineSegmentsOverlay::on_line_segments(const PointCloud2::ConstSharedPtr & l
9090
}
9191

9292
} // namespace yabloc::line_segments_overlay
93+
94+
#include <rclcpp_components/register_node_macro.hpp>
95+
RCLCPP_COMPONENTS_REGISTER_NODE(yabloc::line_segments_overlay::LineSegmentsOverlay)

localization/yabloc/yabloc_image_processing/src/line_segments_overlay/line_segments_overlay_node.cpp

-23
This file was deleted.

localization/yabloc/yabloc_image_processing/src/segment_filter/segment_filter_core.cpp

+5-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323

2424
namespace yabloc::segment_filter
2525
{
26-
SegmentFilter::SegmentFilter()
27-
: Node("segment_filter"),
26+
SegmentFilter::SegmentFilter(const rclcpp::NodeOptions & options)
27+
: Node("segment_filter", options),
2828
image_size_(declare_parameter<int>("image_size")),
2929
max_range_(declare_parameter<float>("max_range")),
3030
min_segment_length_(declare_parameter<float>("min_segment_length")),
@@ -282,3 +282,6 @@ std::set<int> SegmentFilter::filter_by_mask(
282282
}
283283

284284
} // namespace yabloc::segment_filter
285+
286+
#include <rclcpp_components/register_node_macro.hpp>
287+
RCLCPP_COMPONENTS_REGISTER_NODE(yabloc::segment_filter::SegmentFilter)

0 commit comments

Comments
 (0)