Skip to content

sim2bot.RobotState.latency

latency: Optional[float] property

Return the current telemetry age in seconds.

Returns:

  • Optional[float]

    Seconds since browser capture, or None when the packet did not

  • Optional[float]

    include a capture timestamp.


Practical examples

Examples use objects discovered from the current scene rather than hard-coded robot metadata.

Print telemetry age

state = sim.state()
if state and state.latency is not None:
    print(f"{state.latency * 1000:.1f} ms")

Reject stale state

if state is None or state.latency is None or state.latency > 0.25:
    raise RuntimeError("Telemetry is stale")

Guidance

Important behavior

Latency is an observed wall-clock age, not a deterministic control-cycle guarantee.


See also