Generate a new project using the WPILib VSCode Extension
Click Ctrl+Shift+P and type "WPILib: Create New Project"
Choose a template, java project, in the Command Robot Style
After creating this project, navigate to the src/main/java/frc/robot folder
This is where all of the robot code will be stored
In this project there are 6 main types of files: Main, Robot, Subsystem, Command, Container, and Constants
Main
Main starts the robot code. This file should almost never be edited.
Robot
Robot is where the robot is initialized. In this there are some helpful methods that will be used to run the code. These methods are run during certain times in the match. For example, the method robotInit() is run when the robot is turned on.
Subsystems
Subsystems are where the code for the different parts of the robot are stored. For example, the code for the drive train is stored in the DriveTrain subsystem. These subsystems should be lower level methods, for example controlling a motor would be done in a subsystem, but passing in a joystick command to that motor would be done in a command. Subsystems should only be initialized once.
Subsystems have a built in method named periodic that runs whenever the robot is running. You should NEVER run a motor in this method.
Commands
Commands are used to control subsystems. They have a couple of built in helpful methods
Execute is run whenever the command is running. This is where you should run the motors.
Initialize is run when the command is first started. This is where you should reset the subsystems.
End is run when the command is finished. This is where you should stop the motors.
isFinished is run to check if the command is finished. This is where you should check if the command is done. When creating a command, you should edit this method to return true when the command is finished.
Robot Container
Robot Container is where subsystems, commands, and joysticks should be initialized. It is also where the commands are bound to the buttons on the joystick.
Constants
Constants are values that do not change throughout the code. CAN ID numbers should be stored in constants, as well as gear rations, etc.