From 5bf9cbea33b4b88063afccab88de72691f8f98d9 Mon Sep 17 00:00:00 2001 From: MaybeWilli <51888361+MaybeWilli@users.noreply.github.com> Date: Sat, 27 Jun 2026 12:07:40 -0400 Subject: [PATCH 1/4] Node status --- .../system-telemetry-cpp/CMakeLists.txt | 10 ++++ .../node_status_publisher.hpp | 21 ++++++++ .../src/node_status_publisher.cpp | 49 +++++++++++++++++++ 3 files changed, 80 insertions(+) create mode 100644 src/Teleop-Control/system-telemetry-cpp/include/system-telemetry-cpp/node_status_publisher.hpp create mode 100644 src/Teleop-Control/system-telemetry-cpp/src/node_status_publisher.cpp diff --git a/src/Teleop-Control/system-telemetry-cpp/CMakeLists.txt b/src/Teleop-Control/system-telemetry-cpp/CMakeLists.txt index eec9cc89..0a6ee6b0 100644 --- a/src/Teleop-Control/system-telemetry-cpp/CMakeLists.txt +++ b/src/Teleop-Control/system-telemetry-cpp/CMakeLists.txt @@ -36,11 +36,20 @@ add_executable(system_telemetry_publisher src/gpu_collector.cpp ) +add_executable(node_status_publisher + src/node_status_publisher.cpp +) + ament_target_dependencies(system_telemetry_publisher rclcpp interfaces ) +ament_target_dependencies(node_status_publisher + rclcpp + std_msgs +) + add_executable(snmp_network_stats src/snmp_network_stats.cpp ) @@ -62,6 +71,7 @@ target_link_libraries(snmp_network_stats install(TARGETS system_telemetry_publisher snmp_network_stats + node_status_publisher DESTINATION lib/${PROJECT_NAME} ) diff --git a/src/Teleop-Control/system-telemetry-cpp/include/system-telemetry-cpp/node_status_publisher.hpp b/src/Teleop-Control/system-telemetry-cpp/include/system-telemetry-cpp/node_status_publisher.hpp new file mode 100644 index 00000000..b6e1c400 --- /dev/null +++ b/src/Teleop-Control/system-telemetry-cpp/include/system-telemetry-cpp/node_status_publisher.hpp @@ -0,0 +1,21 @@ +#ifndef NODE_STATUS_PUBLISHER_HPP +#define NODE_STATUS_PUBLISHER_HPP + +#include +#include + +#include +#include + +class NodeStatusPublisher : public rclcpp::Node { +public: + NodeStatusPublisher(); + +private: + void publish_nodes(); + + rclcpp::Publisher::SharedPtr publisher_; + rclcpp::TimerBase::SharedPtr timer_; +}; + +#endif // NODE_STATUS_PUBLISHER_HPP \ No newline at end of file diff --git a/src/Teleop-Control/system-telemetry-cpp/src/node_status_publisher.cpp b/src/Teleop-Control/system-telemetry-cpp/src/node_status_publisher.cpp new file mode 100644 index 00000000..9a966be7 --- /dev/null +++ b/src/Teleop-Control/system-telemetry-cpp/src/node_status_publisher.cpp @@ -0,0 +1,49 @@ +#include "../include/system-telemetry-cpp/node_status_publisher.hpp" + +#include +#include +#include + +NodeStatusPublisher::NodeStatusPublisher() : Node("node_status_publisher") { + + rclcpp::QoS qos(10); + qos.transient_local(); + + publisher_ = + this->create_publisher("/system/nodes", qos); + + timer_ = this->create_wall_timer( + std::chrono::seconds(1), + std::bind(&NodeStatusPublisher::publish_nodes, this)); + + RCLCPP_INFO(this->get_logger(), "NodeStatusPublisher started (ROS-native)"); +} + +void NodeStatusPublisher::publish_nodes() { + // Get all nodes in the ROS graph (native API) + std::vector nodes = this->get_node_names(); + + // Build JSON + std::ostringstream json; + json << "{\"nodes\": ["; + + for (size_t i = 0; i < nodes.size(); ++i) { + json << "\"" << nodes[i] << "\""; + if (i + 1 < nodes.size()) + json << ", "; + } + + json << "]}"; + + std_msgs::msg::String msg; + msg.data = json.str(); + + publisher_->publish(msg); +} + +int main(int argc, char **argv) { + rclcpp::init(argc, argv); + rclcpp::spin(std::make_shared()); + rclcpp::shutdown(); + return 0; +} \ No newline at end of file From bfb9fd82ad61af395e7a779a69ab115f80ff0318 Mon Sep 17 00:00:00 2001 From: MaybeWilli <51888361+MaybeWilli@users.noreply.github.com> Date: Mon, 6 Jul 2026 23:12:24 -0400 Subject: [PATCH 2/4] Add to launch file --- src/Bringup/launch/core.launch.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Bringup/launch/core.launch.py b/src/Bringup/launch/core.launch.py index 12c64e56..306f52a8 100644 --- a/src/Bringup/launch/core.launch.py +++ b/src/Bringup/launch/core.launch.py @@ -38,9 +38,16 @@ def generate_launch_description(): output="screen", ) + status_node = Node( + package="system-telemetry-cpp", + executable="node_status_publisher", + name="node_status_publisher" + ) + return LaunchDescription( get_included_launch_descriptions(launch_files) + [ snmp_node, + status_node ] ) From 60cecdaab59a06d39a1948c61a7e36f622e1f13f Mon Sep 17 00:00:00 2001 From: Nathaniel Hargrave Date: Tue, 7 Jul 2026 18:31:28 +0000 Subject: [PATCH 3/4] formatting --- src/Bringup/launch/core.launch.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/Bringup/launch/core.launch.py b/src/Bringup/launch/core.launch.py index 306f52a8..8c89c1b5 100644 --- a/src/Bringup/launch/core.launch.py +++ b/src/Bringup/launch/core.launch.py @@ -41,13 +41,9 @@ def generate_launch_description(): status_node = Node( package="system-telemetry-cpp", executable="node_status_publisher", - name="node_status_publisher" + name="node_status_publisher", ) return LaunchDescription( - get_included_launch_descriptions(launch_files) - + [ - snmp_node, - status_node - ] + get_included_launch_descriptions(launch_files) + [snmp_node, status_node] ) From bddfac61da71ea53ea4691e675846e460a20f9c0 Mon Sep 17 00:00:00 2001 From: Nathaniel Hargrave Date: Wed, 15 Jul 2026 20:57:41 +0000 Subject: [PATCH 4/4] use custom ros message anf configurable frequency --- .../system-telemetry-cpp/CMakeLists.txt | 2 +- .../node_status_publisher.hpp | 6 +++- .../src/node_status_publisher.cpp | 28 ++++++------------- src/interfaces/CMakeLists.txt | 1 + src/interfaces/msg/NodeList.msg | 1 + 5 files changed, 16 insertions(+), 22 deletions(-) create mode 100644 src/interfaces/msg/NodeList.msg diff --git a/src/Teleop-Control/system-telemetry-cpp/CMakeLists.txt b/src/Teleop-Control/system-telemetry-cpp/CMakeLists.txt index 0a6ee6b0..9dfca1e1 100644 --- a/src/Teleop-Control/system-telemetry-cpp/CMakeLists.txt +++ b/src/Teleop-Control/system-telemetry-cpp/CMakeLists.txt @@ -47,7 +47,7 @@ ament_target_dependencies(system_telemetry_publisher ament_target_dependencies(node_status_publisher rclcpp - std_msgs + interfaces ) add_executable(snmp_network_stats diff --git a/src/Teleop-Control/system-telemetry-cpp/include/system-telemetry-cpp/node_status_publisher.hpp b/src/Teleop-Control/system-telemetry-cpp/include/system-telemetry-cpp/node_status_publisher.hpp index b6e1c400..8c5cd904 100644 --- a/src/Teleop-Control/system-telemetry-cpp/include/system-telemetry-cpp/node_status_publisher.hpp +++ b/src/Teleop-Control/system-telemetry-cpp/include/system-telemetry-cpp/node_status_publisher.hpp @@ -7,6 +7,8 @@ #include #include +#include "interfaces/msg/node_list.hpp" + class NodeStatusPublisher : public rclcpp::Node { public: NodeStatusPublisher(); @@ -14,7 +16,9 @@ class NodeStatusPublisher : public rclcpp::Node { private: void publish_nodes(); - rclcpp::Publisher::SharedPtr publisher_; + double frequency_; + + rclcpp::Publisher::SharedPtr publisher_; rclcpp::TimerBase::SharedPtr timer_; }; diff --git a/src/Teleop-Control/system-telemetry-cpp/src/node_status_publisher.cpp b/src/Teleop-Control/system-telemetry-cpp/src/node_status_publisher.cpp index 9a966be7..21117ee9 100644 --- a/src/Teleop-Control/system-telemetry-cpp/src/node_status_publisher.cpp +++ b/src/Teleop-Control/system-telemetry-cpp/src/node_status_publisher.cpp @@ -4,39 +4,27 @@ #include #include -NodeStatusPublisher::NodeStatusPublisher() : Node("node_status_publisher") { +NodeStatusPublisher::NodeStatusPublisher() + : Node("node_status_publisher"), + frequency_(this->declare_parameter("frequency", 1.0)) { rclcpp::QoS qos(10); qos.transient_local(); publisher_ = - this->create_publisher("/system/nodes", qos); + this->create_publisher("/system/nodes", qos); + const auto period = std::chrono::duration(1.0 / frequency_); timer_ = this->create_wall_timer( - std::chrono::seconds(1), + std::chrono::duration_cast(period), std::bind(&NodeStatusPublisher::publish_nodes, this)); RCLCPP_INFO(this->get_logger(), "NodeStatusPublisher started (ROS-native)"); } void NodeStatusPublisher::publish_nodes() { - // Get all nodes in the ROS graph (native API) - std::vector nodes = this->get_node_names(); - - // Build JSON - std::ostringstream json; - json << "{\"nodes\": ["; - - for (size_t i = 0; i < nodes.size(); ++i) { - json << "\"" << nodes[i] << "\""; - if (i + 1 < nodes.size()) - json << ", "; - } - - json << "]}"; - - std_msgs::msg::String msg; - msg.data = json.str(); + interfaces::msg::NodeList msg; + msg.nodes = this->get_node_names(); publisher_->publish(msg); } diff --git a/src/interfaces/CMakeLists.txt b/src/interfaces/CMakeLists.txt index aece4b06..a21dce11 100644 --- a/src/interfaces/CMakeLists.txt +++ b/src/interfaces/CMakeLists.txt @@ -24,6 +24,7 @@ rosidl_generate_interfaces(${PROJECT_NAME} "msg/EspSensorReadings.msg" "msg/GasSensorReading.msg" "msg/MoveGroupStatus.msg" + "msg/NodeList.msg" "msg/ObjectDetected.msg" "msg/PolarimeterSweep.msg" "msg/PwmCommand.msg" diff --git a/src/interfaces/msg/NodeList.msg b/src/interfaces/msg/NodeList.msg new file mode 100644 index 00000000..566e2d01 --- /dev/null +++ b/src/interfaces/msg/NodeList.msg @@ -0,0 +1 @@ +string[] nodes \ No newline at end of file