Class ShooterSuperstructure
This class is built around the foundation of a state machine, and has a defined list of states it can be in. This helps keep track of the different steps involved in shooting, which makes it a lot easier to tweak behavior and a lot harder to introduce weird bugs where things get into undefined states.
This class also has a concept of shooting sources. These provide target values for the shooter subsystems, and can be built to dynamically update, which aids in the development of things like shoot-from-anywhere functionality.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumThe list of states the shooter can be in. -
Constructor Summary
ConstructorsConstructorDescriptionShooterSuperstructure(Shooter shooter, Hood hood, Turret turret, HopperUptake hopperUptake, DigitalInput uptakeBeamBreak) Creates a new ShooterSuperstructure. -
Method Summary
Modifier and TypeMethodDescriptionGets the name of the current shooting source.getState()Gets the current state of the shooter state machine.Command to home the shooter.Trigger that returns true when ready to shoot.voidsetSource(ShootingSource source) Sets the shooting source to use.setSourceCommand(ShootingSource source) Sets the shooting source to the given source.setStateCommand(Supplier<ShooterValues> values) Sets the shooter state to the specified state.Command to start manual control of the shooter.Command to start shooting.Command to start shooting.booleanChecks if the subsystems are at their targets.booleanChecks if the subsystems need for shooting to pause.Command to turn off the shooter.voidupdate()Updates the shooter state depending on the current shooting source.
-
Constructor Details
-
ShooterSuperstructure
public ShooterSuperstructure(Shooter shooter, Hood hood, Turret turret, HopperUptake hopperUptake, DigitalInput uptakeBeamBreak) Creates a new ShooterSuperstructure.- Parameters:
shooter- The shooter to control.hood- The hood to control.turret- The turret to control.hopperUptake- The hopper/uptake subsystem to control.uptakeBeamBreak- The beam break for the uptake.
-
-
Method Details
-
update
public void update()Updates the shooter state depending on the current shooting source.The main purpose of this method is to handle transitions between different state machine states, as well as updating subsystem targets. Every time this method is run, it will check the current state of the superstructure, and, depending on the current state of the superstructure, the current value of the selected
ShootingSource, and feedback from subsystem sensors, this will update the subsystem targets and transition to different states. -
turnOffCommand
Command to turn off the shooter. This can be called from any state, and completely stops the shooter.Can be run while disabled.
- Returns:
- Command to run.
-
homeCommand
Command to home the shooter. This can be called from any state, and places the shooter back into automatic control.Can be run while disabled.
- Returns:
- Command to run.
-
startManualControlCommand
Command to start manual control of the shooter. This can be called from any state, and allows for controlling the shooter with the other commands.Can be run while disabled.
- Returns:
- Command to run.
-
startShootingCommand
Command to start shooting. This can only be called from theShooterSuperstructure.ShooterState.SHOOTING_STAGE_2_READY_TO_SHOOTstate.- Returns:
- Command to run.
-
startShootingWhenReadyCommand
Command to start shooting. This will wait until we enter theShooterSuperstructure.ShooterState.SHOOTING_STAGE_2_READY_TO_SHOOTstate to start shooting.Exits when exiting the
ShooterSuperstructure.ShooterState.SHOOTING_STAGE_3_SHOOTINGstate.- Returns:
- Command to run.
-
setStateCommand
Sets the shooter state to the specified state. This requires that you are inShooterSuperstructure.ShooterState.MANUAL_CONTROL.This assumes that we are not tracking a target, since that is done internally.
- Parameters:
values- Supplier for the values to set the shooter to.- Returns:
- Command to run.
-
setSourceCommand
Sets the shooting source to the given source. This can be called from any state.Can be run while disabled.
- Parameters:
source- The source to set.- Returns:
- Command to run.
-
readyToShootTrigger
Trigger that returns true when ready to shoot. Should be useful for triggering controller haptics.- Returns:
- Trigger, true when in
ShooterSuperstructure.ShooterState.SHOOTING_STAGE_2_READY_TO_SHOOT, false otherwise.
-
subsystemsAtTargets
public boolean subsystemsAtTargets()Checks if the subsystems are at their targets. This checks flywheel speed, hood position, turret position, and uptake speed.- Returns:
- Are all the shooter subsystems at their targets?
-
subsystemsNeedPause
public boolean subsystemsNeedPause()Checks if the subsystems need for shooting to pause. This checks if the turret is no longer at its target (we can assume other subsystems are close enough).- Returns:
- True if we need to pause shooting to wait for subsystems to catch up, false otherwise.
- API Note:
- This is intended for internal use, but is made public for logging purposes.
-
getState
Gets the current state of the shooter state machine. -
setSource
Sets the shooting source to use.This can be called at any time, and will immediately take over the current setting.
- Parameters:
source- Source to set.
-
getSourceName
Gets the name of the current shooting source.
-