Scheduler

class wpilib.command.Scheduler[source]

Bases: wpilib.Sendable

The Scheduler is a singleton which holds the top-level running commands. It is in charge of both calling the command’s run() method and to make sure that there are no two commands with conflicting requirements running.

It is fine if teams wish to take control of the Scheduler themselves, all that needs to be done is to call Scheduler.getInstance().run() often to have Commands function correctly. However, this is already done for you if you use the CommandBased Robot template.

See also

Command

Instantiates a Scheduler.

add(command)[source]

Adds the command to the Scheduler. This will not add the Command immediately, but will instead wait for the proper time in the run() loop before doing so. The command returns immediately and does nothing if given null.

Adding a Command to the Scheduler involves the Scheduler removing any Command which has shared requirements.

Parameters:command – the command to add
addButton(button)[source]

Adds a button to the Scheduler. The Scheduler will poll the button during its run().

Parameters:button – the button to add
disable()[source]

Disable the command scheduler.

enable()[source]

Enable the command scheduler.

static getInstance()[source]

Returns the Scheduler, creating it if one does not exist.

Returns:the Scheduler
getName()[source]
getType()[source]
registerSubsystem(system)[source]

Registers a Subsystem to this Scheduler, so that the Scheduler might know if a default Command needs to be run. All Subsystem objects should call this.

Parameters:system – the system
remove(command)[source]

Removes the Command from the Scheduler.

Parameters:command – the command to remove
removeAll()[source]

Removes all commands

run()[source]

Runs a single iteration of the loop. This method should be called often in order to have a functioning Command system. The loop has five stages:

  • Poll the Buttons
  • Execute/Remove the Commands
  • Send values to SmartDashboard
  • Add Commands
  • Add Defaults