Team 2606's 2404 FRC robot code for Crescendo. Crescendo's code is written in Java and is based off of WPILib's Java control system.
The code is divided into several packages, each responsible for a different aspect of the robot function. This README explains setup instructions, the function of each package, and some of the variable naming conventions used. Additional information about each specific class can be found in that class' Java file.
- Clone this repo
- Run
./gradlewto download gradle and needed FRC libraries - Run
./gradlew tasksto see available build options - Enjoy!
- Run
./gradlew buildto build the code. Use the--infoflag for more details - Run
./gradlew deploy -PteamNumber=2606to deploy to the robot in Terminal (Mac) or Powershell (Windows)
| Subsystem | Controller | Name | ID | PDP |
|---|---|---|---|---|
| Drivetrain | SparkMax | LeftFront | 1 | |
| Drivetrain | SparkMax | RightFront | 2 | |
| Drivetrain | SparkMax | LeftRear | 3 | |
| Drivetrain | SparkMax | RightRear | 4 | |
| Intake | TalonSRX | Intake | 5 | |
| Shooter | SparkMax | ShooterTop | 6 | |
| Shooter | SparkMax | ShooterBottom | 7 | |
| Arm | TalonSRX | ArmMotor | 8 | |
| Lift | TalonSRX | LiftMotor | 9 |
-
Building with Gradle
Instead of working with Ant, we used GradleRIO, which is a powerful Gradle plugin that allows us to build and deploy our code for FRC. It automatically fetches WPILib, CTRE Toolsuite, and other libraries, and is easier to use across different IDEs.
-
frc.robot
Contains the robot's central functions and holds a file with all numerical constants used throughout the code. For example, the
Robotclass controls all routines depending on the robot state. -
frc.robot.subsystems
Subsystems are consolidated into one central class per subsystem, all of which extend the Subsystem abstract class. Each subsystem uses state machines for control. Each subsystem is also a singleton, meaning that there is only one instance of each. To modify a subsystem, one would get the instance of the subsystem and change its state. The
Subsystemclass will work on setting the desired state. -
frc.robot.commands
Commands define the operation of the robot incorporating the capabilities defined in the subsystems. Commands are subclasses of
CommandorCommandGroup. Commands run when scheduled or in response to buttons being pressed or virtual buttons from theSmartDashboard.
- c*** (i.e.
cAutonomous): Command instance variables - k*** (i.e.
kDriveWheelTrackWidthInches): Final constants, especially those found in the Constants.java file - m*** (i.e.
mIsHighGear): Private instance variables - s*** (i.e.
sDrivetrain): Subsystems variables, especially those found in Robot.java file
- Start by setting
IandDto 0. - Increase
Puntil the system starts oscillating for a period ofTu. You want the oscillation to be large enough that you can time it. This maximumPwill be referred to asKu. - Use the chart below to calculate different
P,I, andDvalues.
| Control Types | P | I | D |
|---|---|---|---|
| P | .5*Ku |
0 | 0 |
| PI | .45*Ku |
.54*Ku/Tu |
0 |
| PID | .6*Ku |
1.2*Ku/Tu |
3*Ku*Tu/40 |
Should have a postfix 0 (i.e. 0.1 not .1)