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 in Volt
Section titled “Actions in Volt”Actions encapsulate all logic that controls your Robot. They can be found in three main places:
Actions have three stages of logic:
- Initial logic: Runs once when the
Actionis triggered - Loop logic: Runs continuously until the
Actionis complete - 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}