Commands

WPILib provides a “Command-Based” way of programming the robot. With this approach we define commands with the conditions under which the command runs, the action to be taken and the subsystem(s) required for the command. The alternative is to create our own state machine logic that is monitoring all of the operator and sensor inputs and then deciding which commands should be started or stopped for each iteration. With Command-Based code, we just need to define the commands and the command schedule runs behind the scenes and takes care of the rest. See the WPILib references for more details on this approach.

There are many different structures of commands that can be used for different circumstances:

There are also different ways to define commands in the code:

In addition to individual commands, there are also command compositions that can pull together sequences, parallel actions or any combination.

References:

WPILib What Is “Command-Based” Programming?:
https://docs.wpilib.org/en/stable/docs/software/commandbased/what-is-command-based.html