edu.wpi.first.wpilibj.command

## Class Scheduler

- java.lang.Object
- - edu.wpi.first.wpilibj.command.Scheduler

- All Implemented Interfaces:
    NamedSendable, Sendable

      public class Scheduler
      extends java.lang.Object
      implements NamedSendable

  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`

- - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `add(Command command)` Adds the command to the `Scheduler`.
    `void` | `addButton(Trigger.ButtonScheduler button)` Adds a button to the `Scheduler`.
    `void` | `disable()` Disable the command scheduler.
    `void` | `enable()` Enable the command scheduler.
    `static Scheduler` | `getInstance()` Returns the `Scheduler`, creating it if one does not exist.
    `java.lang.String` | `getName()` The name of the subtable.
    `java.lang.String` | `getSmartDashboardType()` The string representation of the named data type that will be used by the smart dashboard for this `Sendable`.
    `java.lang.String` | `getType()`
    `void` | `initTable(NetworkTable subtable)` Initializes a table for this `Sendable` object.
    `void` | `removeAll()` Removes all commands.
    `void` | `run()` Runs a single iteration of the loop.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### getInstance

          public static Scheduler getInstance()

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

    - #### add

          public void add(Command command)

      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

          public void addButton(Trigger.ButtonScheduler button)

      Adds a button to the `Scheduler`. The `Scheduler` will poll the button during its `run()`.
      Parameters:
        `button` - the button to add

    - #### run

          public void run()

      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:
      1. Poll the Buttons
      2. Execute/Remove the Commands
      3. Send values to SmartDashboard
      4. Add Commands
      5. Add Defaults

    - #### removeAll

          public void removeAll()

      Removes all commands.

    - #### disable

          public void disable()

      Disable the command scheduler.

    - #### enable

          public void enable()

      Enable the command scheduler.

    - #### getName

          public java.lang.String getName()

      Description copied from interface: `NamedSendable`
      The name of the subtable.
      Specified by:
        `getName` in interface `NamedSendable`
      Returns:
        the name of the subtable of SmartDashboard that the Sendable object will use.

    - #### getType

          public java.lang.String getType()

    - #### initTable

          public void initTable(NetworkTable subtable)

      Description copied from interface: `Sendable`
      Initializes a table for this `Sendable` object.
      Specified by:
        `initTable` in interface `Sendable`
      Parameters:
        `subtable` - The table to put the values in.

    - #### getSmartDashboardType

          public java.lang.String getSmartDashboardType()

      Description copied from interface: `Sendable`
      The string representation of the named data type that will be used by the smart dashboard for this `Sendable`.
      Specified by:
        `getSmartDashboardType` in interface `Sendable`
      Returns:
        The type of this `Sendable`.