step.watchdog¶
Watchdog DSL steps — arm, feed, and disarm named keepalive watchdogs.
Watchdogs are registered with the robot’s WatchdogManager and, on
expiry, cancel the main-mission task. This triggers the normal shutdown
path: background tasks drain, the shutdown mission runs, then the process
exits.
Feeding is between-step only. Long-running steps should not attempt to
feed from inside their own update loop — use timeout(...) for
per-step stall detection instead.
Example:
from raccoon.step import seq, start_watchdog, feed_watchdog, stop_watchdog
from raccoon.step.motion import drive_forward
seq(
start_watchdog("scoring", timeout=5.0),
drive_forward(30),
feed_watchdog("scoring"),
drive_forward(30),
stop_watchdog("scoring"),
)
Attributes¶
Classes¶
Arm a named watchdog with a timeout. |
|
Reset a named watchdog's deadline. |
|
Disarm and remove a named watchdog. |
Functions¶
|
Arm a named watchdog that will kill the robot if not fed in time. |
|
Reset a named watchdog's deadline to prevent expiry. |
|
Disarm a named watchdog so it no longer expires. |
Module Contents¶
- step.watchdog.DEFAULT_WATCHDOG_NAME = 'default'¶
- class step.watchdog.StartWatchdog(name: str, timeout: float | int)¶
Bases:
step.StepArm a named watchdog with a timeout.
- step.watchdog.start_watchdog(name: str = DEFAULT_WATCHDOG_NAME, timeout: float | int = 5.0) StartWatchdog¶
Arm a named watchdog that will kill the robot if not fed in time.
Registers a keepalive watchdog with the robot’s
WatchdogManager. If the watchdog is not fed viafeed_watchdogbeforetimeoutseconds elapse, it expires and cancels the main-mission task — the same code path used by the globalshutdown_intimer. The shutdown mission still runs, so motors are hard-stopped and the robot parks safely.Multiple watchdogs can run simultaneously by using distinct names. The default name covers the common single-watchdog case.
- Parameters:
name – Unique identifier for this watchdog. Used by
feed_watchdogandstop_watchdogto address it. Defaults to"default".timeout – Seconds between feeds before expiry. Must be positive.
- Returns:
A StartWatchdog step instance.
Example:
from raccoon.step import seq, start_watchdog, feed_watchdog, stop_watchdog from raccoon.step.motion import drive_forward seq( start_watchdog("scoring", timeout=5.0), drive_forward(30), feed_watchdog("scoring"), drive_forward(30), stop_watchdog("scoring"), )
- step.watchdog.feed_watchdog(name: str = DEFAULT_WATCHDOG_NAME) FeedWatchdog¶
Reset a named watchdog’s deadline to prevent expiry.
Pushes the watchdog’s deadline forward by its full timeout. Feeding an unarmed watchdog logs a warning but does not raise.
- Parameters:
name – Identifier of the watchdog to feed. Defaults to
"default".- Returns:
A FeedWatchdog step instance.
Example:
from raccoon.step import feed_watchdog feed_watchdog("scoring")
- step.watchdog.stop_watchdog(name: str = DEFAULT_WATCHDOG_NAME) StopWatchdog¶
Disarm a named watchdog so it no longer expires.
Removes the watchdog from the manager. Stopping an unarmed watchdog logs a warning but does not raise — intended for cleanup paths where the watchdog may or may not still be active.
- Parameters:
name – Identifier of the watchdog to disarm. Defaults to
"default".- Returns:
A StopWatchdog step instance.
Example:
from raccoon.step import stop_watchdog stop_watchdog("scoring")