de15793c37
2 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
| 6e8ea2e43f |
Implement Phase 2: Network Reliability and Diagnostics
Major improvements to network monitoring, timing instrumentation, and
diagnostic capabilities for production-grade RSI communication.
New Features:
- Real-time timing metrics (latency, jitter, cycle time tracking)
- IPOC gap detection and packet loss monitoring
- Watchdog timer for communication loss detection
- Comprehensive network health checks
- Fully functional DiagnosticsAPI namespace
timing_metrics.py (NEW):
- TimingMetrics class tracks cycle times, IPOC gaps, packet loss
- NetworkQualityMonitor calculates health scores
- Watchdog timer detects communication timeouts (>1s)
- Statistical analysis: mean, std dev, min, max, percentiles
- Configurable thresholds for jitter, packet loss, cycle time
network_handler.py:
- Integrated TimingMetrics into NetworkProcess
- Records cycle timing and IPOC for every communication cycle
- Updates shared metrics_dict every 100 cycles (~400ms)
- Detects watchdog timeout on socket timeout
- Zero performance impact on real-time loop
rsi_client.py:
- Created shared metrics_dict using Manager
- Passes metrics_dict to NetworkProcess
- Resets metrics on reconnect()
diagnostics_api.py:
- Fully implemented (no longer placeholder)
- get_stats() - comprehensive diagnostics
- get_timing() - timing-specific metrics
- get_network_quality() - packet loss and IPOC gaps
- is_healthy() - overall health check
- get_warnings() - list of current warnings
- check_watchdog() - watchdog timer status
- format_stats() - human-readable diagnostics output
Example Usage:
>>> api = RSIAPI('RSI_EthernetConfig.xml')
>>> api.start()
>>> # After some communication
>>> stats = api.diagnostics.get_stats()
>>> print(f"Jitter: {stats['jitter']*1000:.2f}ms")
>>> print(f"Packet loss: {stats['packet_loss_rate']:.2f}%")
>>> print(api.diagnostics.format_stats())
Benefits:
- Real-time performance monitoring
- Automatic problem detection (jitter, packet loss, timeout)
- Production-ready diagnostics
- Foundation for 24-hour stability testing
- Publication-quality performance metrics
Phase 2 Progress: 75% complete
Remaining: Auto-reconnection, 24-hour stability test
|
|||
| 50e6df9719 |
Implement Phase 1 & Phase 5: Code quality improvements and namespaced API architecture
Major refactoring to improve code quality, maintainability, and API organization for publication-quality research software. Phase 1 - Code Quality Foundation: - Add comprehensive type hints across all core modules (500+ annotations) - Create custom exception hierarchy with 20+ specialized exceptions - Replace all print() statements with proper logging (debug, info, warning, error, critical) - Enhance all docstrings with Args/Returns/Raises sections - Improve error handling with exception chaining Modified core modules: - rsi_client.py: State machine with typed exceptions, full type hints - network_handler.py: CSV logging and UDP communication with typed interfaces - config_parser.py: XML parsing with proper exception handling - safety_manager.py: Safety validation with typed limits - __init__.py: Clean exports for all public APIs Phase 5 - Namespaced API Architecture: - Restructure RSIAPI as orchestrator providing 9 specialized namespaces - Create clean separation of concerns with dedicated API classes New namespace APIs: - motion_api.py: Motion control (Cartesian, joints, trajectories) - io_api.py: Digital I/O control - krl_api.py: KRL program manipulation utilities - safety_api.py: Safety management and limits - monitoring_api.py: Live data access and monitoring - logging_api.py: CSV data logging - diagnostics_api.py: Network diagnostics (Phase 2 placeholder) - viz_api.py: Static and live visualization - tools_api.py: Utilities, debugging, inspection Breaking Changes: - No backward compatibility - clean slate API design - Old: api.start_rsi() → New: api.start() - Old: api.update_cartesian(...) → New: api.motion.update_cartesian(...) - See migration guide in PHASE_5_SUMMARY.md Benefits: - Organized and discoverable API structure - Scalable architecture for future enhancements - Type-safe with full IDE autocomplete support - Easier testing and maintenance - Professional industry-standard design pattern Files changed: 6 modified, 9 new (net -37 lines, improved organization) |