This commit is contained in:
Antoine PerreaultE
2026-03-28 13:21:30 -04:00
parent 79568a58b9
commit a92a7a0ea1
6 changed files with 29 additions and 35 deletions

View File

@@ -30,7 +30,6 @@ public class RetourMilieuGauche extends Command {
double angle;
private double MaxSpeed = TunerConstants.kSpeedAt12Volts.in(MetersPerSecond);
private double MaxAngularRate = RotationsPerSecond.of(0.75).in(RadiansPerSecond);
Pigeon2 pigeon2;
Optional<Alliance> alliance = DriverStation.getAlliance();
private final SwerveRequest.FieldCentric drive = new SwerveRequest.FieldCentric()
.withDeadband(MaxSpeed * 0.1).withRotationalDeadband(MaxAngularRate * 0.1)
@@ -63,7 +62,7 @@ public class RetourMilieuGauche extends Command {
x = 2.305;
angle = 0;
if(limelight3g.getV()){
if(pigeon2.getYaw().getValueAsDouble() >355 || pigeon2.getYaw().getValueAsDouble() < 5){
if(drivetrain.getPigeon2().getYaw().getValueAsDouble() >355 || drivetrain.getPigeon2().getYaw().getValueAsDouble() < 5){
if((y-boty < 0.05 && y-boty >-0.05) && (x-botx < 0.05 && x-botx > -0.05)){
drivetrain.setControl(drive.withVelocityX(0).withVelocityY(0));
}
@@ -77,10 +76,10 @@ public class RetourMilieuGauche extends Command {
}
}
else{
if(pigeon2.getYaw().getValueAsDouble() >angle && pigeon2.getYaw().getValueAsDouble() <angle +180){
if(drivetrain.getPigeon2().getYaw().getValueAsDouble() >angle && drivetrain.getPigeon2().getYaw().getValueAsDouble() <angle +180){
drivetrain.setControl(drive.withRotationalRate(0.5));
}
else if(pigeon2.getYaw().getValueAsDouble() >=angle +180){
else if(drivetrain.getPigeon2().getYaw().getValueAsDouble() >=angle +180){
drivetrain.setControl(drive.withRotationalRate(-0.5));
}
@@ -92,7 +91,7 @@ public class RetourMilieuGauche extends Command {
x = 13.963;
angle = 180;
if(limelight3g.getV()){
if(pigeon2.getYaw().getValueAsDouble() >175 && pigeon2.getYaw().getValueAsDouble() < 185){
if(drivetrain.getPigeon2().getYaw().getValueAsDouble() >175 && drivetrain.getPigeon2().getYaw().getValueAsDouble() < 185){
if((y-boty < 0.05 && y-boty >-0.05) && (x-botx < 0.05 && x-botx > -0.05)){
drivetrain.setControl(drive.withVelocityX(0).withVelocityY(0));
}
@@ -106,10 +105,10 @@ public class RetourMilieuGauche extends Command {
}
}
else{
if(pigeon2.getYaw().getValueAsDouble() >0 && pigeon2.getYaw().getValueAsDouble() <180){
if(drivetrain.getPigeon2().getYaw().getValueAsDouble() >0 && drivetrain.getPigeon2().getYaw().getValueAsDouble() <180){
drivetrain.setControl(drive.withRotationalRate(-0.5));
}
else if(pigeon2.getYaw().getValueAsDouble() >=180){
else if(drivetrain.getPigeon2().getYaw().getValueAsDouble() >=180){
drivetrain.setControl(drive.withRotationalRate(0.5));
}