Your logic file will be the brains of the operation, the man in the chair for your subsystem. It’s going to receive and interpret requests from superstructure and translate those requests into action.

Lets quickly discuss the semantics of creating a logic file. Your logic file will be a class named after your subsystem. It will be a class that is constructed in the init of RobotContainer and accepts an io interface as a value in its constructor. The class should inhert from ControlledByStateMachine which is a custom superclass designed to ensure that all classes controlled by our state machine contain a loop method called onLoop().

Below is an example of how you may write the class for your logic file

class NathanAregaGlazer1000(val io: AregaGlazer) : ControlledByStateMachine("NathanAregaGlazer"){}
// Constructed in RobotContainer like this: 
// init {NathanAregaLover = NathanAregaGlazer1000(NathanAregaGlazerIOTalon)}
// Notice how I pass in an instance of the IO class not the class iteslf 
//this is why your IO talon must be an object and not a class

Now into the actual writing of the file, a couple of things about structure. You shouldn’t be including constant values in your logic file, as they should all be included in the associated constants file for your subsystem. Any other variables that you create should be declared and implemented if applicable at the top of your file. Common variables found at the top of logic files are ones like isHomed or position & voltage Target variables.

Small Tangent here but it’s crucial that we take time to understand custom getters & setters in kotlin. A custom getter will allow you to define your own custom logic for a variable to decide what value should be returned. Similarly a custom setter will use custom logic to figure out what a variable should be set to based on a passed in value. These override the default get and set methods that each property(variable) in kotlin automatically has.

var doWELoveNathan : Boolean= true //create & set property
var x = doWELoveNathan //call the default getter and put that value in variable x
doWELoveNathan = false //call default setter and set the value

Now lets take a look at a