TimedRobot

class wpilib.TimedRobot(*args, **kwargs)

Bases: IterativeRobotBase

TimedRobot implements the IterativeRobotBase robot program framework.

The TimedRobot class is intended to be subclassed by a user creating a robot program.

Periodic() functions from the base class are called on an interval by a Notifier instance.

Overloaded function.

  1. __init__(self: wpilib._wpilib.TimedRobot, period: wpimath.units.seconds = 0.02) -> None

Constructor for TimedRobot.

Parameters:

period – The period of the robot loop function.

  1. __init__(self: wpilib._wpilib.TimedRobot, frequency: wpimath.units.hertz) -> None

Constructor for TimedRobot.

Parameters:

frequency – The frequency of the robot loop function.

DEFAULT_PERIOD = 20.0
addPeriodic(callback: collections.abc.Callable[[], None], period: wpimath.units.seconds, offset: wpimath.units.seconds = 0.0) None

Add a callback to run at a specific period with a starting time offset.

This is scheduled on TimedRobot’s Notifier, so TimedRobot and the callback run synchronously. Interactions between them are thread-safe.

Parameters:
  • callback – The callback to run.

  • period – The period at which to run the callback.

  • offset – The offset from the common starting time. This is useful for scheduling a callback in a different timeslot relative to TimedRobot.

endCompetition() None

Ends the main loop in StartCompetition().

getLoopStartTime() wpimath.units.microseconds

Return the system clock time in microseconds for the start of the current periodic loop. This is in the same time base as Timer.GetMonotonicTimestamp(), but is stable through a loop. It is updated at the beginning of every periodic callback (including the normal periodic loop).

Returns:

Robot running time in microseconds, as of the start of the current periodic function.

startCompetition() None

Provide an alternate “main loop” via StartCompetition().