Skip to content
Open
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
73 changes: 73 additions & 0 deletions repositories/diagnostics.BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ load(
"ros2_cpp_library",
)
load("@com_github_mvukov_rules_ros2//ros2:plugin.bzl", "ros2_plugin")
load("@com_github_mvukov_rules_ros2//ros2:py_defs.bzl", "ros2_py_binary")
load("@rules_python//python:defs.bzl", "py_library")
load("@rules_ros2_pip_deps//:requirements.bzl", "requirement")

ros2_cpp_library(
name = "cpp_diagnostic_updater",
srcs = ["diagnostic_updater/src/diagnostic_updater.cpp"],
hdrs = glob(["diagnostic_updater/include/**/*.hpp"]),
includes = ["diagnostic_updater/include"],
visibility = ["//visibility:public"],
Expand Down Expand Up @@ -93,3 +96,73 @@ ros2_cpp_binary(
"@ros2_rclcpp//:rclcpp",
],
)

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!

name = "cpu_monitor_node",
srcs = ["diagnostic_common_diagnostics/diagnostic_common_diagnostics/cpu_monitor.py"],
main = "diagnostic_common_diagnostics/diagnostic_common_diagnostics/cpu_monitor.py",
set_up_ament = False,
visibility = ["//visibility:public"],
deps = [
":py_diagnostic_updater",
"@ros2_common_interfaces//:py_diagnostic_msgs",
"@ros2_rclpy//:rclpy",
requirement("psutil"),
],
)

# The "hd" in "hd_monitor_node" means "hard drive". We name it "hd_monitor_node" to stay
# consistent with the upstream name.
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".

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.

visibility = ["//visibility:public"],
deps = [
":py_diagnostic_updater",
"@ros2_common_interfaces//:py_diagnostic_msgs",
"@ros2_rclpy//:rclpy",
],
)

ros2_py_binary(
name = "ntp_monitor_node",
srcs = ["diagnostic_common_diagnostics/diagnostic_common_diagnostics/ntp_monitor.py"],
main = "diagnostic_common_diagnostics/diagnostic_common_diagnostics/ntp_monitor.py",
set_up_ament = False,
visibility = ["//visibility:public"],
deps = [
":py_diagnostic_updater",
"@ros2_common_interfaces//:py_diagnostic_msgs",
"@ros2_rclpy//:rclpy",
requirement("ntplib"),
],
)

ros2_py_binary(
name = "ram_monitor_node",
srcs = ["diagnostic_common_diagnostics/diagnostic_common_diagnostics/ram_monitor.py"],
main = "diagnostic_common_diagnostics/diagnostic_common_diagnostics/ram_monitor.py",
set_up_ament = False,
visibility = ["//visibility:public"],
deps = [
":py_diagnostic_updater",
"@ros2_common_interfaces//:py_diagnostic_msgs",
"@ros2_rclpy//:rclpy",
requirement("psutil"),
],
)

ros2_py_binary(
name = "sensors_monitor_node",
srcs = ["diagnostic_common_diagnostics/diagnostic_common_diagnostics/sensors_monitor.py"],
main = "diagnostic_common_diagnostics/diagnostic_common_diagnostics/sensors_monitor.py",
set_up_ament = False,
visibility = ["//visibility:public"],
deps = [
":py_diagnostic_updater",
"@ros2_common_interfaces//:py_diagnostic_msgs",
"@ros2_rclpy//:rclpy",
],
)
6 changes: 3 additions & 3 deletions repositories/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -301,9 +301,9 @@ def ros2_repositories():
http_archive,
name = "ros2_diagnostics",
build_file = "@com_github_mvukov_rules_ros2//repositories:diagnostics.BUILD.bazel",
sha256 = "a723dae7acf0f00ee643c076c7c81299be0254919f29225ec7a89dc14cb8ea6f",
strip_prefix = "diagnostics-9f402787ea2c9b3dd4d7e51a9986810e8a3400ba",
urls = ["https://github.com/ros/diagnostics/archive/9f402787ea2c9b3dd4d7e51a9986810e8a3400ba.zip"],
sha256 = "22f3e6cf118bc76bdbd466106f4f0dd94382277d3fc7eb5248d2fcf26be8d411",
strip_prefix = "diagnostics-4.4.6",
urls = ["https://github.com/ros/diagnostics/archive/refs/tags/4.4.6.zip"],
)

maybe(
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ catkin_pkg
coverage
empy==3.3.*
lark-parser
ntplib
numpy~=1.23
packaging
psutil
Expand Down
4 changes: 4 additions & 0 deletions requirements_lock.txt
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ lark-parser==0.12.0 \
--hash=sha256:0eaf30cb5ba787fe404d73a7d6e61df97b21d5a63ac26c5008c78a494373c675 \
--hash=sha256:15967db1f1214013dca65b1180745047b9be457d73da224fcda3d9dd4e96a138
# via -r requirements.txt
ntplib==0.4.0 \
--hash=sha256:899d8fb5f8c2555213aea95efca02934c7343df6ace9d7628a5176b176906267 \
--hash=sha256:8d27375329ed7ff38755f7b6d4658b28edc147cadf40338a63a0da8133469d60
# via -r requirements.txt
numpy==1.26.4 \
--hash=sha256:03a8c78d01d9781b28a6989f6fa1bb2c4f2d51201cf99d3dd875df6fbd96b23b \
--hash=sha256:08beddf13648eb95f8d867350f6a018a4be2e5ad54c8d8caed89ebca558b2818 \
Expand Down
2 changes: 1 addition & 1 deletion ros2/test/diagnostics/diagnostic_publisher.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

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.

diagnostic_updater_.setHardwareID("none");
diagnostic_updater_.add("", &diagnostic_heartbeat_,
&diagnostic_updater::Heartbeat::run);
Expand Down