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