Skip to content

Commit 5e35919

Browse files
isamu-takagikarishma1911
authored andcommitted
feat(diagnostic_graph_aggregator): componentize node (autowarefoundation#7025)
Signed-off-by: Takagi, Isamu <isamu.takagi@tier4.jp>
1 parent f193cfb commit 5e35919

File tree

5 files changed

+17
-20
lines changed

5 files changed

+17
-20
lines changed

system/diagnostic_graph_aggregator/CMakeLists.txt

+11-6
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,6 @@ ament_auto_add_library(${PROJECT_NAME} SHARED
1313
src/common/graph/units.cpp
1414
)
1515

16-
ament_auto_add_executable(aggregator
17-
src/node/aggregator.cpp
18-
src/node/availability.cpp
19-
)
20-
target_include_directories(aggregator PRIVATE src/common)
21-
2216
ament_auto_add_executable(tree
2317
src/tool/tree.cpp
2418
)
@@ -29,6 +23,17 @@ ament_auto_add_executable(plantuml
2923
)
3024
target_include_directories(plantuml PRIVATE src/common)
3125

26+
ament_auto_add_library(aggregator SHARED
27+
src/node/aggregator.cpp
28+
src/node/availability.cpp
29+
)
30+
target_include_directories(aggregator PRIVATE src/common)
31+
32+
rclcpp_components_register_node(aggregator
33+
PLUGIN "diagnostic_graph_aggregator::AggregatorNode"
34+
EXECUTABLE aggregator_node
35+
)
36+
3237
if(BUILD_TESTING)
3338
get_filename_component(RESOURCE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/test/files ABSOLUTE)
3439
ament_auto_add_gtest(gtest_${PROJECT_NAME}

system/diagnostic_graph_aggregator/launch/aggregator.launch.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<launch>
22
<arg name="param_file" default="$(find-pkg-share diagnostic_graph_aggregator)/config/default.param.yaml"/>
33
<arg name="graph_file"/>
4-
<node pkg="diagnostic_graph_aggregator" exec="aggregator" name="aggregator">
4+
<node pkg="diagnostic_graph_aggregator" exec="aggregator_node">
55
<param from="$(var param_file)"/>
66
<param name="graph_file" value="$(var graph_file)"/>
77
</node>

system/diagnostic_graph_aggregator/package.xml

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
<depend>diagnostic_msgs</depend>
1414
<depend>rclcpp</depend>
15+
<depend>rclcpp_components</depend>
1516
<depend>tier4_system_msgs</depend>
1617
<depend>yaml_cpp_vendor</depend>
1718

system/diagnostic_graph_aggregator/src/node/aggregator.cpp

+3-12
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
namespace diagnostic_graph_aggregator
2222
{
2323

24-
AggregatorNode::AggregatorNode() : Node("aggregator")
24+
AggregatorNode::AggregatorNode(const rclcpp::NodeOptions & options) : Node("aggregator", options)
2525
{
2626
const auto stamp = now();
2727

@@ -99,14 +99,5 @@ void AggregatorNode::on_diag(const DiagnosticArray & msg)
9999

100100
} // namespace diagnostic_graph_aggregator
101101

102-
int main(int argc, char ** argv)
103-
{
104-
using diagnostic_graph_aggregator::AggregatorNode;
105-
rclcpp::init(argc, argv);
106-
rclcpp::executors::SingleThreadedExecutor executor;
107-
auto node = std::make_shared<AggregatorNode>();
108-
executor.add_node(node);
109-
executor.spin();
110-
executor.remove_node(node);
111-
rclcpp::shutdown();
112-
}
102+
#include <rclcpp_components/register_node_macro.hpp>
103+
RCLCPP_COMPONENTS_REGISTER_NODE(diagnostic_graph_aggregator::AggregatorNode)

system/diagnostic_graph_aggregator/src/node/aggregator.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ namespace diagnostic_graph_aggregator
3030
class AggregatorNode : public rclcpp::Node
3131
{
3232
public:
33-
AggregatorNode();
33+
explicit AggregatorNode(const rclcpp::NodeOptions & options);
3434
~AggregatorNode();
3535

3636
private:

0 commit comments

Comments
 (0)