mirror of
https://github.com/Team4388/2026KPopRobotHunters.git
synced 2026-06-09 00:38:03 -06:00
Fix shooter
This commit is contained in:
@@ -7,12 +7,12 @@ public final class BuildConstants {
|
|||||||
public static final String MAVEN_GROUP = "";
|
public static final String MAVEN_GROUP = "";
|
||||||
public static final String MAVEN_NAME = "2026KPopRobotHunters";
|
public static final String MAVEN_NAME = "2026KPopRobotHunters";
|
||||||
public static final String VERSION = "unspecified";
|
public static final String VERSION = "unspecified";
|
||||||
public static final int GIT_REVISION = 51;
|
public static final int GIT_REVISION = 52;
|
||||||
public static final String GIT_SHA = "abc3dc6b144dc783d0ceac8861e847d5f5f9741d";
|
public static final String GIT_SHA = "736d7ef8233e918aa0cc1cc3f06f2069517bed59";
|
||||||
public static final String GIT_DATE = "2026-02-14 12:50:09 MST";
|
public static final String GIT_DATE = "2026-02-14 13:49:33 MST";
|
||||||
public static final String GIT_BRANCH = "shoot-button";
|
public static final String GIT_BRANCH = "shoot-button";
|
||||||
public static final String BUILD_DATE = "2026-02-14 13:46:45 MST";
|
public static final String BUILD_DATE = "2026-02-14 14:55:59 MST";
|
||||||
public static final long BUILD_UNIX_TIME = 1771102005908L;
|
public static final long BUILD_UNIX_TIME = 1771106159811L;
|
||||||
public static final int DIRTY = 1;
|
public static final int DIRTY = 1;
|
||||||
|
|
||||||
private BuildConstants(){}
|
private BuildConstants(){}
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ public class LED extends SubsystemBase implements Queryable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@AutoLogOutput
|
||||||
public String getMode(){
|
public String getMode(){
|
||||||
return mode.name();
|
return mode.name();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ public class IntakeConstants {
|
|||||||
public static final ConfigurableDouble ARM_LIMIT_RETRACTED = new ConfigurableDouble("Arm angle retracted", -0.3*0);
|
public static final ConfigurableDouble ARM_LIMIT_RETRACTED = new ConfigurableDouble("Arm angle retracted", -0.3*0);
|
||||||
public static final ConfigurableDouble ARM_LIMIT_EXTENDED = new ConfigurableDouble("Arm angle extended", 0);
|
public static final ConfigurableDouble ARM_LIMIT_EXTENDED = new ConfigurableDouble("Arm angle extended", 0);
|
||||||
|
|
||||||
public static final ConfigurableDouble ROLLER_ACTIVE = new ConfigurableDouble("Rolelr Active", 10);
|
public static final ConfigurableDouble ROLLER_ACTIVE = new ConfigurableDouble("Rolelr Active", 30);
|
||||||
// public static final ConfigurableDouble ROLL = new ConfigurableDouble("Arm angle extended", 0.25);
|
// public static final ConfigurableDouble ROLL = new ConfigurableDouble("Arm angle extended", 0.25);
|
||||||
|
|
||||||
// public static final AngularVelocity ROLLER_MAX_VELOCITY = RotationsPerSecond.of(4.0);
|
// public static final AngularVelocity ROLLER_MAX_VELOCITY = RotationsPerSecond.of(4.0);
|
||||||
@@ -51,7 +51,7 @@ public class IntakeConstants {
|
|||||||
.withKI(0.0)
|
.withKI(0.0)
|
||||||
.withKD(0.0);
|
.withKD(0.0);
|
||||||
|
|
||||||
public static ConfigurableDouble arm_kP = new ConfigurableDouble("ARM KP", 0.2);
|
public static ConfigurableDouble arm_kP = new ConfigurableDouble("ARM KP", 0.1);
|
||||||
public static ConfigurableDouble arm_kI = new ConfigurableDouble("ARM KI", 0);
|
public static ConfigurableDouble arm_kI = new ConfigurableDouble("ARM KI", 0);
|
||||||
public static ConfigurableDouble arm_kD = new ConfigurableDouble("ARM KD", 0);
|
public static ConfigurableDouble arm_kD = new ConfigurableDouble("ARM KD", 0);
|
||||||
|
|
||||||
|
|||||||
@@ -61,9 +61,9 @@ public class Shooter extends SubsystemBase {
|
|||||||
private ShooterMode mode = ShooterMode.NotReady;
|
private ShooterMode mode = ShooterMode.NotReady;
|
||||||
|
|
||||||
public void setShooterReady() {
|
public void setShooterReady() {
|
||||||
// if(this.mode == ShooterMode.NotReady) {
|
if(this.mode == ShooterMode.NotReady) {
|
||||||
this.mode = ShooterMode.Shooting;
|
this.mode = ShooterMode.Ready;
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setShooterNotReady() {
|
public void setShooterNotReady() {
|
||||||
@@ -100,52 +100,53 @@ public class Shooter extends SubsystemBase {
|
|||||||
|
|
||||||
// TODO: get if the robot is within the angle of the hub
|
// TODO: get if the robot is within the angle of the hub
|
||||||
|
|
||||||
// boolean driverError =
|
boolean driverError = false;
|
||||||
// XYSpeed <= ShooterConstants.ROBOT_SPEED_TOLERANCE.get() |
|
// XYSpeed <= ShooterConstants.ROBOT_SPEED_TOLERANCE.get() |
|
||||||
// AngSpeed <= ShooterConstants.ROBOT_ANG_SPEED_TOLERANCE.get() |
|
// AngSpeed <= ShooterConstants.ROBOT_ANG_SPEED_TOLERANCE.get() |
|
||||||
// distanceToHub <= ShooterConstants.ROBOT_MIN_HUB.get() |
|
// distanceToHub <= ShooterConstants.ROBOT_MIN_HUB.get() |
|
||||||
// distanceToHub >= ShooterConstants.ROBOT_MAX_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;
|
||||||
|
double shooterSpeedTarget = Math.abs(state.motor1TargetVelocity.in(RotationsPerSecond) + state.motor2TargetVelocity.in(RotationsPerSecond)) / 2;
|
||||||
|
|
||||||
// boolean badShooterVelocity = shooterSpeed < ShooterConstants.SHOOTER_SPEED_TOLERANCE.get();
|
boolean badShooterVelocity = Math.abs(shooterSpeed - shooterSpeedTarget) > ShooterConstants.SHOOTER_SPEED_TOLERANCE.get();
|
||||||
// boolean intakeBad = m_Intake.getMode() == IntakeMode.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);// + (intakeBad ? 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);
|
||||||
// break;
|
break;
|
||||||
// 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: // 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: // 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
|
case 0b100: // Bad intake, no driver err
|
||||||
// m_robotLED.setMode(Constants.LEDConstants.INTAKE_OUT);
|
m_robotLED.setMode(Constants.LEDConstants.INTAKE_OUT);
|
||||||
// break;
|
break;
|
||||||
// case 0b101: // Bad intake, yes driver err
|
case 0b101: // Bad intake, yes driver err
|
||||||
// m_robotLED.setMode(Constants.LEDConstants.INTAKE_OUT_BADPHYS);
|
m_robotLED.setMode(Constants.LEDConstants.INTAKE_OUT_BADPHYS);
|
||||||
// break;
|
break;
|
||||||
// case 0b110: // Bad intake and shooter (intake is more important), no driver err
|
case 0b110: // Bad intake and shooter (intake is more important), no driver err
|
||||||
// m_robotLED.setMode(Constants.LEDConstants.INTAKE_OUT);
|
m_robotLED.setMode(Constants.LEDConstants.INTAKE_OUT);
|
||||||
// break;
|
break;
|
||||||
// case 0b111: // Bad intake and shooter (intake is more important), yes driver err
|
case 0b111: // Bad intake and shooter (intake is more important), yes driver err
|
||||||
// m_robotLED.setMode(Constants.LEDConstants.INTAKE_OUT_BADPHYS);
|
m_robotLED.setMode(Constants.LEDConstants.INTAKE_OUT_BADPHYS);
|
||||||
// break;
|
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
|
||||||
// mode = (
|
mode = (
|
||||||
// bitmask == 0 ?
|
bitmask == 0 ?
|
||||||
// ShooterMode.Ready :
|
ShooterMode.Shooting :
|
||||||
// ShooterMode.NotReady
|
ShooterMode.Ready
|
||||||
// );
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,9 +12,7 @@ import frc4388.utility.status.CanDevice;
|
|||||||
public class ShooterConstants {
|
public class ShooterConstants {
|
||||||
// Motor conversions
|
// Motor conversions
|
||||||
|
|
||||||
public static final double FEEDER_INCHES_PER_ROT = 1.;
|
public static final double SHOOTERMOTOR_GEAR_RATIO = 1.5;
|
||||||
public static final double SHOOTERMOTOR1_GEAR_RATIO = 1.;
|
|
||||||
public static final double SHOOTERMOTOR2_GEAR_RATIO = 1.;
|
|
||||||
public static final double INDEXER_GEAR_RATIO = 1.;
|
public static final double INDEXER_GEAR_RATIO = 1.;
|
||||||
|
|
||||||
// public static final AngularVelocity SHOOTER_ACTIVE_VELOCITY = RotationsPerSecond.of(30);
|
// public static final AngularVelocity SHOOTER_ACTIVE_VELOCITY = RotationsPerSecond.of(30);
|
||||||
@@ -40,15 +38,15 @@ public class ShooterConstants {
|
|||||||
public static final ConfigurableDouble ROBOT_SPEED_TOLERANCE = new ConfigurableDouble("Speed tolerance MS", 1);
|
public static final ConfigurableDouble ROBOT_SPEED_TOLERANCE = new ConfigurableDouble("Speed tolerance MS", 1);
|
||||||
public static final ConfigurableDouble ROBOT_ANG_SPEED_TOLERANCE = new ConfigurableDouble("Shoot Ang speed tolerance DEG", 3);
|
public static final ConfigurableDouble ROBOT_ANG_SPEED_TOLERANCE = new ConfigurableDouble("Shoot Ang speed tolerance DEG", 3);
|
||||||
|
|
||||||
public static final ConfigurableDouble SHOOTER_SPEED_TOLERANCE = new ConfigurableDouble("Shooter speed tolerance RPS", 1);
|
public static final ConfigurableDouble SHOOTER_SPEED_TOLERANCE = new ConfigurableDouble("Shooter speed tolerance RPS", 5);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static Slot0Configs SHOOTER_PID = new Slot0Configs()
|
public static Slot0Configs SHOOTER_PID = new Slot0Configs()
|
||||||
.withKV(0.0)
|
.withKV(0.0)
|
||||||
.withKP(0.0)
|
.withKP(0.0)
|
||||||
.withKI(0.0)
|
.withKI(0.1)
|
||||||
.withKD(0.2);
|
.withKD(0.08);
|
||||||
|
|
||||||
public static Slot0Configs INDEXER_PID = new Slot0Configs()
|
public static Slot0Configs INDEXER_PID = new Slot0Configs()
|
||||||
.withKV(0.0)
|
.withKV(0.0)
|
||||||
@@ -61,8 +59,8 @@ public class ShooterConstants {
|
|||||||
public static ConfigurableDouble indexer_kI = new ConfigurableDouble("Indexer KI", 0);
|
public static ConfigurableDouble indexer_kI = new ConfigurableDouble("Indexer KI", 0);
|
||||||
public static ConfigurableDouble indexer_kD = new ConfigurableDouble("Indexer KD", 0);
|
public static ConfigurableDouble indexer_kD = new ConfigurableDouble("Indexer KD", 0);
|
||||||
|
|
||||||
public static ConfigurableDouble shooter_kP = new ConfigurableDouble("Shooter KP", 0.2);
|
public static ConfigurableDouble shooter_kP = new ConfigurableDouble("Shooter KP", 0.08);
|
||||||
public static ConfigurableDouble shooter_kI = new ConfigurableDouble("Shooter KI", 0);
|
public static ConfigurableDouble shooter_kI = new ConfigurableDouble("Shooter KI", 0.1);
|
||||||
public static ConfigurableDouble shooter_kD = new ConfigurableDouble("Shooter KD", 0);
|
public static ConfigurableDouble shooter_kD = new ConfigurableDouble("Shooter KD", 0);
|
||||||
|
|
||||||
// Limits
|
// Limits
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ public class ShooterReal implements ShooterIO {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
AngularVelocity motorRps = target.times(ShooterConstants.INDEXER_GEAR_RATIO);
|
AngularVelocity motorRps = target.times(ShooterConstants.SHOOTERMOTOR_GEAR_RATIO);
|
||||||
|
|
||||||
m_shooter1Motor.setControl(shooter1Velocity.withVelocity(motorRps));
|
m_shooter1Motor.setControl(shooter1Velocity.withVelocity(motorRps));
|
||||||
m_shooter2Motor.setControl(shooter2Velocity.withVelocity(motorRps));
|
m_shooter2Motor.setControl(shooter2Velocity.withVelocity(motorRps));
|
||||||
@@ -72,8 +72,8 @@ public class ShooterReal implements ShooterIO {
|
|||||||
@Override
|
@Override
|
||||||
public void updateInputs(ShooterState state) {
|
public void updateInputs(ShooterState state) {
|
||||||
|
|
||||||
state.motor1Velocity = m_shooter1Motor.getVelocity().getValue().div(ShooterConstants.SHOOTERMOTOR1_GEAR_RATIO);
|
state.motor1Velocity = m_shooter1Motor.getVelocity().getValue().div(ShooterConstants.SHOOTERMOTOR_GEAR_RATIO);
|
||||||
state.motor2Velocity = m_shooter2Motor.getVelocity().getValue().div(ShooterConstants.SHOOTERMOTOR2_GEAR_RATIO);
|
state.motor2Velocity = m_shooter2Motor.getVelocity().getValue().div(ShooterConstants.SHOOTERMOTOR_GEAR_RATIO);
|
||||||
state.indexerVelocity = m_indexerMotor.getVelocity().getValue().div(ShooterConstants.INDEXER_GEAR_RATIO);
|
state.indexerVelocity = m_indexerMotor.getVelocity().getValue().div(ShooterConstants.INDEXER_GEAR_RATIO);
|
||||||
|
|
||||||
// state.motorLinearVelocity = InchesPerSecond.of(m_shooter1Motor.getVelocity().getValue().in(RotationsPerSecond) * ShooterConstants.FEEDER_INCHES_PER_ROT);
|
// state.motorLinearVelocity = InchesPerSecond.of(m_shooter1Motor.getVelocity().getValue().in(RotationsPerSecond) * ShooterConstants.FEEDER_INCHES_PER_ROT);
|
||||||
|
|||||||
Reference in New Issue
Block a user