Skip to content

What are Actions

Actions is a concept from RoadRunner, another library for FTC

Actions help you define simple behaviors that are easy to combine into large routines.

Actions encapsulate all logic that controls your Robot. They can be found in three main places:

Actions have three stages of logic:

  1. Initial logic: Runs once when the Action is triggered
  2. Loop logic: Runs continuously until the Action is complete
  3. Cleanup logic: Runs once after the loop has completed
fun enable(target: Double = targetVelocity): Action = action {
init {
// Runs once when the Action is triggered
setVelocity(target)
}
loop {
// Runs continuously until the Action is complete
// Has implicit access to a TelemetryPacket providing the put function:
put("Left flywheel velocity", leftMotor.velocity)
put("Right flywheel velocity", rightMotor.velocity)
isAtSpeed // Returns true when the Action is complete
}
cleanup {
// Runs once after the loop has completed
// Not needed in this instance
}
}

The VoltActionBuilder can be used to build new actions from existing actions:

fun rampUp(target: Double = targetVelocity): Action = voltAction {
+enable(target / 4) // Enables at 1/4 of target
+enable(target / 2) // After reaching 1/4 of target, enables at 1/2 of target
+enable(target) // After reaching 1/2 of target, enables at target
}