Unify timestamp checks and fix headerless FPS checks#31
Unify timestamp checks and fix headerless FPS checks#31sgillen merged 14 commits intoNVIDIA-ISAAC-ROS:mainfrom
Conversation
Signed-off-by: Blake McHale <bmchale@nvidia.com>
Signed-off-by: Blake McHale <bmchale@nvidia.com>
Greptile SummaryThis PR unifies timestamp-check logic into a shared Two logic issues were found:
Confidence Score: 3/5
Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[GreenwaveDiagnostics constructor] --> B[applyTimeCheckPreset]
B --> C{time_check_preset}
C -->|HeaderOnly| D["node_ts.enabled=false\nnode_ts.check_fps_jitter=false\nmsg_ts.enabled=true\nmsg_ts.check_fps_jitter=true\nmsg_ts.check_increasing=true"]
C -->|NodetimeOnly| E["node_ts.enabled=true\nnode_ts.check_fps_window=true\nnode_ts.check_increasing=true\nmsg_ts.enabled=false"]
C -->|HeaderWithFallback| F{"has_msg_timestamp?"}
F -->|yes| G["node_ts.enabled=true\nnode_ts.check_increasing=true\nmsg_ts.enabled=true\nmsg_ts.check_fps_jitter=true\nmsg_ts.check_increasing=true"]
F -->|no| H["node_ts.enabled=true\nnode_ts.check_fps_window=true\nnode_ts.check_increasing=true\nmsg_ts.enabled=false"]
C -->|None| I[No flags changed]
D --> J[setExpectedDt called]
E --> J
G --> J
H --> J
I --> J
J --> K["⚠️ node_ts.enabled=true\nmsg_ts.enabled=true\n(overrides preset!)"]
K --> L[updateDiagnostics]
L --> M[updateTimeSource node_ts]
L --> N{has_msg_timestamp?}
N -->|yes| O[updateTimeSource msg_ts]
M --> P{node_ts.enabled?}
P -->|yes| Q[checkFpsJitter\ncheckFpsWindow\ncheckIncreasing]
Q --> R{check_fps_jitter?}
R -->|no| S["⚠️ addJitter called\noutlier_count increments\nbut returns false"]
R -->|yes| T[may return ERROR]
P -->|no| U[update prev_ts only]
Last reviewed commit: c26f657 |
Signed-off-by: Blake McHale <bmchale@nvidia.com>
Signed-off-by: Blake McHale <bmchale@nvidia.com>
Signed-off-by: Blake McHale <bmchale@nvidia.com>
Signed-off-by: Blake McHale <bmchale@nvidia.com>
Signed-off-by: Blake McHale <bmchale@nvidia.com>
Signed-off-by: Blake McHale <bmchale@nvidia.com>
Signed-off-by: Blake McHale <bmchale@nvidia.com>
Additional Comments (2)
This is the common startup path: A fix would be to track a separate void setExpectedDt(double expected_hz, double tolerance_percent)
{
const std::lock_guard<std::mutex> lock(greenwave_diagnostics_mutex_);
// Only enable sources that the preset allows, instead of force-enabling both.
node_source_.enabled = diagnostics_config_.enable_node_time_diagnostics;
msg_source_.enabled = diagnostics_config_.enable_msg_time_diagnostics;
...
}
void clearExpectedDt()
{
const std::lock_guard<std::mutex> lock(greenwave_diagnostics_mutex_);
node_source_.enabled = diagnostics_config_.enable_node_time_diagnostics;
msg_source_.enabled = diagnostics_config_.enable_msg_time_diagnostics;
...
}
The format string has 6 should be: Or more simply drop to four format args: with |
- Add Timestamp sources doc section explaining header vs node time and latency - Move applyTimeCheckPreset to be a member method of GreenwaveDiagnosticsConfig - Rename TimeSourceState -> TimeSeriesState - Rename node_source_/msg_source_ -> node_ts_series_/msg_ts_series_ - Ignore .claude/ directory Signed-off-by: Blake McHale <bmchale@nvidia.com> Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Additional Comments (3)
The fix is to save the preset's intent for each series and restore it in // Option A: re-enable only series that have at least one check configured
node_ts_series_.enabled =
node_ts_series_.check_fps_jitter ||
node_ts_series_.check_fps_window ||
node_ts_series_.check_increasing;
msg_ts_series_.enabled =
msg_ts_series_.check_fps_jitter ||
msg_ts_series_.check_fps_window ||
msg_ts_series_.check_increasing;Correspondingly,
This means that whenever a time series is If the intent is to collect jitter statistics unconditionally and only gate error reporting via if (!source.check_fps_jitter) {
return false;
}
const int64_t diff_us = timestamp_diff_us - diagnostics_config_.expected_dt_us;
const int64_t abs_jitter_us = std::abs(diff_us);
const bool missed_deadline =
source.window.addJitter(abs_jitter_us, diagnostics_config_.jitter_tolerance_us);
That is technically correct, but the structure makes it look like the default appears twice. A cleaner approach avoids repeating it: (No change in arguments — just noting the message text so a future reader isn't confused by the apparent duplication.) Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time! |
Fixes #18 . Also migrates the time check logic to one shared class configured with flags. This unifies logic between node and message time allowing for them to both verify similar failure cases. The current checks that can be enabled are:
Alongside the new checks there is a ROS parameter
gw_time_check_preset. This parameter accepts presetsHeaderWithFallback,HeaderOnly,NodeOnly, andNone. TheHeaderWithFallbackconfigures the tests to use message time when a message timestamp exists and node time when it does not.Nonedoes not change the configuration and allows the user to fully specify the checks they want to be enabled. The*Onlypresets enable flags specifically for Header or Node time.