Subsystem
Default Commands
Continuously executing until Interrupt
setDefaultCommand(new ExampleGroup());
Relation To Robot
Subsystems can be compared to mechanisms that use the same overall resources
Realize that two actions that require the same subsystem cannot occur at the same time
Dependencies
These prevent two different commands from utilizing the same resources on the robot
Dependencies are created by
requires(Robot.exampleSubsystem);
Commands
Initialization
Initialization occurs when a command is run for the first time
This means that if a command is stopped and then run again the init() method will run twice
Execution
The execute method inside of a command is must be concise and must not bog down the system or the entire robot may stop
This means that large loops and wait methods should not be inside of an execute command
Interrupts
Called to stop a command from running
Specifically when robot is disabled or a dependency overlaps
Connection With Buttons
Commands can be easily mapped to buttons through the OI class
Manually Starting Commands
In order to manually start commands, create a new command object and run the start() method on the new command object
This may be very important when programming the autonomous robot
ExampleCommand cmd = new ExampleCommand()
...
cmd.start();
Input Class
Input Devices
Input devices are mapped through joystick and button objects
Joystick js0 = new Joystick(0);
Button btn00 = new JoystickButton(js0, 0);
Button Actions
Commands can be mapped to buttons or triggers in the OI class
btn00.whileHeld(new Command());
Robot Map
Ports
This class centralizes port numbers and connection numbers for robot-wide use
public final static int DEFAULT_MOTOR = 2;
Command Groups
About
Command Groups are used for command sequencing and parallelization
Basically running things in a specific order or at the same time
Think about automated actions
Commands will add in order of methods to add them
Parallel
Runs one command in the command group after the other without the need for an end command.
addParallel(new Command1());
Ending Parallel
When an end() method is run in a parallel command group, the ended command is removed from the group until the next instance of the command is run.
Sequential
Runs one command in the command group after the other with the need for an end() command before moving to the next command.
addSequential(new Command1());
Scheduling Commands "How To"
Scheduling commands is a important process of running the robot that can easily get out of hand. There are three main types of commands that should be run at any time and some of them may require their own subsystem. These types of commands include Continuously Run Commands, Human Run Commands, and perhaps most importantly Program Run Commands. Continuously Run Commands like reading sensors, determining the state of a subsystem or running hardware constantly (ex. pneumatic compressors) should be run using the default command method.Human Run Commands are scheduled from the OI Class through the use of buttons and triggers, however command logic should not be placed in the OI class. Command logic should be either be placed in the command or through subsystem states.
For more notes, see ​Introduction to Command-Based Programming.