Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(diagnostic_graph_aggregator): componentize node #7025

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading