Skip to content

Delays ​

In NextFTC there are two types of delays.

Delay ​

A Delay is a command that waits a certain amount of time before finishing.

A Delay takes a Duration from kotlin.time to determine how long it waits for. Alternatively, it can take a Double in seconds.

kotlin
// it can take a Duration:
Delay(5.seconds)
Delay(500.milliseconds)

// or a time in seconds, as a Double
Delay(5.0)

WaitUntil ​

WaitUntil evaluates a check every loop and ends when it returns true.

kotlin
WaitUntil { false } // never ends

Delay Utilities ​

There are a few utilities that help you write common delays more easily.

endAfter ​

endAfter returns a ParallelRaceGroup with the command and a Delay. This causes the command to have a maximum time it can be before it ends.

kotlin
// All are equivalent
command.endAfter(2.seconds)
command.endAfter(2000.milliseconds)
command.endAfter(2.0)
ParallelRaceGroup(
    command,
    Delay(2.seconds)
)

afterTime ​

afterTime returns a SequentialGroup with a Delay and then the command. This causes the command to wait a certain amount of time before starting.

kotlin
// All are equivalent
command.afterTime(2.seconds)
command.afterTime(2000.milliseconds)
command.afterTime(2.0)
SequentialGroup(
    Delay(2.seconds),
    command
)

thenWait ​

thenWait is like afterTime, but the opposite! thenWait returns a SequentialGroup with the command and then a Delay.

kotlin
// All are equivalent
command.thenWait(2.seconds)
command.thenWait(2000.milliseconds)
command.thenWait(2.0)
SequentialGroup(
    command,
    Delay(2.seconds)
)