Skip to content

Commit

Permalink
feat(diagnostic_graph_aggregator): componentize node (autowarefoundat…
Browse files Browse the repository at this point in the history
…ion#7025)

Signed-off-by: Takagi, Isamu <isamu.takagi@tier4.jp>
  • Loading branch information
isamu-takagi authored May 15, 2024
1 parent 23d103f commit 85fdcb0
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 20 deletions.
17 changes: 11 additions & 6 deletions system/diagnostic_graph_aggregator/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,6 @@ ament_auto_add_library(${PROJECT_NAME} SHARED
src/common/graph/units.cpp
)

ament_auto_add_executable(aggregator
src/node/aggregator.cpp
src/node/availability.cpp
)
target_include_directories(aggregator PRIVATE src/common)

ament_auto_add_executable(tree
src/tool/tree.cpp
)
Expand All @@ -29,6 +23,17 @@ ament_auto_add_executable(plantuml
)
target_include_directories(plantuml PRIVATE src/common)

ament_auto_add_library(aggregator SHARED
src/node/aggregator.cpp
src/node/availability.cpp
)
target_include_directories(aggregator PRIVATE src/common)

rclcpp_components_register_node(aggregator
PLUGIN "diagnostic_graph_aggregator::AggregatorNode"
EXECUTABLE aggregator_node
)

if(BUILD_TESTING)
get_filename_component(RESOURCE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/test/files ABSOLUTE)
ament_auto_add_gtest(gtest_${PROJECT_NAME}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<launch>
<arg name="param_file" default="$(find-pkg-share diagnostic_graph_aggregator)/config/default.param.yaml"/>
<arg name="graph_file"/>
<node pkg="diagnostic_graph_aggregator" exec="aggregator" name="aggregator">
<node pkg="diagnostic_graph_aggregator" exec="aggregator_node">
<param from="$(var param_file)"/>
<param name="graph_file" value="$(var graph_file)"/>
</node>
Expand Down
1 change: 1 addition & 0 deletions system/diagnostic_graph_aggregator/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

<depend>diagnostic_msgs</depend>
<depend>rclcpp</depend>
<depend>rclcpp_components</depend>
<depend>tier4_system_msgs</depend>
<depend>yaml_cpp_vendor</depend>

Expand Down
15 changes: 3 additions & 12 deletions system/diagnostic_graph_aggregator/src/node/aggregator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
namespace diagnostic_graph_aggregator
{

AggregatorNode::AggregatorNode() : Node("aggregator")
AggregatorNode::AggregatorNode(const rclcpp::NodeOptions & options) : Node("aggregator", options)
{
const auto stamp = now();

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

} // namespace diagnostic_graph_aggregator

int main(int argc, char ** argv)
{
using diagnostic_graph_aggregator::AggregatorNode;
rclcpp::init(argc, argv);
rclcpp::executors::SingleThreadedExecutor executor;
auto node = std::make_shared<AggregatorNode>();
executor.add_node(node);
executor.spin();
executor.remove_node(node);
rclcpp::shutdown();
}
#include <rclcpp_components/register_node_macro.hpp>
RCLCPP_COMPONENTS_REGISTER_NODE(diagnostic_graph_aggregator::AggregatorNode)
2 changes: 1 addition & 1 deletion system/diagnostic_graph_aggregator/src/node/aggregator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ namespace diagnostic_graph_aggregator
class AggregatorNode : public rclcpp::Node
{
public:
AggregatorNode();
explicit AggregatorNode(const rclcpp::NodeOptions & options);
~AggregatorNode();

private:
Expand Down

0 comments on commit 85fdcb0

Please sign in to comment.