Package com.cdarobotics.cdalib.tasks
Class Task
java.lang.Object
com.cdarobotics.cdalib.tasks.Task
- Direct Known Subclasses:
BasicTask,DeadlineTask,DeferredTask,FollowPathTask,HoldPointTask,InstantTask,NullTask,ParallelTask,RaceTask,RepeatTask,SequentialTask,SleepTask,WaitUntilTask
Base type for all actions in the task framework. A task is initialized once via
init(),
then run() is polled every loop until it returns true to signal completion.
Tasks compose into larger behaviors through the fluent builders:
andThen(Task...)— run this task, then the given tasks in sequencealongWith(Task...)— run this task in parallel with the given tasks; finishes when all finishraceWith(Task...)— run this task in parallel with the given tasks; finishes when any one finisheswithDeadline(Task)— run this task until the given deadline task finishes
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionRuns this task in parallel with the given tasks, finishing once all of them finish.Runs this task, then the given tasks one after another.abstract voidinit()Called once before the firstrun().Runs this task in parallel with the given tasks, finishing as soon as any one finishes.abstract booleanrun()Called every loop afterinit().abstract StringtoString()withDeadline(Task deadline) Runs this task untildeadlinefinishes, then stops regardless of this task's state.
-
Constructor Details
-
Task
public Task()
-
-
Method Details
-
init
public abstract void init()Called once before the firstrun(). Set up state and issue starting commands here. -
run
public abstract boolean run()Called every loop afterinit().- Returns:
truewhen the task is finished,falseto keep running.
-
toString
-
andThen
Runs this task, then the given tasks one after another. -
alongWith
Runs this task in parallel with the given tasks, finishing once all of them finish. -
raceWith
Runs this task in parallel with the given tasks, finishing as soon as any one finishes. -
withDeadline
Runs this task untildeadlinefinishes, then stops regardless of this task's state.
-