Files
2026KPopRobotHunters/src/main/java/frc4388/robot/subsystems/intake/Intake.java
T

102 lines
2.7 KiB
Java
Raw Normal View History

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;
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;
import edu.wpi.first.wpilibj2.command.SubsystemBase;
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;
public Intake(
2026-02-14 15:57:33 -07:00
IntakeIO io
2026-02-07 14:51:05 -07:00
// Supplier<Pose2d> swervePoseSupplier
2026-01-27 18:16:23 -08:00
) {
this.io = io;
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-02-14 15:00:40 -07:00
Extending,
2026-02-16 15:57:24 -07:00
Retracting,
2026-03-03 17:13:28 -07:00
Idle
2026-01-27 18:16:23 -08:00
}
2026-02-21 12:54:16 -08:00
private IntakeMode mode = IntakeMode.Idle;
2026-02-10 17:33:39 -08:00
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-02-25 15:33:01 -08:00
public void rollerStop(){
io.setRollerOutput(state, 0);
}
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);
2026-02-20 20:59:06 -08:00
Logger.recordOutput("Intake/IntakeState", this.mode);
2026-01-27 18:16:23 -08:00
io.updateInputs(state);
2026-02-21 12:54:16 -08:00
switch (mode) {
case Extended:
io.setArmAngle(state, Rotations.of(IntakeConstants.ARM_LIMIT_EXTENDED.get()));
io.setRollerOutput(state, IntakeConstants.ROLLER_PERCENT_OUTPUT.get());
break;
case Retracted:
io.setArmAngle(state, Rotations.of(IntakeConstants.ARM_LIMIT_RETRACTED.get()));
io.setRollerOutput(state, 0);
break;
case Extending:
io.armOutput(IntakeConstants.ARM_EXTEND_PERCENT_OUTPUT.get());
io.setRollerOutput(state, IntakeConstants.ROLLER_PERCENT_OUTPUT.get());
break;
case Retracting:
io.armOutput(IntakeConstants.ARM_RETRACT_PERCENT_OUTPUT.get());
io.setRollerOutput(state, 0);
break;
case Idle:
io.stopArm();
break;
}
2026-02-17 18:53:26 -08:00
// if (state.retractedLimit){
// this.mode = IntakeMode.Retracted;
// }
2026-02-10 17:33:39 -08:00
2026-01-27 18:16:23 -08:00
}
}