2026-01-27 18:16:23 -08:00
|
|
|
package frc4388.robot.subsystems.intake;
|
|
|
|
|
|
2026-02-09 17:18:54 -08:00
|
|
|
import static edu.wpi.first.units.Units.Rotations;
|
|
|
|
|
import static edu.wpi.first.units.Units.RotationsPerSecond;
|
2026-01-27 18:16:23 -08:00
|
|
|
import java.util.function.Supplier;
|
|
|
|
|
|
|
|
|
|
import org.littletonrobotics.junction.Logger;
|
|
|
|
|
|
|
|
|
|
import edu.wpi.first.math.geometry.Pose2d;
|
2026-02-14 10:55:51 -08:00
|
|
|
import edu.wpi.first.wpilibj.DigitalInput;
|
2026-01-27 18:16:23 -08:00
|
|
|
import edu.wpi.first.wpilibj2.command.SubsystemBase;
|
2026-02-14 10:55:51 -08:00
|
|
|
import frc4388.robot.subsystems.intake.Intake.IntakeMode;
|
2026-01-27 18:16:23 -08:00
|
|
|
|
|
|
|
|
public class Intake extends SubsystemBase {
|
2026-02-09 17:18:54 -08:00
|
|
|
public IntakeIO io;
|
2026-01-27 18:16:23 -08:00
|
|
|
IntakeStateAutoLogged state = new IntakeStateAutoLogged();
|
|
|
|
|
|
|
|
|
|
Supplier<Pose2d> m_swervePoseSupplier;
|
2026-02-14 10:55:51 -08:00
|
|
|
public DigitalInput m_armLimitSwitch;
|
2026-01-27 18:16:23 -08:00
|
|
|
|
|
|
|
|
public Intake(
|
2026-02-14 10:55:51 -08:00
|
|
|
IntakeIO io,
|
|
|
|
|
DigitalInput m_armLimitSwitch
|
2026-02-07 14:51:05 -07:00
|
|
|
// Supplier<Pose2d> swervePoseSupplier
|
2026-01-27 18:16:23 -08:00
|
|
|
) {
|
|
|
|
|
this.io = io;
|
2026-02-14 10:55:51 -08:00
|
|
|
this.m_armLimitSwitch= m_armLimitSwitch;
|
2026-02-07 14:51:05 -07:00
|
|
|
// this.m_swervePoseSupplier = swervePoseSupplier;
|
2026-01-27 18:16:23 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public enum IntakeMode {
|
2026-02-09 17:18:54 -08:00
|
|
|
Extended,
|
|
|
|
|
Retracted,
|
2026-01-27 18:16:23 -08:00
|
|
|
}
|
|
|
|
|
|
2026-02-10 17:33:39 -08:00
|
|
|
private IntakeMode mode = IntakeMode.Extended;
|
|
|
|
|
|
2026-01-27 18:16:23 -08:00
|
|
|
public void setMode(IntakeMode mode) {
|
2026-02-10 17:33:39 -08:00
|
|
|
this.mode = mode;
|
2026-01-27 18:16:23 -08:00
|
|
|
}
|
|
|
|
|
|
2026-02-10 18:42:47 -08:00
|
|
|
public IntakeMode getMode() {
|
|
|
|
|
return mode;
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-27 18:16:23 -08:00
|
|
|
|
|
|
|
|
// public enum FieldZone {
|
|
|
|
|
// // The robot should aim at the hub
|
|
|
|
|
// InShootZone,
|
|
|
|
|
// // The robot should aim towards the wall
|
|
|
|
|
// AimAtWall,
|
|
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// // 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;
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void periodic() {
|
|
|
|
|
// FaultReporter.register(this); // TODO Implement fault reporter
|
2026-02-14 10:55:51 -08:00
|
|
|
// System.out.println(m_armLimitSwitch.get());
|
2026-01-27 18:16:23 -08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
Logger.processInputs("Intake", state);
|
|
|
|
|
|
|
|
|
|
io.updateInputs(state);
|
|
|
|
|
|
2026-02-10 17:33:39 -08:00
|
|
|
switch (mode) {
|
|
|
|
|
case Extended:
|
|
|
|
|
io.setArmAngle(state, Rotations.of(IntakeConstants.ARM_LIMIT_EXTENDED.get()));
|
|
|
|
|
io.setRollerVelocity(state, RotationsPerSecond.of(IntakeConstants.ROLLER_ACTIVE.get()));
|
|
|
|
|
break;
|
|
|
|
|
case Retracted:
|
2026-02-14 10:55:51 -08:00
|
|
|
if (!m_armLimitSwitch.get()){
|
|
|
|
|
System.out.println("Triggered!");
|
|
|
|
|
io.stopArm();
|
|
|
|
|
} else {
|
|
|
|
|
io.setArmAngle(state, Rotations.of(IntakeConstants.ARM_LIMIT_RETRACTED.get()));
|
|
|
|
|
}
|
2026-02-10 17:33:39 -08:00
|
|
|
io.setRollerVelocity(state, RotationsPerSecond.of(0));
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-27 18:16:23 -08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|