Class RepeatTask

java.lang.Object
com.cdarobotics.cdalib.tasks.Task
com.cdarobotics.cdalib.tasks.RepeatTask

public class RepeatTask extends Task
Repeatedly runs a freshly built task: each time the current task finishes, a new one is built from the supplier and started immediately.

Warning: this task has no termination condition of its own — run() always returns false. To stop it, compose it with a bounding task via Task.raceWith(Task...) or Task.withDeadline(Task).

  • Constructor Details

    • RepeatTask

      public RepeatTask(Supplier<Task> taskSupplier)
      Parameters:
      taskSupplier - builds a fresh task each time the previous one finishes.
  • Method Details

    • init

      public void init()
      Description copied from class: Task
      Called once before the first Task.run(). Set up state and issue starting commands here.
      Specified by:
      init in class Task
    • run

      public boolean run()
      When the current inner task finishes, builds and starts a new one.
      Specified by:
      run in class Task
      Returns:
      always false; this task never finishes on its own.
    • toString

      @NonNull public String toString()
      Specified by:
      toString in class Task