mirror of
https://github.com/Team4388/2026KPopRobotHunters.git
synced 2026-06-09 08:48:05 -06:00
Limit Switch
This commit is contained in:
@@ -97,54 +97,54 @@ public class Shooter extends SubsystemBase {
|
||||
|
||||
// TODO: get if the robot is within the angle of the hub
|
||||
|
||||
boolean driverError =
|
||||
XYSpeed <= ShooterConstants.ROBOT_SPEED_TOLERANCE.get() |
|
||||
AngSpeed <= ShooterConstants.ROBOT_ANG_SPEED_TOLERANCE.get() |
|
||||
distanceToHub <= ShooterConstants.ROBOT_MIN_HUB.get() |
|
||||
distanceToHub >= ShooterConstants.ROBOT_MAX_HUB.get();
|
||||
// boolean driverError =
|
||||
// XYSpeed <= ShooterConstants.ROBOT_SPEED_TOLERANCE.get() |
|
||||
// AngSpeed <= ShooterConstants.ROBOT_ANG_SPEED_TOLERANCE.get() |
|
||||
// distanceToHub <= ShooterConstants.ROBOT_MIN_HUB.get() |
|
||||
// distanceToHub >= ShooterConstants.ROBOT_MAX_HUB.get();
|
||||
|
||||
double shooterSpeed = Math.abs(state.motor1Velocity.in(RotationsPerSecond) + state.motor2Velocity.in(RotationsPerSecond)) / 2;
|
||||
// double shooterSpeed = Math.abs(state.motor1Velocity.in(RotationsPerSecond) + state.motor2Velocity.in(RotationsPerSecond)) / 2;
|
||||
|
||||
boolean badShooterVelocity = shooterSpeed < ShooterConstants.SHOOTER_SPEED_TOLERANCE.get();
|
||||
boolean intakeBad = m_Intake.getMode() == IntakeMode.Extended;
|
||||
// boolean badShooterVelocity = shooterSpeed < ShooterConstants.SHOOTER_SPEED_TOLERANCE.get();
|
||||
// boolean intakeBad = m_Intake.getMode() == IntakeMode.Extended;
|
||||
|
||||
|
||||
int bitmask = (driverError ? 1 : 0) + (badShooterVelocity ? 2 : 0) + (intakeBad ? 4 : 0);
|
||||
switch (bitmask) {
|
||||
case 0b000: // No Errors
|
||||
m_robotLED.setMode(Constants.LEDConstants.OPREADY);
|
||||
break;
|
||||
case 0b001: // No op err, yes driver err
|
||||
m_robotLED.setMode(Constants.LEDConstants.OPREADY_BADPHYS);
|
||||
break;
|
||||
case 0b010: // Bad flywheel, no driver err
|
||||
m_robotLED.setMode(Constants.LEDConstants.BAD_FLYWEEL);
|
||||
break;
|
||||
case 0b011: // 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;
|
||||
}
|
||||
// int bitmask = (driverError ? 1 : 0) + (badShooterVelocity ? 2 : 0) + (intakeBad ? 4 : 0);
|
||||
// switch (bitmask) {
|
||||
// case 0b000: // No Errors
|
||||
// m_robotLED.setMode(Constants.LEDConstants.OPREADY);
|
||||
// break;
|
||||
// case 0b001: // No op err, yes driver err
|
||||
// m_robotLED.setMode(Constants.LEDConstants.OPREADY_BADPHYS);
|
||||
// break;
|
||||
// case 0b010: // Bad flywheel, no driver err
|
||||
// m_robotLED.setMode(Constants.LEDConstants.BAD_FLYWEEL);
|
||||
// break;
|
||||
// case 0b011: // 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;
|
||||
// }
|
||||
|
||||
// We set the shooter mode to ready if there are no errors
|
||||
mode = (
|
||||
bitmask == 0 ?
|
||||
ShooterMode.Ready :
|
||||
ShooterMode.NotReady
|
||||
);
|
||||
// // We set the shooter mode to ready if there are no errors
|
||||
// mode = (
|
||||
// bitmask == 0 ?
|
||||
// ShooterMode.Ready :
|
||||
// ShooterMode.NotReady
|
||||
// );
|
||||
|
||||
}
|
||||
// }
|
||||
|
||||
switch (mode) {
|
||||
case Shooting:
|
||||
@@ -162,4 +162,4 @@ public class Shooter extends SubsystemBase {
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}}
|
||||
|
||||
@@ -24,8 +24,8 @@ public class ShooterConstants {
|
||||
// public static final AngularVelocity INDEXER_ACTIVE_VELOCITY = RotationsPerSecond.of(10);
|
||||
// public static final AngularVelocity INDEXER_INACTIVE_VELOCITY = RotationsPerSecond.of(0.0);
|
||||
|
||||
public static final ConfigurableDouble SHOOTER_ACTIVE_VELOCITY = new ConfigurableDouble("Shooter Active Velocity", 30);
|
||||
public static final ConfigurableDouble SHOOTER_RESTING_VELOCITY = new ConfigurableDouble("Shooter Resting Velocity", 15);
|
||||
public static final ConfigurableDouble SHOOTER_ACTIVE_VELOCITY = new ConfigurableDouble("Shooter Active Velocity", 0);
|
||||
public static final ConfigurableDouble SHOOTER_RESTING_VELOCITY = new ConfigurableDouble("Shooter Resting Velocity", 0);
|
||||
|
||||
public static final ConfigurableDouble INDEXER_FORWARD_VELOCITY = new ConfigurableDouble("Indexer FWD Velocity", 10);
|
||||
public static final ConfigurableDouble INDEXER_REVERSE_VELOCITY = new ConfigurableDouble("Indexer reverse Velocity", 10);
|
||||
|
||||
Reference in New Issue
Block a user