Package edu.wpi.first.wpilibj.command
Class Scheduler
- java.lang.Object
-
- edu.wpi.first.wpilibj.command.Scheduler
-
- All Implemented Interfaces:
Sendable,AutoCloseable
public final class Scheduler extends Object implements Sendable, AutoCloseable
TheScheduleris a singleton which holds the top-level running commands. It is in charge of both calling the command'srun()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
Schedulerthemselves, all that needs to be done is to callScheduler.getInstance().run()often to haveCommandsfunction 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 Description voidadd(Command command)Adds the command to theScheduler.voidaddButton(Trigger.ButtonScheduler button)Adds a button to theScheduler.voidclose()voiddisable()Disable the command scheduler.voidenable()Enable the command scheduler.static SchedulergetInstance()Returns theScheduler, creating it if one does not exist.voidinitSendable(SendableBuilder builder)Initializes thisSendableobject.voidremoveAll()Removes all commands.voidrun()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
-
Methods inherited from interface edu.wpi.first.wpilibj.Sendable
addChild, getName, getSubsystem, setName, setName, setName, setName, setSubsystem
-
-
-
-
Method Detail
-
getInstance
public static Scheduler getInstance()
Returns theScheduler, creating it if one does not exist.- Returns:
- the
Scheduler
-
close
public void close()
- Specified by:
closein interfaceAutoCloseable
-
add
public void add(Command command)
Adds the command to theScheduler. This will not add theCommandimmediately, but will instead wait for the proper time in therun()loop before doing so. The command returns immediately and does nothing if given null.Adding a
Commandto theSchedulerinvolves theSchedulerremoving anyCommandwhich has shared requirements.- Parameters:
command- the command to add
-
addButton
public void addButton(Trigger.ButtonScheduler button)
- 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 functioningCommandsystem. The loop has five stages:- Poll the Buttons
- Execute/Remove the Commands
- Send values to SmartDashboard
- Add Commands
- 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:SendableInitializes thisSendableobject.- Specified by:
initSendablein interfaceSendable- Parameters:
builder- sendable builder
-
-