Search in sources :

Example 1 with TaskTrajectory

use of me.wobblyyyy.pathfinder2.trajectory.TaskTrajectory in project Pathfinder2 by Wobblyyyy.

the class Pathfinder method task.

/**
 * Create a new {@link TaskTrajectory} and add it to Pathfinder's
 * queue so that it can be executed
 *
 * @param initial    code to be executed the first time the trajectory's
 *                   {@code #isDone(PointXYZ)} method is called.
 * @param during     code to be executed any time the trajectory's
 *                   {@code #isDone(PointXYZ)} method is called.
 * @param onFinish   code to be executed whenever the task is finished.
 * @param isFinished a supplier that indicates if the task is finished.
 *                   If the task is not finished, it should continue stop
 *                   its execution.
 * @param minTimeMs  the minimum time, in milliseconds, the trajectory
 *                   will be active for.
 * @param maxTimeMs  the maximum time, in milliseconds, the trajectory
 *                   will be active for.
 * @return {@code this}, used for method chaining.
 */
public Pathfinder task(Runnable initial, Runnable during, Runnable onFinish, Supplier<Boolean> isFinished, double minTimeMs, double maxTimeMs) {
    Trajectory trajectory = new TaskTrajectoryBuilder().setInitial(initial).setDuring(during).setOnFinish(onFinish).setIsFinished(isFinished).setMinTimeMs(minTimeMs).setMaxTimeMs(maxTimeMs).build();
    followTrajectory(trajectory);
    return this;
}
Also used : Trajectory(me.wobblyyyy.pathfinder2.trajectory.Trajectory) TaskTrajectory(me.wobblyyyy.pathfinder2.trajectory.TaskTrajectory) LinearTrajectory(me.wobblyyyy.pathfinder2.trajectory.LinearTrajectory) TaskTrajectoryBuilder(me.wobblyyyy.pathfinder2.trajectory.TaskTrajectoryBuilder)

Aggregations

LinearTrajectory (me.wobblyyyy.pathfinder2.trajectory.LinearTrajectory)1 TaskTrajectory (me.wobblyyyy.pathfinder2.trajectory.TaskTrajectory)1 TaskTrajectoryBuilder (me.wobblyyyy.pathfinder2.trajectory.TaskTrajectoryBuilder)1 Trajectory (me.wobblyyyy.pathfinder2.trajectory.Trajectory)1