Skip to content

Commit

Permalink
rename nodes
Browse files Browse the repository at this point in the history
Signed-off-by: Takagi, Isamu <[email protected]>
  • Loading branch information
isamu-takagi committed Mar 14, 2024
1 parent 257e530 commit cf6b39b
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
14 changes: 7 additions & 7 deletions system/diagnostic_graph_aggregator/src/node/aggregator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
namespace diagnostic_graph_aggregator
{

MainNode::MainNode() : Node("diagnostic_graph_aggregator_aggregator")
AggregatorNode::AggregatorNode() : Node("aggregator")
{
// Init diagnostics graph.
{
Expand All @@ -39,7 +39,7 @@ MainNode::MainNode() : Node("diagnostic_graph_aggregator_aggregator")
const auto qos_input = rclcpp::QoS(declare_parameter<int64_t>("input_qos_depth"));
const auto qos_graph = rclcpp::QoS(declare_parameter<int64_t>("graph_qos_depth"));

const auto callback = std::bind(&MainNode::on_diag, this, _1);
const auto callback = std::bind(&AggregatorNode::on_diag, this, _1);
sub_input_ = create_subscription<DiagnosticArray>("/diagnostics", qos_input, callback);
pub_graph_ = create_publisher<DiagnosticGraph>("/diagnostics_graph", qos_graph);

Expand All @@ -51,20 +51,20 @@ MainNode::MainNode() : Node("diagnostic_graph_aggregator_aggregator")
debug_ = declare_parameter<bool>("use_debug_mode");
}

MainNode::~MainNode()
AggregatorNode::~AggregatorNode()
{
// for unique_ptr
}

void MainNode::on_timer()
void AggregatorNode::on_timer()
{
const auto stamp = now();
pub_graph_->publish(graph_.report(stamp));
if (debug_) graph_.debug();
if (modes_) modes_->update(stamp);
}

void MainNode::on_diag(const DiagnosticArray::ConstSharedPtr msg)
void AggregatorNode::on_diag(const DiagnosticArray::ConstSharedPtr msg)
{
graph_.callback(now(), *msg);
}
Expand All @@ -73,10 +73,10 @@ void MainNode::on_diag(const DiagnosticArray::ConstSharedPtr msg)

int main(int argc, char ** argv)
{
using diagnostic_graph_aggregator::MainNode;
using diagnostic_graph_aggregator::AggregatorNode;
rclcpp::init(argc, argv);
rclcpp::executors::SingleThreadedExecutor executor;
auto node = std::make_shared<MainNode>();
auto node = std::make_shared<AggregatorNode>();
executor.add_node(node);
executor.spin();
executor.remove_node(node);
Expand Down
6 changes: 3 additions & 3 deletions system/diagnostic_graph_aggregator/src/node/aggregator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@
namespace diagnostic_graph_aggregator
{

class MainNode : public rclcpp::Node
class AggregatorNode : public rclcpp::Node
{
public:
MainNode();
~MainNode();
AggregatorNode();
~AggregatorNode();

private:
Graph graph_;
Expand Down
10 changes: 5 additions & 5 deletions system/diagnostic_graph_aggregator/src/node/converter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,19 +60,19 @@ std::vector<std::string> complement_paths(const DiagnosticGraph & graph)
return result;
}

ToolNode::ToolNode() : Node("diagnostic_graph_aggregator_converter")
ConverterNode::ConverterNode() : Node("converter")
{
using std::placeholders::_1;
const auto qos_graph = rclcpp::QoS(1);
const auto qos_array = rclcpp::QoS(1);

const auto callback = std::bind(&ToolNode::on_graph, this, _1);
const auto callback = std::bind(&ConverterNode::on_graph, this, _1);
sub_graph_ = create_subscription<DiagnosticGraph>("/diagnostics_graph", qos_graph, callback);
pub_array_ = create_publisher<DiagnosticArray>("/diagnostics_agg", qos_array);
complement_inner_nodes_ = declare_parameter<bool>("complement_inner_nodes");
}

void ToolNode::on_graph(const DiagnosticGraph::ConstSharedPtr msg)
void ConverterNode::on_graph(const DiagnosticGraph::ConstSharedPtr msg)
{
DiagnosticArray message;
message.header.stamp = msg->stamp;
Expand Down Expand Up @@ -108,10 +108,10 @@ void ToolNode::on_graph(const DiagnosticGraph::ConstSharedPtr msg)

int main(int argc, char ** argv)
{
using diagnostic_graph_aggregator::ToolNode;
using diagnostic_graph_aggregator::ConverterNode;
rclcpp::init(argc, argv);
rclcpp::executors::SingleThreadedExecutor executor;
auto node = std::make_shared<ToolNode>();
auto node = std::make_shared<ConverterNode>();
executor.add_node(node);
executor.spin();
executor.remove_node(node);
Expand Down
4 changes: 2 additions & 2 deletions system/diagnostic_graph_aggregator/src/node/converter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
namespace diagnostic_graph_aggregator
{

class ToolNode : public rclcpp::Node
class ConverterNode : public rclcpp::Node
{
public:
ToolNode();
ConverterNode();

private:
bool complement_inner_nodes_;
Expand Down

0 comments on commit cf6b39b

Please sign in to comment.