Skip to content

Conversation

thomasegriffith
Copy link
Contributor

@thomasegriffith thomasegriffith commented Apr 3, 2025

Add diagnostics monitor nodes from diagnostic_common_diagnostics.

Includes the following updates:

  • add bazel targets for cpu_monitor_node, hd_monitor_node, ntp_monitor_node, ram_monitor_node, and sensors_monitor_node
  • add ntplib to the pip requirements files
  • update our version of the ros/diagnostics repo to 207f0c0f1f8e9bd1842a07d90459aa9a2b670c23
  • update the sources in cpp_diagnostic_updater to use new source files that were not in the previous version of ros/diagnostics
  • update the diagnostics test to correctly instantiate diagnostic_updater_, since brace initialization will not work with the templated constructor anymore (a delegated constructor's definition was moved from a header to a source file)

class Publisher : public rclcpp::Node {
public:
Publisher() : Node("heartbeat_publisher"), diagnostic_updater_{this} {
Publisher() : Node("heartbeat_publisher"), diagnostic_updater_(this) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change seems to be unrelated to this PR. Please revert.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The CI fails without this change. Looks like the log expired, but it's a brace initialization problem.

Between versions 9f402787ea2c9b3dd4d7e51a9986810e8a3400ba and 207f0c0f1f8e9bd1842a07d90459aa9a2b670c23 of ros/diagnostics, they moved one of the Updater constructors from a header file to a source file. That constructor is then used by the templated constructor. Since we're using the templated constructor, brace initialization requires that its definition is completely visible from the header file. Since it's delegating to another constructor that's now defined in the source file, brace initialization won't work.

I should have put the reason for this in the PR description. Added!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be more clear: they moved the definition of this constructor to a source file.

It's used by the templated constructor on line 371.

@thomasegriffith thomasegriffith requested a review from mvukov April 15, 2025 22:19
)

ros2_py_binary(
name = "hd_monitor_node",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is hd?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It stands for "hard drive". hd_monitor_node has an unfortunate name, but I figure we ought to keep the naming consistent with the upstream stuff. To help out on our end, I added a comment clarifying this is "hard drive".

],
)

ros2_py_binary(
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay. Why do you need set_up_ament = True? How is this supposed to work in practice? Just launch the nodes?

Copy link
Contributor Author

@thomasegriffith thomasegriffith Jul 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose we don't need it. Change to False. Thanks!

@thomasegriffith thomasegriffith requested a review from mvukov July 30, 2025 02:21
urls = ["https://github.com/ros/diagnostics/archive/9f402787ea2c9b3dd4d7e51a9986810e8a3400ba.zip"],
sha256 = "66b00679cc5404fbe41c4ee486382235f80900bc21bd7937ba25ffca469ec5d4",
strip_prefix = "diagnostics-207f0c0f1f8e9bd1842a07d90459aa9a2b670c23",
urls = ["https://github.com/ros/diagnostics/archive/207f0c0f1f8e9bd1842a07d90459aa9a2b670c23.zip"],
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, I am very sorry for such a late reply. Can we use https://github.com/ros/diagnostics/releases/tag/4.4.6 tag here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea! Done

@thomasegriffith thomasegriffith requested a review from mvukov August 29, 2025 19:15
Copy link
Owner

@mvukov mvukov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One small comment, otherwise LGTM.

name = "hd_monitor_node",
srcs = ["diagnostic_common_diagnostics/diagnostic_common_diagnostics/hd_monitor.py"],
main = "diagnostic_common_diagnostics/diagnostic_common_diagnostics/hd_monitor.py",
set_up_ament = False,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you need set_up_ament = False here and below? If not necessary, please remove.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants