mirror of
https://github.com/Team4388/2026KPopRobotHunters.git
synced 2026-06-08 16:28:05 -06:00
Add feeder button
This commit is contained in:
@@ -243,6 +243,9 @@ public class RobotContainer {
|
||||
m_robotIntake.setMode(IntakeMode.Retracted);
|
||||
}));
|
||||
|
||||
|
||||
|
||||
|
||||
new Trigger(() -> getDeadbandedOperatorController().getLeftTriggerAxis() >= 0.5)
|
||||
.onTrue(new InstantCommand(() -> {
|
||||
m_robotShooter.setShooterNotReady();
|
||||
@@ -253,7 +256,16 @@ public class RobotContainer {
|
||||
m_robotShooter.setShooterReady();
|
||||
m_robotIntake.setMode(IntakeMode.Idle);
|
||||
}));
|
||||
|
||||
new JoystickButton(getDeadbandedOperatorController(), XboxController.BACK_BUTTON)
|
||||
.onTrue(new InstantCommand(() -> {
|
||||
m_robotShooter.setShooterReadyFeeder();
|
||||
}));
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
new JoystickButton(getDeadbandedOperatorController(), XboxController.A_BUTTON)
|
||||
.onTrue(new InstantCommand(() -> {
|
||||
m_robotShooter.setShooterShoot();
|
||||
|
||||
@@ -101,7 +101,7 @@ public final class Constants {
|
||||
|
||||
public static final LEDPatterns DEFAULT_PATTERN = LEDPatterns.FOREST_RAINBOW;
|
||||
|
||||
// // LED color for when the intake is out
|
||||
// // // LED color for when the intake is out
|
||||
// public static final LEDPatterns INTAKE_OUT = LEDPatterns.SOLID_RED;
|
||||
// // LED color for when the intake is out, but the driver conditions are bad
|
||||
// public static final LEDPatterns INTAKE_OUT_BADPHYS = LEDPatterns.RED_STROBE;
|
||||
@@ -116,6 +116,10 @@ public final class Constants {
|
||||
public static final LEDPatterns OPREADY = LEDPatterns.SOLID_WHITE;
|
||||
// Operator ready to shoot, but the driver conditions are bad
|
||||
public static final LEDPatterns OPREADY_BADPHYS = LEDPatterns.WHITE_STROBE;
|
||||
|
||||
|
||||
public static final LEDPatterns OPREADY_FEED = LEDPatterns.SOLID_BLUE;
|
||||
public static final LEDPatterns OPREADY_FEED_BADPHYS = LEDPatterns.BLUE_STROBE;
|
||||
}
|
||||
|
||||
public static final class OIConstants {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package frc4388.robot.subsystems.shooter;
|
||||
|
||||
import static edu.wpi.first.units.Units.Rotation;
|
||||
import static edu.wpi.first.units.Units.RotationsPerSecond;
|
||||
|
||||
import org.littletonrobotics.junction.AutoLogOutput;
|
||||
@@ -53,6 +54,10 @@ public class Shooter extends SubsystemBase {
|
||||
Shooting,
|
||||
// Shooter is going to fire soon
|
||||
Ready,
|
||||
|
||||
ShootingFeeder,
|
||||
ReadyFeeder,
|
||||
|
||||
// Not ready to shoot
|
||||
NotReady,
|
||||
}
|
||||
@@ -61,20 +66,22 @@ public class Shooter extends SubsystemBase {
|
||||
private boolean shooterButtonReady = false;
|
||||
|
||||
public void setShooterReady() {
|
||||
if(this.mode == ShooterMode.NotReady) {
|
||||
this.mode = ShooterMode.Ready;
|
||||
}
|
||||
this.mode = ShooterMode.Ready;
|
||||
}
|
||||
|
||||
public void setShooterReadyFeeder() {
|
||||
this.mode = ShooterMode.ReadyFeeder;
|
||||
}
|
||||
|
||||
public void setShooterNotReady() {
|
||||
this.mode = ShooterMode.NotReady;
|
||||
}
|
||||
|
||||
|
||||
public void setShooterShoot() {
|
||||
shooterButtonReady = true;
|
||||
}
|
||||
|
||||
|
||||
public void setShooterNOTShoot() {
|
||||
shooterButtonReady = false;
|
||||
}
|
||||
@@ -119,8 +126,8 @@ public class Shooter extends SubsystemBase {
|
||||
boolean badShooterVelocity = Math.abs(shooterSpeed - shooterSpeedTarget) > ShooterConstants.SHOOTER_SPEED_TOLERANCE.get();
|
||||
// boolean intakeBad = m_Intake.getMode() == IntxakeMode.Extended;
|
||||
|
||||
|
||||
int bitmask = (driverError ? 1 : 0) + (badShooterVelocity ? 2 : 0);// + (intakeBad ? 4 : 0);
|
||||
|
||||
int bitmask = (driverError ? 1 : 0) + (badShooterVelocity ? 2 : 0) + (this.mode == ShooterMode.ReadyFeeder ? 4 : 0);
|
||||
switch (bitmask) {
|
||||
case 0b000: // No Errors
|
||||
m_robotLED.setMode(Constants.LEDConstants.OPREADY);
|
||||
@@ -128,24 +135,23 @@ public class Shooter extends SubsystemBase {
|
||||
case 0b001: // No op err, yes driver err
|
||||
m_robotLED.setMode(Constants.LEDConstants.OPREADY_BADPHYS);
|
||||
break;
|
||||
case 0b010: // Bad flywheel, no driver err
|
||||
|
||||
case 0b010:
|
||||
case 0b110: // Bad flywheel, no driver err
|
||||
m_robotLED.setMode(Constants.LEDConstants.BAD_FLYWEEL);
|
||||
break;
|
||||
case 0b011: // Bad flywheel, yes driver err
|
||||
|
||||
case 0b011:
|
||||
case 0b111: // Bad flywheel, yes driver err
|
||||
m_robotLED.setMode(Constants.LEDConstants.BAD_FLYWEEL_BADPHYS);
|
||||
break;
|
||||
// case 0b100: // Bad intake, no driver err
|
||||
// m_robotLED.setMode(Constants.LEDConstants.INTAKE_OUT);
|
||||
// break;
|
||||
// case 0b101: // Bad intake, yes driver err
|
||||
// m_robotLED.setMode(Constants.LEDConstants.INTAKE_OUT_BADPHYS);
|
||||
// break;
|
||||
// case 0b110: // Bad intake and shooter (intake is more important), no driver err
|
||||
// m_robotLED.setMode(Constants.LEDConstants.INTAKE_OUT);
|
||||
// break;
|
||||
// case 0b111: // Bad intake and shooter (intake is more important), yes driver err
|
||||
// m_robotLED.setMode(Constants.LEDConstants.INTAKE_OUT_BADPHYS);
|
||||
// break;
|
||||
|
||||
case 0b100:
|
||||
m_robotLED.setMode(Constants.LEDConstants.OPREADY_FEED);
|
||||
break;
|
||||
case 0b101:
|
||||
m_robotLED.setMode(Constants.LEDConstants.OPREADY_FEED_BADPHYS);
|
||||
break;
|
||||
}
|
||||
|
||||
// // We set the shooter mode to ready if there are no errors
|
||||
@@ -165,18 +171,35 @@ public class Shooter extends SubsystemBase {
|
||||
|
||||
switch (mode) {
|
||||
case Shooting:
|
||||
io.setShooterVelocity(state, ShooterConstants.getTargetShooterSpeed(distanceToHub));
|
||||
|
||||
if(shooterButtonReady) {
|
||||
io.setShooterVelocity(state, ShooterConstants.getTargetShooterSpeed(distanceToHub));
|
||||
io.setIndexerOutput(state, ShooterConstants.INDEXER_FORWARD_OUTPUT.get());
|
||||
} else {
|
||||
io.setShooterVelocity(state, ShooterConstants.getTargetShooterSpeed(distanceToHub));
|
||||
io.setIndexerOutput(state, ShooterConstants.INDEXER_REVERSE_OUTPUT.get());
|
||||
}
|
||||
break;
|
||||
|
||||
case Ready:
|
||||
io.setShooterVelocity(state, ShooterConstants.getTargetShooterSpeed(distanceToHub));
|
||||
io.setIndexerOutput(state, ShooterConstants.INDEXER_REVERSE_OUTPUT.get());
|
||||
break;
|
||||
|
||||
case ShootingFeeder:
|
||||
io.setShooterVelocity(state, RotationsPerSecond.of(ShooterConstants.SHOOTER_FEED_VELOCITY.get()));
|
||||
|
||||
if(shooterButtonReady) {
|
||||
io.setIndexerOutput(state, ShooterConstants.INDEXER_FORWARD_OUTPUT.get());
|
||||
} else {
|
||||
io.setIndexerOutput(state, ShooterConstants.INDEXER_REVERSE_OUTPUT.get());
|
||||
}
|
||||
break;
|
||||
|
||||
case ReadyFeeder:
|
||||
io.setShooterVelocity(state, ShooterConstants.getTargetShooterSpeed(distanceToHub));
|
||||
io.setIndexerOutput(state, ShooterConstants.INDEXER_REVERSE_OUTPUT.get());
|
||||
break;
|
||||
|
||||
case NotReady:
|
||||
io.setShooterVelocity(state, RotationsPerSecond.of(ShooterConstants.SHOOTER_RESTING_VELOCITY.get()));
|
||||
io.setIndexerOutput(state, ShooterConstants.INDEXER_REVERSE_OUTPUT.get());
|
||||
|
||||
@@ -21,6 +21,7 @@ public class ShooterConstants {
|
||||
// public static final ConfigurableDouble SHOOTER_ACTIVE_VELOCITY = new ConfigurableDouble("Shooter Active Velocity", -40);
|
||||
public static final ConfigurableDouble SHOOTER_MAX_VELOCITY = new ConfigurableDouble("Shooter MAX Velocity", 60);
|
||||
public static final ConfigurableDouble SHOOTER_RESTING_VELOCITY = new ConfigurableDouble("Shooter Resting Velocity", 0.0);
|
||||
public static final ConfigurableDouble SHOOTER_FEED_VELOCITY = new ConfigurableDouble("Shooter Feed Velocity", 35);
|
||||
|
||||
public static final ConfigurableDouble INDEXER_FORWARD_OUTPUT = new ConfigurableDouble("Indexer FWD % Output", -0.4);
|
||||
public static final ConfigurableDouble INDEXER_REVERSE_OUTPUT = new ConfigurableDouble("Indexer reverse % Output", 0.0);
|
||||
|
||||
Reference in New Issue
Block a user