This commit is contained in:
samuel desharnais
2026-03-31 17:54:41 -04:00
9 changed files with 96 additions and 54 deletions

View File

@@ -43,7 +43,9 @@ public class Limelighter extends Command {
// Called when the command is initially scheduled.
@Override
public void initialize() {}
public void initialize() {
alliance = DriverStation.getAlliance();
}
// Called every time the scheduler runs while the command is scheduled.
@Override
@@ -51,41 +53,45 @@ public class Limelighter extends Command {
double[] BotPose = new double[6];
System.out.println("e");
if (limelight3g.getV()) {
BotPose = limelight3g.getBotPoseBlue();
// BotPose = limelight3g.getBotPoseBlue();
if (!alliance.isPresent()) {
return;
}
if (alliance.get() == Alliance.Blue) {
x = 4;
x = 4.6;
BotPose = limelight3g.getBotPoseBlue();
}
else {
x = 11.915394;
BotPose = limelight3g.getBotPoseRed();
}
botx = BotPose[1];
boty = BotPose[0];
angle = drivetrain.getPigeon2().getYaw().getValueAsDouble();
calcul = limelight3g.Calcule(botx, x, boty, 4.6, angle);
if(calcul < -3 && calcul > -180){
calcul = limelight3g.Calcule(botx, x, boty, 4, angle);
if(calcul < -5 && calcul > -180){
drivetrain.setControl(
drive.withRotationalRate(-1.5));
drive.withRotationalRate(0.5*(2*Math.PI)));
}
else if(calcul > 3 && calcul < 180){
else if(calcul > 5 && calcul < 180){
drivetrain.setControl(
drive.withRotationalRate(-1.5));
drive.withRotationalRate(-0.5*(2*Math.PI)));
}
else if(calcul >= 180){
else if(calcul < -5){
drivetrain.setControl(
drive.withRotationalRate(-1.5));
drive.withRotationalRate(-0.5*(2*Math.PI)));
}
else if(calcul <= -180){
drivetrain.setControl(
drive.withRotationalRate(1.5));
drive.withRotationalRate(0.5*(2*Math.PI)));
}
else{
drivetrain.setControl(
drive.withRotationalRate(0));
}
System.out.println(calcul);
}
drivetrain.setControl(
drive.withVelocityX(0).withVelocityY(0).withRotationalRate(calcul));
System.out.println(angle);
if (calcul < 0.2 && calcul > -0.2) {
drivetrain.setControl(drive.withRotationalRate(0));
}