Intro - GrissomRobotics/InfiniteRecharge GitHub Wiki
Code Introduction
This repository uses Java to program an FRC robot. Most code that we care about is under src/main/java/frc/robot
and generally uses the WPILib framework to interact with elements on the robot.
Useful links
- Intro to VS Code
- Running commands in VS Code
- Building and deploying code to robot
- Viewing robot debug output
- Introduction to Git (or just talk to Justin)
- Command-based programming (this is how we use WPILib to organize each component of the robot)
High-level code description
Main.java
- Boiler-plate code for building project. Can be ignored.
OI.java
- Custom uses of the controller inputs
Robot.java
- Instantiates each mode, e.g., teleop and autonomous.
- Sets up cameras for teleop
RobotMap.java
- Instantiates sensors/subsystems
- Maps joystick controls
commandGroups
- Each code file in this directory contains sequences of commands to use during autonomous mode
commands
- Each code file in this directory specifies one "operation" of the robot, e.g.,
DriveWithJoystick.java
,SpinCellIn.java
- Commands use access to a
subsystem
(see below) to make the robot do things, as opposed to directly accessing a motor, which is part of a subsystem
- Each code file in this directory specifies one "operation" of the robot, e.g.,
custom
- Code "classes" made by our group that do special things we needed our robot to do that weren't in the WPILib code
- E.g.,
Ramper.java
limits the acceleration of a command sent to a motor
- E.g.,
- Code "classes" made by our group that do special things we needed our robot to do that weren't in the WPILib code
subsystems
- Each subsystem is a collection of hardware (e.g., motors) that does a thing as a unit, e.g.,
Belt.java
orDriveSubsystem.java
- Each subsystem is a collection of hardware (e.g., motors) that does a thing as a unit, e.g.,
FAQ
So how does the robot know what to do when I press a button on the remote control? Examples:
Belt
This one is a bit convoluted...
belt
subsystem is instantiated here after being imported here so it can be used in this Java file- The "default command" for the
belt
subsystem is set here to be theManualBelt
command. Note that theoi
object is passed in toManualBelt
- The
oi
object is instantiated here - The "default command" is what gets run if the subsystem is not otherwise being commanded
- The
ManualBelt
declares what its primary functionality is in theexecute
function- The
belt
subsystem knows which motor to actuate in itsturnBelt
function because it is defined here
Color sensor
This one is much simpler...