class wpilib.Watchdog(self: wpilib.Watchdog, timeout: seconds, callback: Callable[], None]) → None

Bases: pybind11_builtins.pybind11_object

A class that’s a wrapper around a watchdog timer.

When the timer expires, a message is printed to the console and an optional user-provided callback is invoked.

The watchdog is initialized disabled, so the user needs to call Enable() before use.

Watchdog constructor.

  • timeout – The watchdog’s timeout in seconds with microsecond resolution.

  • callback – This function is called when the timeout expires.

addEpoch(self: wpilib.Watchdog, epochName: str) → None

Adds time since last epoch to the list printed by PrintEpochs().

Epochs are a way to partition the time elapsed so that when overruns occur, one can determine which parts of an operation consumed the most time.


epochName – The name to associate with the epoch.

disable(self: wpilib.Watchdog) → None

Disables the watchdog timer.

enable(self: wpilib.Watchdog) → None

Enables the watchdog timer.

getTime(self: wpilib.Watchdog) → float

Returns the time in seconds since the watchdog was last fed.

getTimeout(self: wpilib.Watchdog) → float

Returns the watchdog’s timeout in seconds.

isExpired(self: wpilib.Watchdog) → bool

Returns true if the watchdog timer has expired.

printEpochs(self: wpilib.Watchdog) → None

Prints list of epochs added so far and their times.

reset(self: wpilib.Watchdog) → None

Resets the watchdog timer.

This also enables the timer if it was previously disabled.

setTimeout(self: wpilib.Watchdog, timeout: seconds) → None

Sets the watchdog’s timeout.


timeout – The watchdog’s timeout in seconds with microsecond resolution.

suppressTimeoutMessage(self: wpilib.Watchdog, suppress: bool) → None

Enable or disable suppression of the generic timeout message.

This may be desirable if the user-provided callback already prints a more specific message.


suppress – Whether to suppress generic timeout message.