Package frc.robot.subsystems
Class MARSShooter
java.lang.Object
edu.wpi.first.wpilibj2.command.SubsystemBase
frc.robot.subsystems.MARSShooter
- All Implemented Interfaces:
SystemTestable,edu.wpi.first.util.sendable.Sendable,edu.wpi.first.wpilibj2.command.Subsystem
public class MARSShooter
extends edu.wpi.first.wpilibj2.command.SubsystemBase
implements SystemTestable
Generic flywheel subsystem used for the main shooter, floor intake, and feeder.
Despite its name, this class is a general-purpose velocity-controlled flywheel wrapper. In
RobotContainer, three separate instances are created:
shooter— the main scoring flywheel (4-motor, high-velocity)floorIntake— ground pickup rollersfeeder— internal transfer mechanism
Each instance accepts a FlywheelIO implementation via dependency injection, allowing
seamless switching between real hardware (FlywheelIOTalonFX) and physics simulation
(FlywheelIOSim).
-
Constructor Summary
ConstructorsConstructorDescriptionMARSShooter(String name, FlywheelIO io, MARSPowerManager powerManager) Constructs the shooter subsystem. -
Method Summary
Modifier and TypeMethodDescriptionedu.wpi.first.wpilibj2.command.CommandGenerates an autonomous, state-machine style verification routine for this subsystem.doubleGets the current velocity of the shooter flywheel.booleanReturns whether the flywheel velocity is within 20 rad/s of the target.voidperiodic()voidsetClosedLoopVelocity(double speed) Runs the flywheel at a target velocity using the motor's internal closed-loop controller and dynamically injects the calculated feedforward voltage.voidsetVoltage(double volts) Directly sets the shooter motor voltage.edu.wpi.first.wpilibj2.command.CommandReturns a command that continuously spins the flywheel at the default scoring velocity.edu.wpi.first.wpilibj2.command.CommandsysIdDynamic(edu.wpi.first.wpilibj2.command.sysid.SysIdRoutine.Direction direction) Generates a SysId Dynamic characterization command.edu.wpi.first.wpilibj2.command.CommandsysIdQuasistatic(edu.wpi.first.wpilibj2.command.sysid.SysIdRoutine.Direction direction) Generates a SysId Quasistatic characterization command.Methods inherited from class edu.wpi.first.wpilibj2.command.SubsystemBase
addChild, getName, getSubsystem, initSendable, setName, setSubsystemMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface edu.wpi.first.wpilibj2.command.Subsystem
defer, getCurrentCommand, getDefaultCommand, idle, register, removeDefaultCommand, run, runEnd, runOnce, setDefaultCommand, simulationPeriodic, startEnd, startRun
-
Constructor Details
-
MARSShooter
Constructs the shooter subsystem.- Parameters:
name- The unique identifier for this flywheel instance (e.g., Shooter, FloorIntake, Feeder)io- The hardware abstraction layer for the shooter flywheel motor.powerManager- The active power manager for load-shedding voltage queries.
-
-
Method Details
-
periodic
public void periodic()- Specified by:
periodicin interfaceedu.wpi.first.wpilibj2.command.Subsystem
-
spinUpCommand
public edu.wpi.first.wpilibj2.command.Command spinUpCommand()Returns a command that continuously spins the flywheel at the default scoring velocity.- Returns:
- A
Commandthat runs the flywheel at ~400 rad/s using closed-loop control.
-
setVoltage
public void setVoltage(double volts) Directly sets the shooter motor voltage. Used for open-loop manual control.- Parameters:
volts- The voltage to apply.
-
setClosedLoopVelocity
public void setClosedLoopVelocity(double speed) Runs the flywheel at a target velocity using the motor's internal closed-loop controller and dynamically injects the calculated feedforward voltage.- Parameters:
speed- Target velocity in radians per second.
-
isAtTolerance
public boolean isAtTolerance()Returns whether the flywheel velocity is within 20 rad/s of the target.- Returns:
trueif the flywheel is at the commanded velocity within tolerance.
-
sysIdQuasistatic
public edu.wpi.first.wpilibj2.command.Command sysIdQuasistatic(edu.wpi.first.wpilibj2.command.sysid.SysIdRoutine.Direction direction) Generates a SysId Quasistatic characterization command.- Parameters:
direction- The direction of the quasistatic routine (Forward/Reverse).- Returns:
- The SysId Command to execute.
-
sysIdDynamic
public edu.wpi.first.wpilibj2.command.Command sysIdDynamic(edu.wpi.first.wpilibj2.command.sysid.SysIdRoutine.Direction direction) Generates a SysId Dynamic characterization command.- Parameters:
direction- The direction of the dynamic routine (Forward/Reverse).- Returns:
- The SysId Command to execute.
-
getVelocityRadPerSec
public double getVelocityRadPerSec()Gets the current velocity of the shooter flywheel.- Returns:
- Velocity in radians per second.
-
getSystemCheckCommand
public edu.wpi.first.wpilibj2.command.Command getSystemCheckCommand()Description copied from interface:SystemTestableGenerates an autonomous, state-machine style verification routine for this subsystem.- Specified by:
getSystemCheckCommandin interfaceSystemTestable- Returns:
- A command that runs through diagnostic checks and logs results.
-