Class Scheduler

  • All Implemented Interfaces:
    Sendable, AutoCloseable

    public final class Scheduler
    extends SendableBase
    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:
    • Method Detail

      • 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.

        command - the command 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.
      • initSendable

        public void initSendable​(SendableBuilder builder)
        Description copied from interface: Sendable
        Initializes this Sendable object.
        builder - sendable builder