Prerequisite: Simulation
Robot functions are broken into subsystems. Each subsystem represents a distinct robot mechanism. Subsystems vary based on the game objectives, but they typically include:
In programing, subsystems serve as abstractions to encapsulate system information and behavior such as:
Within WPILib, there is a Command Scheduler that orchestrates when actions are performed by the subsystems. Commands will be covered in a separate section.
Create a subsysyem by following these steps:
1) Open project you created in Simulation section
1) Right-click on subsystems directory and select “Create a new class/commnad”
1) Select Subsystem from the menu and type in a name for the subsystem (e.g. “Arm”) and press enter
1) Add a print statement to the periodic method
1) Create an instance variable for the new subsystem. Note, you need to import the subsystem, hover over the class name and from the Quick Fix… menu select “Import {classname}”
1) In the constructor of RobotContainer, instantiate the Subsystem
1) Simulate the robot code and observe the print statements
Reference: docs