Skip to content

Commit

Permalink
fix: don't allow GPWS to block inputs while stalling
Browse files Browse the repository at this point in the history
Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
  • Loading branch information
Octol1ttle committed May 12, 2024
1 parent b35c8ac commit 8378907
Showing 1 changed file with 13 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public class GroundProximityComputer implements ITickableComputer, IPitchLimiter
private static final float PULL_UP_THRESHOLD = 5.0f;
private static final float PITCH_CORRECT_THRESHOLD = 2.5f;
private final AirDataComputer data = ComputerRegistry.resolve(AirDataComputer.class);
private final StallComputer stall = ComputerRegistry.resolve(StallComputer.class);
private final FlightPlanner plan = ComputerRegistry.resolve(FlightPlanner.class);
public float descentImpactTime = STATUS_UNKNOWN;
public float terrainImpactTime = STATUS_UNKNOWN;
Expand Down Expand Up @@ -161,9 +162,20 @@ private BlockPos findHighest(BlockPos.Mutable at) {
return at;
}

@Override
public @Nullable ControlInput getPitchInput() {
if (FAConfig.computer().sinkrateProtection.recover() && positiveLessOrEquals(descentImpactTime, PITCH_CORRECT_THRESHOLD)) {
return new ControlInput(90.0f, 1 / descentImpactTime, InputPriority.HIGH);
} else if (FAConfig.computer().terrainProtection.recover() && positiveLessOrEquals(terrainImpactTime, PITCH_CORRECT_THRESHOLD)) {
return new ControlInput(90.0f, 1 / terrainImpactTime, InputPriority.HIGH);
}

return null;
}

@Override
public boolean blockPitchChange(Direction direction) {
if (direction != Direction.DOWN) {
if (direction != Direction.DOWN || stall.status == StallComputer.StallStatus.FULL_STALL) {
return false;
}

Expand All @@ -184,17 +196,6 @@ public void reset() {
fireworkUseSafe = true;
}

@Override
public @Nullable ControlInput getPitchInput() {
if (FAConfig.computer().sinkrateProtection.recover() && positiveLessOrEquals(descentImpactTime, PITCH_CORRECT_THRESHOLD)) {
return new ControlInput(90.0f, 1 / descentImpactTime, InputPriority.HIGH);
} else if (FAConfig.computer().terrainProtection.recover() && positiveLessOrEquals(terrainImpactTime, PITCH_CORRECT_THRESHOLD)) {
return new ControlInput(90.0f, 1 / terrainImpactTime, InputPriority.HIGH);
}

return null;
}

public enum LandingClearanceStatus {
TOO_LOW,
SAFE,
Expand Down

0 comments on commit 8378907

Please sign in to comment.