2026-01-10 16:52:43 -07:00
|
|
|
package frc4388.robot.subsystems.shooter;
|
|
|
|
|
|
2026-02-09 17:18:54 -08:00
|
|
|
import static edu.wpi.first.units.Units.Rotation;
|
|
|
|
|
import static edu.wpi.first.units.Units.Rotations;
|
|
|
|
|
import static edu.wpi.first.units.Units.RotationsPerSecond;
|
|
|
|
|
|
2026-01-10 16:52:43 -07:00
|
|
|
import java.util.function.Supplier;
|
|
|
|
|
|
|
|
|
|
import org.littletonrobotics.junction.Logger;
|
|
|
|
|
|
|
|
|
|
import edu.wpi.first.math.geometry.Pose2d;
|
|
|
|
|
import edu.wpi.first.units.measure.Angle;
|
|
|
|
|
import edu.wpi.first.wpilibj2.command.SubsystemBase;
|
2026-01-29 18:07:19 -07:00
|
|
|
import frc4388.robot.subsystems.intake.IntakeConstants;
|
|
|
|
|
import frc4388.robot.subsystems.shooter.ShooterIO.ShooterState;
|
2026-01-10 16:52:43 -07:00
|
|
|
|
|
|
|
|
public class Shooter extends SubsystemBase {
|
2026-02-09 17:18:54 -08:00
|
|
|
public ShooterIO io;
|
2026-01-10 16:52:43 -07:00
|
|
|
ShooterStateAutoLogged state = new ShooterStateAutoLogged();
|
|
|
|
|
|
2026-02-07 14:51:05 -07:00
|
|
|
// Supplier<Pose2d> m_swervePoseSupplier;
|
2026-01-10 16:52:43 -07:00
|
|
|
|
2026-01-29 18:07:19 -07:00
|
|
|
|
2026-01-10 16:52:43 -07:00
|
|
|
public Shooter(
|
2026-02-07 14:51:05 -07:00
|
|
|
ShooterIO io
|
|
|
|
|
// Supplier<Pose2d> swervePoseSupplier
|
2026-01-10 16:52:43 -07:00
|
|
|
) {
|
|
|
|
|
this.io = io;
|
2026-02-07 14:51:05 -07:00
|
|
|
// this.m_swervePoseSupplier = swervePoseSupplier;
|
2026-01-10 16:52:43 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setMode(ShooterMode mode) {
|
|
|
|
|
switch (mode) {
|
|
|
|
|
case Active:
|
2026-02-09 17:18:54 -08:00
|
|
|
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()));
|
2026-01-29 18:07:19 -07:00
|
|
|
break;
|
|
|
|
|
case Resting:
|
2026-02-09 17:18:54 -08:00
|
|
|
io.setShooterVelocity(state, RotationsPerSecond.of(ShooterConstants.SHOOTER_RESTING_VELOCITY.get()));
|
|
|
|
|
// io.setMotor2Velocity(state, ShooterConstants.SHOOTER_RESTING_VELOCITY);
|
|
|
|
|
io.setIndexerVelocity(state, RotationsPerSecond.of(ShooterConstants.INDEXER_INACTIVE_VELOCITY.get()));
|
2026-01-29 18:07:19 -07:00
|
|
|
break;
|
|
|
|
|
case Inactive:
|
2026-02-09 17:18:54 -08:00
|
|
|
io.setShooterVelocity(state, RotationsPerSecond.of(ShooterConstants.SHOOTER_RESTING_VELOCITY.get()));
|
|
|
|
|
// io.setMotor2Velocity(state, ShooterConstants.SHOOTER_RESTING_VELOCITY);
|
|
|
|
|
io.setIndexerVelocity(state, RotationsPerSecond.of(ShooterConstants.INDEXER_INACTIVE_VELOCITY.get()));
|
2026-01-29 18:07:19 -07:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-10 16:52:43 -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
|
|
|
|
2026-01-10 16:52:43 -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();
|
2026-01-10 16:52:43 -07:00
|
|
|
|
|
|
|
|
io.updateInputs(state);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|