Skip to content

Conversation

@mfaferek93
Copy link
Collaborator

@mfaferek93 mfaferek93 commented Dec 21, 2025

Pull Request

Closes #78

Summary

Add FaultReporter client library for easy fault reporting with local
filtering support.

New package ros2_medkit_fault_reporter provides:

  • FaultReporter class with simple API: report(fault_code, severity, description)
  • LocalFilter class for per-fault-code threshold/window filtering
  • Local filtering enabled by default (3 reports in 10s before forwarding)
  • High-severity faults (ERROR, CRITICAL) bypass filtering
  • Configuration via ROS parameters

Dependencies: rclcpp, ros2_medkit_msgs


Issue

Link the related issue (required):


Type

  • Bug fix
  • New feature or tests
  • Breaking change
  • Documentation only

Testing

How was this tested / how should reviewers verify it?


Checklist

  • Breaking changes are clearly described (and announced in docs / changelog if needed)
  • Tests were added or updated if needed
  • Docs were updated if behavior or public API changed

Copilot AI review requested due to automatic review settings December 21, 2025 16:38
@mfaferek93 mfaferek93 self-assigned this Dec 21, 2025
  Add FaultReporter client library for easy fault reporting with local
  filtering support.

  New package ros2_medkit_fault_reporter provides:
  - FaultReporter class with simple API: report(fault_code, severity, description)
  - LocalFilter class for per-fault-code threshold/window filtering
  - Local filtering enabled by default (3 reports in 10s before forwarding)
  - High-severity faults (ERROR, CRITICAL) bypass filtering
  - Configuration via ROS parameters

  Dependencies: rclcpp, ros2_medkit_msgs
@mfaferek93 mfaferek93 force-pushed the 78/feat/faultReporterLib branch from 078989a to 3a4d034 Compare December 21, 2025 16:40
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces a new ROS 2 client library package ros2_medkit_fault_reporter that provides a simple API for nodes to report faults to the central FaultManager with optional local filtering to reduce noise from repeated fault occurrences.

Key changes:

  • New FaultReporter class with report(fault_code, severity, description) API
  • LocalFilter class implementing threshold-based filtering within sliding time windows
  • Local filtering enabled by default (3 reports in 10s) with high-severity bypass
  • Comprehensive unit and integration tests
  • Full documentation including design diagrams and usage examples

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 15 comments.

Show a summary per file
File Description
src/ros2_medkit_fault_reporter/package.xml Package metadata defining dependencies on rclcpp and ros2_medkit_msgs
src/ros2_medkit_fault_reporter/CMakeLists.txt Build configuration for library, tests, and coverage support
src/ros2_medkit_fault_reporter/include/ros2_medkit_fault_reporter/fault_reporter.hpp Public API for FaultReporter class with documentation
src/ros2_medkit_fault_reporter/include/ros2_medkit_fault_reporter/local_filter.hpp LocalFilter class and FilterConfig struct definitions
src/ros2_medkit_fault_reporter/src/fault_reporter.cpp Implementation of FaultReporter with parameter loading and service calls
src/ros2_medkit_fault_reporter/src/local_filter.cpp Implementation of filtering logic with time-window tracking
src/ros2_medkit_fault_reporter/test/test_local_filter.cpp Unit tests for LocalFilter threshold and window behavior
src/ros2_medkit_fault_reporter/test/test_integration.test.py Integration tests verifying end-to-end fault reporting with FaultManager
src/ros2_medkit_fault_reporter/README.md Package-level documentation with usage examples and configuration
src/ros2_medkit_fault_reporter/design/index.rst Comprehensive design documentation with architecture diagrams
src/ros2_medkit_fault_reporter/design/architecture.puml PlantUML class diagram source

  Thread safety fixes:
  - Move mutex acquisition before reading config_ in should_forward()
  - Return FilterConfig by value with mutex lock in config() method

  Robustness improvements:
  - Use WARN level logging when service unavailable for high-severity faults
  - Add has_parameter() checks before declare_parameter() to prevent exceptions
  - Validate source_id in constructor (warn if empty)
  - Validate fault_code in report() (reject if empty)
  - Add validate_config() to ensure threshold >= 1 and window > 0

  Code quality:
  - Add documentation for FilterConfig struct fields
  - Optimize cleanup_expired() with fast path and std::lower_bound
  - Add explanatory comment for silent exception in test
@mfaferek93 mfaferek93 requested a review from bburda December 21, 2025 17:18
@bburda bburda merged commit 18e354b into main Dec 21, 2025
4 checks passed
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.

Create FaultReporter Client Library

3 participants