Ironclad Best practices
Naming Conventions
- any code that is not auto generated should be written using camelCase.
- name things what they are.
Subsystem and Command Rules
- All hardware associated with a subsystem should be defined and initiated within the subsystem
- All hardware objects should be private (and final if applicable)
- Do not expose any hardware inside of public getters
public Cancoder getCancoder() {
return Cancoder
}
instead return information needed from the hardware
public Cancoder getCancoderPosition() {
return Cancoder.getPosition().getValueAsDouble();
}
- All commands that are not composite (command groups) should be written as inline commands inside the subsystem
- Do not expose any method that allows hardware such as motors to be controlled unless it is in a command. A
stop()method is the only exception to this rule
public void moveMotor() { //this is bad
...
}
public Command moveMotor() { //this is good
...
}
- Composit commands should be written inside of
RobotContaineror another command factory insideRobotContainer - Commands such as
goToPositionshould NOT have an end condition by default. This allows the user to set and end condition for different use cases i.e. auto vs teleop - Dont be afraid to run motors fast. speed is key
- Dont use excessive timeouts. Theres no need to run the motor for 5 seconds after a gamepiece is scored.
- Log everything. Use annotation logging and write custom loggers 3rd party classes.
- Expose Triggers for things that happen within your subsystem like sensors being tripped or motors reaching position.