Skip to content

Commit

Permalink
Amping up the Amp button
Browse files Browse the repository at this point in the history
  • Loading branch information
frc1987 committed May 4, 2024
1 parent ff51289 commit 4a55b14
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 15 deletions.
47 changes: 37 additions & 10 deletions src/main/java/frc/robot/RobotContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ public class RobotContainer {
new SlewRateLimiter(Constants.translationSlewRate);
// private final SlewRateLimiter RotationalSlewRate =
// new SlewRateLimiter(Constants.rotationSlewRate);
public static boolean isForwardAmpPrimed = false;
public static boolean isReverseAmpPrimed = false;
public static boolean isAmpPrepped = false;
public static boolean isAmpShot = false;
public static boolean isClimbPrimed = false;
public static boolean aimAtTargetAuto = false;
private double MaxSpeed = DriveConstants.kSpeedAt12VoltsMps;
Expand Down Expand Up @@ -136,19 +136,46 @@ public RobotContainer() {
private void configureDriverController() {
DRIVER_CONTROLLER.b().onTrue(new ShootSubwooferFlat(ELEVATOR, WRIST, SHOOTER));

// DRIVER_CONTROLLER
// .y()
// .onTrue(
// new ConditionalCommand(
// new GoHome(ELEVATOR, WRIST, SHOOTER, INTAKE)
// .andThen(() -> isReverseAmpPrimed = false),
// new PrepRevAmp(ELEVATOR, WRIST)
// .andThen(new WaitCommand(0.8))
// .andThen(new FireRevAmp(SHOOTER))
// .andThen(new WaitCommand(0.1))
// .andThen(new InstantCommand(() -> ELEVATOR.setLengthInches(4.2)))
// .andThen(new InstantCommand(() -> isReverseAmpPrimed = true)),
// () -> isReverseAmpPrimed));

DRIVER_CONTROLLER
.y()
.onTrue(
new ConditionalCommand(
new GoHome(ELEVATOR, WRIST, SHOOTER, INTAKE)
.andThen(() -> isReverseAmpPrimed = false),
// Compare prepped to not prepped (If prepped, try shoot. Else, prep)
new ConditionalCommand(
// Compare shot to not shot (If shot, go home. If not, try shot)
new GoHome(ELEVATOR, WRIST, SHOOTER, INTAKE)
.andThen(
() -> {
isAmpPrepped = false;
isAmpShot = false;
}),
new ConditionalCommand(
// Compare working shot (If working, shoot. Else rumble.)
new FireRevAmp(SHOOTER)
.andThen(new WaitCommand(0.1))
.andThen(new InstantCommand(() -> ELEVATOR.setLengthInches(4.2)))
.andThen(new InstantCommand(() -> isAmpShot = true)),
new AsyncRumble(
DRIVER_CONTROLLER.getHID(), RumbleType.kBothRumble, 1.0, 400L),
() -> AMP_SENSORS.getBothSensors()),
() -> isAmpShot),
new PrepRevAmp(ELEVATOR, WRIST)
.andThen(new WaitCommand(0.8))
.andThen(new FireRevAmp(SHOOTER))
.andThen(new WaitCommand(0.1))
.andThen(new InstantCommand(() -> ELEVATOR.setLengthInches(4.2)))
.andThen(new InstantCommand(() -> isReverseAmpPrimed = true)),
() -> isReverseAmpPrimed));
.andThen(new InstantCommand(() -> isAmpPrepped = true)),
() -> isAmpPrepped));
DRIVER_CONTROLLER
.back()
.onTrue(
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/frc/robot/commands/control/AimLockWrist.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public void execute() {
if (RobotContainer.isClimbPrimed) {
return;
}
if (RobotContainer.isForwardAmpPrimed || RobotContainer.isReverseAmpPrimed) {
if (RobotContainer.isAmpPrepped) {
return;
}
// if (Util.canSeeTarget(speakerLimelight)) {
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/frc/robot/commands/control/GoHome.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import edu.wpi.first.wpilibj2.command.InstantCommand;
import edu.wpi.first.wpilibj2.command.ParallelCommandGroup;
import frc.robot.RobotContainer;
import frc.robot.subsystems.Elevator;
import frc.robot.subsystems.Intake;
import frc.robot.subsystems.Shooter;
Expand All @@ -23,6 +24,8 @@ public GoHome(Elevator elevator, Wrist wrist, Shooter shooter, Intake intake) {
new InstantCommand(wrist::goHome),
new InstantCommand(shooter::stopShooter),
new InstantCommand(shooter::stopFeeder),
new InstantCommand(intake::stopCollecting));
new InstantCommand(intake::stopCollecting),
new InstantCommand(() -> RobotContainer.isAmpPrepped = false),
new InstantCommand(() -> RobotContainer.isAmpShot = false));
}
}
2 changes: 1 addition & 1 deletion src/main/java/frc/robot/commands/control/IdleShooter.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public void execute() {
shooter.stopShooter();
return;
}
if (RobotContainer.isForwardAmpPrimed) {
if (RobotContainer.isAmpPrepped) {
shooter.setRPMShoot(Constants.Shooter.SHOOTER_AMP_RPM);
return;
}
Expand Down
8 changes: 6 additions & 2 deletions src/main/java/frc/robot/subsystems/AmpSensors.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,19 @@ public class AmpSensors extends SubsystemBase {
public AmpSensors() {
m_sensor_left = new DigitalInput(Constants.Wrist.PROXIMITY_SENSOR_LEFT_ID);
m_sensor_right = new DigitalInput(Constants.Wrist.PROXIMITY_SENSOR_RIGHT_ID);
Shuffleboard.getTab("MAIN").addBoolean("Amp Left", () -> getSensorLeft());
Shuffleboard.getTab("MAIN").addBoolean("Amp Rights", () -> getSensorRight());
Shuffleboard.getTab("MAIN").addBoolean("Amp Sensor", () -> getBothSensors());
}

public boolean getSensorLeft() {
return m_sensor_left.get();
//6.2 inches from wall
return !m_sensor_left.get();
}

public boolean getSensorRight() {
return m_sensor_right.get();
//6.2 inches from wall
return !m_sensor_right.get();
}

public boolean getBothSensors() {
Expand Down

0 comments on commit 4a55b14

Please sign in to comment.