tourner a zero/180 regle

This commit is contained in:
Antoine PerreaultE
2026-03-24 20:28:03 -04:00
parent 70b796e99a
commit 22746ab8ca
3 changed files with 78 additions and 2 deletions

View File

@@ -25,6 +25,7 @@ public class TournerVersMur extends Command {
private double MaxAngularRate = RotationsPerSecond.of(0.75).in(RadiansPerSecond);
Pigeon2 pigeon2;
double force;
double angle;
private final SwerveRequest.FieldCentric drive = new SwerveRequest.FieldCentric()
.withDeadband(MaxSpeed * 0.1).withRotationalDeadband(MaxAngularRate * 0.1)
.withDriveRequestType(DriveRequestType.OpenLoopVoltage);
@@ -44,9 +45,11 @@ public class TournerVersMur extends Command {
public void execute() {
if(alliance.get() == Alliance.Blue){
force = 0.5;
angle = 0;
}
else{
force = -0.5;
angle = 180;
}
if(pigeon2.getYaw().getValueAsDouble() >0 && pigeon2.getYaw().getValueAsDouble() <180){
drivetrain.setControl(drive.withRotationalRate(force));
@@ -63,6 +66,6 @@ public class TournerVersMur extends Command {
// Returns true when the command should end.
@Override
public boolean isFinished() {
return pigeon2.getYaw().getValueAsDouble() > 165 && pigeon2.getYaw().getValueAsDouble() < 195;
return pigeon2.getYaw().getValueAsDouble() > angle - 5 && pigeon2.getYaw().getValueAsDouble() < angle + 5;
}
}