Diagnostics¶
Cycle timing, jitter, packet loss, watchdog and health checks on the UDP link.
Usage¶
stats = api.diagnostics.get_stats()
timing = api.diagnostics.get_timing() # cycle time, jitter
quality = api.diagnostics.get_network_quality() # packet loss, IPOC gaps
if not api.diagnostics.is_healthy():
for w in api.diagnostics.get_warnings():
print(f"Warning: {w}")
if api.diagnostics.check_watchdog():
api.reconnect()
print(api.diagnostics.format_stats())
# Network Diagnostics:
# Cycle Time: 4.01ms (+/-0.12ms jitter)
# Packet Loss: 0.05%
# ...
Reference¶
DiagnosticsAPI
¶
Network and performance diagnostics interface for KUKA RSI robot control.
Provides real-time access to: - Timing metrics (latency, jitter, cycle time) - Network quality monitoring (packet loss, IPOC gaps) - Watchdog timer status - Communication health checks
Initialize DiagnosticsAPI namespace.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
client
|
RSIClient
|
RSIClient instance with metrics_dict |
required |
get_stats
¶
Get comprehensive network and performance statistics.
Returns:
| Type | Description |
|---|---|
Dictionary with diagnostic information
|
|
Example
stats = api.diagnostics.get_stats() print(f"Jitter: {stats['jitter']*1000:.2f}ms") print(f"Packet loss: {stats['packet_loss_rate']:.2f}%")
get_timing
¶
Get timing-specific metrics.
Returns:
| Type | Description |
|---|---|
Dictionary with timing statistics
|
|
Example
timing = api.diagnostics.get_timing() print(f"Avg cycle: {timing['mean_cycle_time']1000:.2f}ms") print(f"Jitter: {timing['jitter']1000:.2f}ms")
get_network_quality
¶
Get network quality metrics.
Returns:
| Type | Description |
|---|---|
Dictionary with network metrics
|
|
Example
quality = api.diagnostics.get_network_quality() if quality['packet_loss_rate'] > 1.0: ... print("Warning: High packet loss!")
is_healthy
¶
Check overall system health.
Evaluates: - Jitter within acceptable limits (< 2ms) - Packet loss < 1% - No watchdog timeout - Client in RUNNING state
Returns:
| Type | Description |
|---|---|
bool
|
True if all health checks pass |
Example
if not api.diagnostics.is_healthy(): ... warnings = api.diagnostics.get_warnings() ... for w in warnings: ... print(f"Warning: {w}")
get_warnings
¶
Get current network health warnings.
Returns:
| Type | Description |
|---|---|
List[str]
|
List of warning messages (empty if healthy) |
Example
warnings = api.diagnostics.get_warnings() for warning in warnings: ... print(f"⚠️ {warning}")
check_watchdog
¶
Check if watchdog timer has triggered.
The watchdog detects communication loss when no packets are received for >1 second.
Returns:
| Type | Description |
|---|---|
bool
|
True if watchdog timeout detected |
Example
if api.diagnostics.check_watchdog(): ... print("Communication lost!") ... api.reconnect()
get_uptime
¶
Get network uptime in seconds.
Returns:
| Type | Description |
|---|---|
float
|
Seconds since network process started |
Example
uptime = api.diagnostics.get_uptime() hours = uptime / 3600 print(f"Uptime: {hours:.1f} hours")
reset_metrics
¶
Reset all diagnostic metrics.
Note
This is not yet implemented. Metrics are automatically reset on reconnect().
format_stats
¶
Format statistics as human-readable string.
Returns:
| Type | Description |
|---|---|
str
|
Formatted string with key metrics |
Example
print(api.diagnostics.format_stats()) Network Diagnostics: Cycle Time: 4.01ms (±0.12ms jitter) Packet Loss: 0.05% IPOC Gaps: 0.2 per 1000 cycles Uptime: 120.5s Health: ✅ Healthy