Skip to content

Commit 3176cd2

Browse files
authored
Fixup headers, maintainers, README, lint, before public release (#5)
1 parent d9a74a8 commit 3176cd2

File tree

15 files changed

+157
-32
lines changed

15 files changed

+157
-32
lines changed

.github/workflows/debian-packages.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
# SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES
2+
# Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
# SPDX-License-Identifier: Apache-2.0
17+
118
name: Generate Debian Packages
219

320
on:

.github/workflows/ros-tests.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
# SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES
2+
# Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
# SPDX-License-Identifier: Apache-2.0
17+
118
name: ROS2 Tests
219

320
on:

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@ Greenwave monitor is a tool for runtime monitoring of ROS 2 topics.
55

66
It provides the following features:
77

8-
1. A node similar to a C++ based ros2 topic hz. I.E. subscribes to topics to determine the frame rate and latency. compared to ros2 topic hz the greenwave node is more performant, publishes Diagnostics, and offers services to manage topics and expected frequencies.
8+
1. A node similar to a C++ based ros2 topic hz. i.e. subscribes to topics to determine the frame rate and latency. Compared to ros2 topic hz the greenwave node is more performant, publishes Diagnostics, and offers services to manage topics and expected frequencies.
99

1010
2. A terminal based dashboard that displays the topic rates, latency, and status, and allows you to add/remove topics and set expected frequencies.
1111

1212
3. A header only C++ library so you can calculate and publish compatible diagnostics directly from your own nodes for reduced overhead.
1313

14-
This diagram shows an overview of the ![architecture](docs/images/greenwave_diagram.png)
14+
This diagram shows an overview of the architecture:
15+
16+
![architecture](docs/images/greenwave_diagram.png)
1517

1618
## Diagnostic messages
1719

greenwave_monitor/CMakeLists.txt

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,6 @@ if(BUILD_TESTING)
8181
find_package(ament_cmake_pytest REQUIRED)
8282
find_package(ament_cmake_gtest REQUIRED)
8383

84-
# the following line skips the linter which checks for copyrights
85-
# comment the line when a copyright and license is added to all source files
86-
set(ament_cmake_copyright_FOUND TRUE)
87-
# the following line skips cpplint (only works in a git repo)
88-
# comment the line when this package is in a git repo and when
89-
# a copyright and license is added to all source files
90-
set(ament_cmake_cpplint_FOUND TRUE)
9184
ament_lint_auto_find_test_dependencies()
9285

9386
# Add launch tests for greenwave_monitor

greenwave_monitor/include/message_diagnostics.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,6 @@ class MessageDiagnostics
487487
}
488488
return error_found;
489489
}
490-
491490
};
492491

493492
} // namespace message_diagnostics

greenwave_monitor/include/minimal_publisher_node.hpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,18 @@
1717

1818
#pragma once
1919

20+
#include <memory>
21+
#include <string>
22+
#include <vector>
23+
2024
#include "rclcpp/rclcpp.hpp"
2125
#include "sensor_msgs/msg/image.hpp"
2226
#include "sensor_msgs/msg/imu.hpp"
2327
#include "std_msgs/msg/string.hpp"
2428
#include "message_diagnostics.hpp"
2529
#include "rclcpp/subscription_options.hpp"
2630

27-
using namespace std::chrono_literals;
31+
using std::chrono_literals::operator""ms;
2832

2933
class MinimalPublisher : public rclcpp::Node
3034
{

greenwave_monitor/src/greenwave_monitor.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,12 @@
1818
#include "greenwave_monitor.hpp"
1919

2020
#include <algorithm>
21-
#include "rosidl_typesupport_introspection_cpp/message_introspection.hpp"
2221
#include <cstring>
2322
#include <mutex>
2423
#include <unordered_map>
2524

25+
#include "rosidl_typesupport_introspection_cpp/message_introspection.hpp"
26+
2627
using namespace std::chrono_literals;
2728

2829
GreenwaveMonitor::GreenwaveMonitor(const rclcpp::NodeOptions & options)
@@ -227,7 +228,7 @@ bool GreenwaveMonitor::has_header_from_type(const std::string & type_name)
227228
{"std_msgs/msg/Float64", false},
228229
{"std_msgs/msg/Bool", false},
229230
{"std_msgs/msg/Empty", false},
230-
{"std_msgs/msg/Header", false}, // Header itself doesn't have a header
231+
{"std_msgs/msg/Header", false}, // Header itself doesn't have a header
231232

232233
// Common message types without headers
233234
{"geometry_msgs/msg/Twist", false},
@@ -326,7 +327,7 @@ GreenwaveMonitor::GetTimestampFromSerializedMessage(
326327
const std::string & type)
327328
{
328329
if (!has_header_from_type(type)) {
329-
return std::chrono::time_point<std::chrono::system_clock>(); // timestamp 0 as fallback
330+
return std::chrono::time_point<std::chrono::system_clock>(); // timestamp 0 as fallback
330331
}
331332

332333
int32_t timestamp_sec;

greenwave_monitor/test/test_message_diagnostics.cpp

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,12 @@ TEST_F(MessageDiagnosticsTest, FrameRateMsgTest)
6868
message_diagnostics::MessageDiagnostics message_diagnostics(
6969
*node_, "test_topic", message_diagnostics::MessageDiagnosticsConfig());
7070

71-
uint64_t timestamp = test_constants::kStartTimestampNs; // in nanoseconds
71+
uint64_t timestamp = test_constants::kStartTimestampNs; // in nanoseconds
7272
for (int i = 0; i < 1000; i++) {
7373
message_diagnostics.updateDiagnostics(timestamp);
74-
timestamp += 10000000; // 10 ms in nanoseconds
74+
timestamp += 10000000; // 10 ms in nanoseconds
7575
}
76-
EXPECT_EQ(message_diagnostics.getFrameRateMsg(), 100); // 100 Hz
76+
EXPECT_EQ(message_diagnostics.getFrameRateMsg(), 100); // 100 Hz
7777
}
7878

7979
TEST_F(MessageDiagnosticsTest, FrameRateNodeTest)
@@ -82,11 +82,12 @@ TEST_F(MessageDiagnosticsTest, FrameRateNodeTest)
8282
message_diagnostics::MessageDiagnostics message_diagnostics(
8383
*node_, "test_topic", message_diagnostics::MessageDiagnosticsConfig());
8484

85-
constexpr auto timestamp = test_constants::kStartTimestampNs; // dummy timestamp, not used for node time calculation
85+
// dummy timestamp, not used for node time calculation
86+
constexpr auto timestamp = test_constants::kStartTimestampNs;
8687
const auto start_time = std::chrono::high_resolution_clock::now();
8788

8889
constexpr int num_messages = 1000;
89-
constexpr int interarrival_time_ms = 10; // 100 hz
90+
constexpr int interarrival_time_ms = 10; // 100 hz
9091

9192
for (int i = 0; i < num_messages; i++) {
9293
message_diagnostics.updateDiagnostics(timestamp);
@@ -98,7 +99,8 @@ TEST_F(MessageDiagnosticsTest, FrameRateNodeTest)
9899

99100
const double expected_frame_rate = static_cast<double>(num_messages) / total_duration.count();
100101

101-
EXPECT_NEAR(message_diagnostics.getFrameRateNode(), expected_frame_rate, 2.0); // allow 2.0 Hz error
102+
// allow 2.0 Hz error
103+
EXPECT_NEAR(message_diagnostics.getFrameRateNode(), expected_frame_rate, 2.0);
102104
}
103105

104106
TEST_F(MessageDiagnosticsTest, MessageLatencyTest)
@@ -116,22 +118,24 @@ TEST_F(MessageDiagnosticsTest, MessageLatencyTest)
116118

117119
message_diagnostics.updateDiagnostics(msg_timestamp.nanoseconds());
118120

119-
EXPECT_NEAR(message_diagnostics.getLatency(), expected_latency_ms, 1.0); // allow 1 ms tolerance
121+
EXPECT_NEAR(message_diagnostics.getLatency(), expected_latency_ms, 1.0); // allow 1 ms tolerance
120122
}
121123

122124
TEST_F(MessageDiagnosticsTest, DiagnosticPublishSubscribeTest)
123125
{
124-
constexpr int input_frequency = 50; // 50 Hz
126+
constexpr int input_frequency = 50; // 50 Hz
127+
// 20 ms in nanoseconds
125128
const int64_t interarrival_time_ns = static_cast<int64_t>(
126-
::message_diagnostics::constants::kSecondsToNanoseconds / input_frequency); // 20 ms in nanoseconds
129+
::message_diagnostics::constants::kSecondsToNanoseconds / input_frequency);
127130

128131
// Initialize MessageDiagnostics with diagnostics enabled
129132
message_diagnostics::MessageDiagnosticsConfig config;
130133
config.enable_msg_time_diagnostics = true;
131134
config.enable_node_time_diagnostics = true;
132135
config.enable_increasing_msg_time_diagnostics = true;
136+
// in us
133137
config.expected_dt_us = interarrival_time_ns /
134-
::message_diagnostics::constants::kMicrosecondsToNanoseconds; // in us
138+
::message_diagnostics::constants::kMicrosecondsToNanoseconds;
135139

136140
message_diagnostics::MessageDiagnostics message_diagnostics(*node_, "test_topic", config);
137141

@@ -144,10 +148,12 @@ TEST_F(MessageDiagnosticsTest, DiagnosticPublishSubscribeTest)
144148
received_diagnostics.push_back(msg);
145149
});
146150

151+
// 50 ms delay
147152
constexpr int64_t delay_time_ns = 50 *
148153
static_cast<int64_t>(::message_diagnostics::constants::kMillisecondsToMicroseconds) *
149-
static_cast<int64_t>(::message_diagnostics::constants::kMicrosecondsToNanoseconds); // 50 ms delay
150-
auto msg_timestamp = test_constants::kStartTimestampNs; // Starting message timestamp in nanoseconds
154+
static_cast<int64_t>(::message_diagnostics::constants::kMicrosecondsToNanoseconds);
155+
// Starting message timestamp in nanoseconds
156+
auto msg_timestamp = test_constants::kStartTimestampNs;
151157

152158
int sent_count = 0;
153159
const auto start_time = std::chrono::high_resolution_clock::now();
@@ -170,7 +176,7 @@ TEST_F(MessageDiagnosticsTest, DiagnosticPublishSubscribeTest)
170176
}
171177
// Add a jitter by delaying at count 10
172178
if (sent_count == 10) {
173-
std::this_thread::sleep_for(std::chrono::nanoseconds(delay_time_ns)); // 50 ms delay
179+
std::this_thread::sleep_for(std::chrono::nanoseconds(delay_time_ns)); // 50 ms delay
174180
msg_timestamp += delay_time_ns;
175181
}
176182

greenwave_monitor_interfaces/CMakeLists.txt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
# SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES
2+
# Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
# SPDX-License-Identifier: Apache-2.0
17+
118
cmake_minimum_required(VERSION 3.8)
219
project(greenwave_monitor_interfaces)
320

greenwave_monitor_interfaces/package.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
33
<package format="3">
44
<name>greenwave_monitor_interfaces</name>
5-
<version>0.0.0</version>
5+
<version>0.1.0</version>
66
<description>Interfaces for the greenwave_monitor package</description>
7-
<maintainer email="[email protected]">user</maintainer>
7+
<maintainer email="[email protected]">Sean Gillen</maintainer>
88
<license>Apache-2.0</license>
99

1010
<buildtool_depend>ament_cmake</buildtool_depend>

0 commit comments

Comments
 (0)