PurePursuitTask

open class PurePursuitTask : Task

Task for running Pure Pursuit paths using the BunyipsOpMode Task system. This task is internally used by the PurePursuit.PathMaker to run the path.

Note! Unlike the other drive tasks, this task does not automatically attach itself to a BunyipsSubsystem on construction, and needs to be done manually via the onSubsystem method, or can be omitted if there are no default tasks for the drive during execution (e.g. only action in Autonomous).

Author

Lucas Bubner, 2024

Since

5.1.0

Constructors

Link copied to clipboard
constructor(runner: PurePursuit, path: Path)
Create a new Pure Pursuit task to follow the given constructed path.
constructor(runner: PurePursuit, pathMaker: PurePursuit.PathMaker)
Create a new deferred Pure Pursuit task with a path to be constructed when this task is run.

Inherited properties

Link copied to clipboard
Link copied to clipboard

Timeout value for an infinite task that will run forever.

Link copied to clipboard
Get a reference to the currently running BunyipsOpMode.
Link copied to clipboard

Whether the task is finished or not via timeout or custom condition. Will be true regardless of the finisher being fired or not, as some tasks will handle this via finishNow().

Link copied to clipboard
open var timeout: Measure<Time>

Functions

Link copied to clipboard
protected open fun init()
Define code to run once, when the task is started.
Link copied to clipboard
protected open fun isTaskFinished(): Boolean
Return a boolean to this method to add custom criteria if a task should be considered finished.
Link copied to clipboard
protected open fun periodic()
To run as an active loop during this task's duration.

Inherited functions

Link copied to clipboard
fun after(otherTasks: Array<Task>): SequentialTaskGroup

Compose this task into a SequentialTaskGroup with the supplied tasks to run before this one.

Link copied to clipboard
fun during(otherTasks: Array<Task>): DeadlineTaskGroup

Compose this task into a DeadlineTaskGroup with the supplied tasks to run these extra tasks until this task is done.

Link copied to clipboard
fun finish()

Tell a task to finish on the next iteration.

Link copied to clipboard
fun finishNow()

Force a task to finish immediately, and fire the onFinish() method without waiting for the next polling loop. This method is useful when your task needs to die and needs to finish up immediately. If your finisher has already been fired, this method will do nothing but ensure that the task is marked as finished.

Link copied to clipboard

Time in seconds since the task was started.

Link copied to clipboard

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.

Link copied to clipboard

Return whether this task has elected a dependency on a subsystem or not.

Link copied to clipboard

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.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
protected open fun onFinish()

Finalising function to run once the task is finished. This will always run regardless of whether the task was ended because of an interrupt or the task naturally finishing. Override to add your own callback.

Link copied to clipboard
protected open fun onInterrupt()

Finalising function that will be called after onFinish in the event this task is finished via a call to finish or finishNow. Override to add your own callback.

Link copied to clipboard
protected open fun onReset()

Called when the task is resetting now. Override this method to add custom reset behaviour, such as resetting any internal state variables such as iterators or lists.

Link copied to clipboard
open fun onSubsystem(subsystem: BunyipsSubsystem, override: Boolean): Task

Set the subsystem you want to elect this task to run on, notifying the runner that this task should run there.

Link copied to clipboard
protected fun opMode(@NonNull ifRunning: Consumer<BunyipsOpMode>)
Null check consumer for the opMode field which will no-op the given consumer if an active BunyipsOpMode is not present (i.e.
Link copied to clipboard

Update and query the state of the task if it is finished. This will return true if the task is finished and the finisher has been fired.

Link copied to clipboard
fun race(otherTasks: Array<Task>): RaceTaskGroup

Compose this task into a RaceTaskGroup with the supplied tasks to run all of these tasks until one finishes.

Link copied to clipboard

Wrap this task in a RepeatTask where finish conditions are reset immediately.

Link copied to clipboard
protected fun require(@Nullable nullableOpMode: BunyipsOpMode): BunyipsOpMode
Null assertion for the opMode field which throws a NullPointerException if an active BunyipsOpMode is not present (i.e.
Link copied to clipboard
fun reset()

Reset a task to an uninitialised and unfinished state. Will no-op if the task is already fully reset.

Link copied to clipboard
abstract fun run()

fun run()

Should be called by your polling loop to run the task and manage all state properly.

Link copied to clipboard
fun then(otherTasks: Array<Task>): SequentialTaskGroup

Compose this task into a SequentialTaskGroup with the supplied tasks to follow after this one.

Link copied to clipboard

Get the name of this task. By default, it will be the class simple name, but you can call withName to set a custom name.

Link copied to clipboard

Get a verbose string representation of this task, including all of its properties.

Link copied to clipboard

Compose this task into a RaceTaskGroup with a WaitUntilTask based on this condition.

Link copied to clipboard
fun with(otherTasks: Array<Task>): ParallelTaskGroup

Compose this task into a ParallelTaskGroup with the supplied tasks to run all of these tasks at once.

Link copied to clipboard

Mute task reports from the Scheduler.

Link copied to clipboard
open fun withName(name: String): Task

Set the name of this task to be displayed in the OpMode. You may override this method if required to enforce a naming convention/prefix.

Link copied to clipboard
fun withTimeout(timeout: Measure<Time>): Task

Set the timeout of this task dynamically and return the task.