Skip to content

Instantly share code, notes, and snippets.

@smoser
Created January 25, 2022 20:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save smoser/087e0d924bf5b249d2362eeb4549392f to your computer and use it in GitHub Desktop.
Save smoser/087e0d924bf5b249d2362eeb4549392f to your computer and use it in GitHub Desktop.
frc code layout doc

A command based architecture is one of the designs that FRC suggests (see the TimedRobot here and command based here).

CommandScheduler.java -- I don't think we need to touch this class, but it is at the core of a command-based design; commands may specify which subsystems they interact with, and the scheduler will never schedule more than one command requiring a given subsystem at a time.

RobotCointainer.java -- define/create subsystem and command fields/objects, bind controller buttons to commands, and specify commands for autonomous routine.

SubsytemsBase.java -- a base class that subsystem classes inherit (e.g., drive subsytem, launcher subsystem etc); commands are associated with subsystems; the CommandScheduler is already setup to not run two commands associated with the same subsystem at the same time (i.e., the scheduler checks "requirements" for the command using the command's subsystem)

CommandBase.java -- a base class command classes inherit; a command could be driveForward (for example); each command should have four methods implemented: initialize(), execute(), isFinished(), and end().

There is also a SequentialCommandGroup base class and a ParallelCommandGroup base class that allows you to create Command groups. This way commands can be bite-sized things that the robot can do (which, in theory can be reused in many different combos or forms), and the command groups can perform a set of commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment