public class Scheduler extends SendableBase implements Sendable
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.
Command
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. |
void |
initSendable(SendableBuilder builder)
Initializes this
Sendable object. |
void |
removeAll()
Removes all commands.
|
void |
run()
Runs a single iteration of the loop.
|
addChild, free, getName, getSubsystem, setName, setName, setName, setSubsystem
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getName, getSubsystem, setName, setName, setSubsystem
public static Scheduler getInstance()
Scheduler
, creating it if one does not exist.Scheduler
public void add(Command command)
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 addpublic void addButton(Trigger.ButtonScheduler button)
button
- the button to addpublic void run()
Command
system. The loop has five stages:
public void removeAll()
public void disable()
public void enable()
public void initSendable(SendableBuilder builder)
Sendable
Sendable
object.initSendable
in interface Sendable
builder
- sendable builder