Files
2026KPopRobotHunters/src/main/java/frc4388/robot/subsystems/shooter/Shooter.java
T

91 lines
2.6 KiB
Java
Raw Normal View History

package frc4388.robot.subsystems.shooter;
2026-02-09 17:18:54 -08:00
import static edu.wpi.first.units.Units.RotationsPerSecond;
import org.littletonrobotics.junction.Logger;
import edu.wpi.first.math.geometry.Pose2d;
import edu.wpi.first.wpilibj2.command.SubsystemBase;
public class Shooter extends SubsystemBase {
2026-02-09 17:18:54 -08:00
public ShooterIO io;
ShooterStateAutoLogged state = new ShooterStateAutoLogged();
2026-02-07 14:51:05 -07:00
// Supplier<Pose2d> m_swervePoseSupplier;
2026-01-29 18:07:19 -07:00
public Shooter(
2026-02-07 14:51:05 -07:00
ShooterIO io
// Supplier<Pose2d> swervePoseSupplier
) {
this.io = io;
2026-02-07 14:51:05 -07:00
// this.m_swervePoseSupplier = swervePoseSupplier;
}
public enum FieldZone {
// The robot should aim at the hub
InShootZone,
// The robot should aim towards the wall
AimAtWall,
}
2026-01-29 18:07:19 -07:00
public enum ShooterMode {
//Shooter is at speed it fires balls
Active,
//Shooter is at a resting velocity
Resting,
//Shooter is inactive (Off)
Inactive,
}
2026-02-10 17:33:39 -08:00
private ShooterMode mode = ShooterMode.Inactive;
2026-02-09 18:38:55 -08:00
2026-01-29 18:07:19 -07:00
public void setMode(ShooterMode mode) {
2026-02-10 17:33:39 -08:00
this.mode = mode;
2026-01-29 18:07:19 -07:00
}
// Calculate what should be done based off of the position of the robot
// TODO: Implement field zones
public FieldZone getTarget(Pose2d position) {
return FieldZone.InShootZone;
}
2026-01-29 18:07:19 -07:00
@Override
public void periodic() {
// FaultReporter.register(this); // TODO Implement fault reporter
Logger.processInputs("Shooter", state);
2026-02-07 14:51:05 -07:00
// Pose2d pose = m_swervePoseSupplier.get();
// Angle robotRot = pose.getRotation().getMeasure();
io.updateInputs(state);
2026-02-10 17:33:39 -08:00
switch (mode) {
case Active:
io.setShooterVelocity(state, RotationsPerSecond.of(ShooterConstants.SHOOTER_ACTIVE_VELOCITY.get()));
// io.setMotor2Velocity(state, ShooterConstants.SHOOTER_ACTIVE_VELOCITY);
io.setIndexerVelocity(state, RotationsPerSecond.of(ShooterConstants.INDEXER_ACTIVE_VELOCITY.get()));
break;
case Resting:
io.setShooterVelocity(state, RotationsPerSecond.of(ShooterConstants.SHOOTER_RESTING_VELOCITY.get()));
// io.setMotor2Velocity(state, ShooterConstants.SHOOTER_RESTING_VELOCITY);
io.setIndexerVelocity(state, RotationsPerSecond.of(0));
break;
case Inactive:
io.setShooterVelocity(state, RotationsPerSecond.of(0));
// io.setMotor2Velocity(state, ShooterConstants.SHOOTER_RESTING_VELOCITY);
io.setIndexerVelocity(state, RotationsPerSecond.of(0));
break;
}
}
}