Skip to content

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

DiagnosticsAPI(client: RSIClient)

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_stats() -> Dict[str, Any]

Get comprehensive network and performance statistics.

Returns:

Type Description
Dictionary with diagnostic information
- mean_cycle_time: Average cycle time in seconds
- std_cycle_time: Standard deviation (jitter)
- min_cycle_time: Minimum cycle time
- max_cycle_time: Maximum cycle time
- jitter: Cycle time variance (alias for std)
- packet_loss_rate: Packet loss percentage
- ipoc_gap_rate: IPOC gaps per 1000 cycles
- total_cycles: Total cycles recorded
- uptime: Time since start in seconds
- is_healthy: Overall health boolean
- warnings: List of warning messages
- watchdog_timeout: Whether watchdog timed out
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() -> Dict[str, float]

Get timing-specific metrics.

Returns:

Type Description
Dictionary with timing statistics
- mean_cycle_time: Average in seconds
- std_cycle_time: Standard deviation
- min_cycle_time: Minimum
- max_cycle_time: Maximum
- jitter: Variance (alias)
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() -> Dict[str, float]

Get network quality metrics.

Returns:

Type Description
Dictionary with network metrics
- packet_loss_rate: Percentage of lost packets
- ipoc_gap_rate: IPOC gaps per 1000 cycles
- total_cycles: Total communication cycles
Example

quality = api.diagnostics.get_network_quality() if quality['packet_loss_rate'] > 1.0: ... print("Warning: High packet loss!")

is_healthy

is_healthy() -> bool

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_warnings() -> List[str]

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_watchdog() -> bool

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_uptime() -> float

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_metrics() -> None

Reset all diagnostic metrics.

Note

This is not yet implemented. Metrics are automatically reset on reconnect().

format_stats

format_stats() -> str

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