Skip to content

Commit

Permalink
Demooo stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
GreenTomato5 committed Oct 20, 2024
1 parent 81d3361 commit 925bb93
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 21 deletions.
2 changes: 1 addition & 1 deletion src/main/java/frc/robot/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public static final class Intake {
public static final double OFF = 0.0;

// In DEGREES (Pivot setpoints)
public static final double DOWN = -233;
public static final double DOWN = -228;
public static final double IN = 0;

// In RPS (Spinner Setpoints)
Expand Down
14 changes: 13 additions & 1 deletion src/main/java/frc/robot/subsystems/drive/Drive.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public class Drive extends Subsystem<DriveStates> {
private PIDController headingCorrectionController;
private boolean headingCorrectionEnabled;
private boolean fieldRelativeEnabled = true;
// private Timer demoTimer = true;

private SwerveDriveKinematics kinematics = new SwerveDriveKinematics(getModuleTranslations());
private Rotation2d rawGyroRotation = new Rotation2d();
Expand Down Expand Up @@ -103,6 +104,15 @@ public Drive(
addTrigger(DriveStates.REGULAR_DRIVE, DriveStates.SLOW_MODE, () ->
Constants.controller.getLeftBumperPressed()
);

addTrigger(DriveStates.REGULAR_DRIVE, DriveStates.DEMO_SPIN, () ->
Constants.controller.getXButtonPressed()
);

addTrigger(DriveStates.DEMO_SPIN, DriveStates.REGULAR_DRIVE, () ->
Constants.controller.getXButtonPressed()
);

// addTrigger(DriveStates.REGULAR_DRIVE, DriveStates.SPEED_MAXXING,
// () -> Constants.controller.getLeftBumperPressed());

Expand All @@ -121,12 +131,14 @@ public void runState() {
// good)
// Logger.recordOutput("driveState", getState());
// TODO: TURN ON HEADING CORRECTION LATER


if (DriverStation.isTeleop() && getState() != DriveStates.AUTO_ALIGN) {
drive(
this,
() -> Constants.controller.getLeftY(),
() -> Constants.controller.getLeftX(),
() -> Constants.controller.getRightX(),
() -> Constants.controller.getRightX() + (getState() == DriveStates.DEMO_SPIN ? 0.15 : 0),
getState().getRotationModifier(),
getState().getTranslationModifier(),
headingCorrectionEnabled,
Expand Down
1 change: 1 addition & 0 deletions src/main/java/frc/robot/subsystems/drive/DriveStates.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

public enum DriveStates implements SubsystemStates {
REGULAR_DRIVE("Regular Drive", Constants.Drive.REGULAR_TM, Constants.Drive.REGULAR_RM),
DEMO_SPIN("Spinning for Demo", 0.5, 0.2),
SLOW_MODE("Slow Mode", Constants.Drive.SLOW_TM, Constants.Drive.SLOW_RM),
AUTO_ALIGN("Auto Aligning", Constants.Drive.AA_TM, Constants.Drive.AA_RM),
SPEED_MAXXING("Speed Maxxing", Constants.Drive.FAST_TM, Constants.Drive.FAST_RM);
Expand Down
22 changes: 11 additions & 11 deletions src/main/java/frc/robot/subsystems/intake/IntakeIOSparkMax.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ public class IntakeIOSparkMax implements IntakeIO {

boolean usingInPID;

private DigitalInput beamBreak;
Debouncer beamBreakDebouncer;
// private DigitalInput beamBreak;
// Debouncer beamBreakDebouncer;

public IntakeIOSparkMax() {
intakeMotor = new TalonFX(Constants.Intake.SPINNER_ID);
Expand All @@ -48,11 +48,11 @@ public IntakeIOSparkMax() {
pivotEncoder.setPositionConversionFactor(Constants.RADIAN_CF);
pivotEncoder.setVelocityConversionFactor(Constants.RADIAN_CF);

beamBreak = new DigitalInput(Constants.Intake.BEAM_BREAK_PORT);
beamBreakDebouncer = new Debouncer(
Constants.Intake.DEBOUNCE_TIME,
Debouncer.DebounceType.kBoth
);
// beamBreak = new DigitalInput(Constants.Intake.BEAM_BREAK_PORT);
// beamBreakDebouncer = new Debouncer(
// Constants.Intake.DEBOUNCE_TIME,
// Debouncer.DebounceType.kBoth
// );
}

public void setSetpoints(
Expand Down Expand Up @@ -124,8 +124,8 @@ public void configurePID(PIDConstants outPIDConst, PIDConstants inPIPidConst) {
inPIDController.setPID(inPIPidConst.kP, inPIPidConst.kI, inPIPidConst.kD);
}

@Override
public boolean noteDetected() {
return !beamBreakDebouncer.calculate(beamBreak.get());
}
// @Override
// public boolean noteDetected() {
// return !beamBreakDebouncer.calculate(beamBreak.get());
// }
}
19 changes: 11 additions & 8 deletions src/main/java/frc/robot/subsystems/manager/Manager.java
Original file line number Diff line number Diff line change
Expand Up @@ -159,15 +159,18 @@ public Manager() {
addTrigger(ManagerStates.IDLE, ManagerStates.INTAKING, () ->
Constants.controller.getBButtonPressed()
);
addTrigger(
ManagerStates.INTAKING,
ManagerStates.IDLE,
() ->
(intakeSubsystem.noteDetected() &&
intakeSubsystem.nearSetPoint() &&
useBeamBreaksVal) ||
Constants.controller.getBButtonPressed()
addTrigger(ManagerStates.INTAKING, ManagerStates.IDLE, () ->
Constants.controller.getBButtonPressed()
);
// addTrigger(
// ManagerStates.INTAKING,
// ManagerStates.IDLE,
// () ->
// (intakeSubsystem.noteDetected() &&
// intakeSubsystem.nearSetPoint() &&
// useBeamBreaksVal) ||
// Constants.controller.getBButtonPressed()
// );

// Amping (Y)
addTrigger(ManagerStates.IDLE, ManagerStates.STAGING_AMP, () ->
Expand Down

0 comments on commit 925bb93

Please sign in to comment.