Task
A task, or command is an action that can be performed by a robot. This has been designed to reflect closely the command-based programming style used in FRC, while still being reflective of the past nature of how the Task system was implemented in BunyipsLib.
The task system in BunyipsLib has been constructed from the ground-up with a more lightweight ecosystem where Tasks are at their core stripped into running some code for some time, somewhere. The original behaviour of tasks running outright used to be the legacy roots of how Tasks worked, and since has adopted some command-based structures that work by running them in the contexts of other subsystems.
Task extends BunyipsComponent to allow for simpler integration with accessing the OpMode, and was a legacy feature that was kept for the sake of simplicity, more pedantic exception handling, and ease of use.
As of 6.0.0, the Task system now implements the Action interface for seamless compatibility with RoadRunner v1.0.0. The ActionTask may be used to convert a pure Action into a task, however, writing a task directly using a Task is encouraged for more control and flexibility, due to there being no downsides to doing so and the exposure of the same accessors. Additional changes have also been made to allow for simpler construction of tasks, and the introduction of a new DynamicTask class to allow for more flexible task construction.
Author
Lucas Bubner, 2024
Since
1.0.0-pre
Inheritors
Properties
Get the subsystem reference that this task has elected a dependency on. Will return an Optional where if it is not present, this task is not dependent on any subsystem.
Convenience field to get a reference to FtcDashboard's field overlay for drawing on the field. Available as soon as init has been called for this task.
Query (but not update) the finished state of the task. This will return true if the task is finished and the finisher has been fired.
Whether this task should override other tasks in the queue if they conflict with this task. Will only apply if this task has a dependency to run on (see dependency).
Inherited properties
Get a reference to the currently running BunyipsOpMode.
Functions
Composes a WaitTask to run before this task.
Compose this task into a SequentialTaskGroup with the supplied task to run before this one.
Implicitly run a SequentialTaskGroup with this supplied Runnable, queued to run before this task starts.
Compose this task into a SequentialTaskGroup with the supplied tasks to run before this one.
Compose this task into a DeadlineTaskGroup with the supplied task to run alongside this one until this task is done.
Compose this task into a DeadlineTaskGroup with the supplied tasks to run these extra tasks until this task is done.
Composes a ParallelTaskGroup with a WaitTask to run before this task. This will ensure the task runs for at least the specified time, and no-ops until the duration if it finishes early.
Return a boolean to this method to add custom criteria if a task should be considered finished.
Set the subsystem you want to elect this task to run on, notifying the runner that this task should run there. This task is scheduled with default override behaviour (where this task is not priority).
Set the subsystem you want to elect this task to run on, notifying the runner that this task should run there.
Compose this task into a RaceTaskGroup with the supplied task to run alongside this one until one finishes.
Compose this task into a RaceTaskGroup with the supplied tasks to run all of these tasks until one finishes.
Wrap this task in a RepeatTask where finish conditions are reset immediately.
Compose this task into a SequentialTaskGroup with the supplied task to follow after this one.
Implicitly run a SequentialTaskGroup with this supplied Runnable, queued to run when this task finishes.
Compose this task into a SequentialTaskGroup with the supplied tasks to follow after this one.
Get a verbose string representation of this task, including all of its properties.
Compose this task into a RaceTaskGroup with a wait condition based on this condition.
Compose this task into a ParallelTaskGroup with the supplied task to run alongside this one.
Compose this task into a ParallelTaskGroup with the supplied tasks to run all of these tasks at once.
Inherited functions
Null check consumer for the opMode field which will no-op the given consumer if an active BunyipsOpMode is not present (i.e. the opMode field is null). This method is the same to the BunyipsOpMode.ifRunning
method, and is supplied here for convenience.
Null assertion for the opMode field which throws a NullPointerException if an active BunyipsOpMode is not present (i.e. the supplied field is null). This method replicates Objects.requireNonNull
but has a built-in message to alert the user of a non-active OpMode.