Package choreo.auto
Class AutoRoutine
java.lang.Object
choreo.auto.AutoRoutine
An object that represents an autonomous routine.
This loop is used to handle autonomous trigger logic and schedule commands. This loop should **not** be shared across multiple autonomous routines.
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionprotected boolean
A boolean utilized inrunning()
to resolve truenessprotected boolean
A boolean that is true when the loop is killedprotected final EventLoop
The underlyingEventLoop
that triggers are bound to and polledprotected final String
The name of the auto routine this loop is associated withprotected int
The amount of times the routine has been polled -
Constructor Summary
ModifierConstructorDescriptionAutoRoutine
(String name) Creates a new loop with a specific nameprotected
AutoRoutine
(String name, EventLoop loop) A constructor to be used when inhereting this class to instantiate a custom inner loop -
Method Summary
Modifier and TypeMethodDescriptioncmd()
Creates a command that will poll this event loop and reset it when it is cancelled.cmd
(BooleanSupplier finishCondition) Creates a command that will poll this event loop and reset it when it is finished or canceled.void
kill()
Kills the loop and prevents it from running again.loop()
Gets the event loop that this routine is using.void
poll()
Polls the routine.void
reset()
Resets the routine.running()
Returns aTrigger
that is true while this autonomous routine is being polled.
-
Field Details
-
loop
The underlyingEventLoop
that triggers are bound to and polled -
name
The name of the auto routine this loop is associated with -
isActive
A boolean utilized inrunning()
to resolve trueness -
isKilled
A boolean that is true when the loop is killed -
pollCount
The amount of times the routine has been polled
-
-
Constructor Details
-
AutoRoutine
Creates a new loop with a specific name- Parameters:
name
- The name of the loop- See Also:
-
AutoRoutine
A constructor to be used when inhereting this class to instantiate a custom inner loop- Parameters:
name
- The name of the looploop
- The innerEventLoop
-
-
Method Details
-
running
Returns aTrigger
that is true while this autonomous routine is being polled.Using a
Trigger.onFalse(Command)
will do nothing as when this is false the routine is not being polled anymore.- Returns:
- A
Trigger
that is true while this autonomous routine is being polled.
-
poll
Polls the routine. Should be called in the autonomous periodic method. -
loop
Gets the event loop that this routine is using.- Returns:
- The event loop that this routine is using.
-
reset
Resets the routine. This can either be called on auto init or auto end to reset the routine incase you run it again. If this is called on a routine that doesn't need to be reset it will do nothing. -
kill
Kills the loop and prevents it from running again. -
cmd
Creates a command that will poll this event loop and reset it when it is cancelled.- Returns:
- A command that will poll this event loop and reset it when it is cancelled.
- See Also:
-
cmd
Creates a command that will poll this event loop and reset it when it is finished or canceled.- Parameters:
finishCondition
- A condition that will finish the loop when it is true.- Returns:
- A command that will poll this event loop and reset it when it is finished or canceled.
- See Also:
-