A key part of the logic file is a state machine. A state machine is a way to organize different tasks your subsystem needs to complete. For example if you were to make a state machine for an oven your states would be things like “off” “warming” “baking” “convection”. These are all different states the oven could be in. The state machine will be able to tell your robot what it should be doing and what it needs to do next by using states.
The biggest component of your state machine is your individual states. Each state is a way to bundle up a bunch of actions for your robot and generalize it under a task. For example our imaginary oven would have a state like “bake” this state would consist of turning on the convection fans and the heating elements. When the state “bake” is used it will tell the oven to do all these things.
To start writing your state machines you will need an enumerated class with the names of all of your states. This class will go inside of a companion object. For our imaginary oven subsystem that would look something like this.