Clear, robust subsystem behavior comes from well-structured state machines. Use this guide to design, implement, and debug yours effectively.
A state machine is a way to organize the different tasks your subsystem needs to complete. For an oven, example states might be "Off", "Warming", "Baking", or "Convection". The state machine tells the robot what it should be doing now and what it should do next.
A state bundles the actions your robot should take for a specific mode of operation.
fun periodic() to run your state machine.currentState and compute nextState each cycle.Logger.recordOutput("Subsystem/State", currentState).when (currentState) block.This is a function that will go inside of your companion object along with your enum of states. It will take a “Request” which is created by your superstructure and set your current state to that request. See example code below for how to write this.
Start with a minimal, reliable set and expand as needed.