-
Notifications
You must be signed in to change notification settings - Fork 2
feat(#78): add ros2_medkit_fault_reporter client library #92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
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
078989a to
3a4d034
Compare
There was a problem hiding this 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 |
src/ros2_medkit_fault_reporter/include/ros2_medkit_fault_reporter/local_filter.hpp
Outdated
Show resolved
Hide resolved
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
Pull Request
Closes #78
Summary
Add FaultReporter client library for easy fault reporting with local
filtering support.
New package ros2_medkit_fault_reporter provides:
Dependencies: rclcpp, ros2_medkit_msgs
Issue
Link the related issue (required):
Type
Testing
How was this tested / how should reviewers verify it?
Checklist