public bool update() { landingPrediction = Forecast.predictLandPosition(); brakeAltitudePrediction = Forecast.predictImmediateRetrogradeBurnStopAltitude(); var altitude = VesselController.getAltitude(); var velocity = VesselController.getVelocity().Length(); if (currentStage == Stage.Landing && altitude <= 20.0 && velocity < 2.0f) { currentStage = Stage.Landed; } if (currentStage == Stage.Landing) { updateLandingBurn(); } if (currentStage == Stage.Landed) { updateLanded(); } VesselDirectionController.update(); return(false); }
public bool update() { var landingPrediction = Forecast.predictLandPosition(); var brakeAltitudePrediction = Forecast.predictImmediateRetrogradeBurnStopAltitude(); var targetRelative = Target - landingPrediction.Position; var targetRelativeNormalized = targetRelative; targetRelativeNormalized.Normalize(); float minimalCorrectiveThrottle = 0.0f; var desiredDirection = targetRelativeNormalized; desiredDirection.Normalize(); VesselDirectionController.setTargetDirection(desiredDirection); minimalCorrectiveThrottle = (float)VesselDirectionController.getOnTargetPercentage() * Math.Min(1.0f, (float)Math.Pow(targetRelative.Length() * 0.0008f, 2.0f)) * 0.1f; VesselDirectionController.update(); Console.WriteLine("Prediction mismatch {0}", targetRelative.Length()); if ((targetRelative.Length() < 1000.0 && lastMissDistance < targetRelative.Length()) || targetRelative.Length() < 10.0) { VesselController.setThrottle(0.0); return(true); } lastMissDistance = targetRelative.Length(); VesselController.setThrottle(minimalCorrectiveThrottle); return(false); }
public bool update() { landingPrediction = Forecast.predictLandPosition(); brakingLandingPrediction = Forecast.predictLandPositionWithBraking(); brakeAltitudePrediction = Forecast.predictImmediateRetrogradeBurnStopAltitude(); var altitude = VesselController.getAltitude(); var velocity = VesselController.getVelocity().Length(); var targetRelative = Target - landingPrediction.Position; double missDistance = targetRelative.Length(); if (currentStage == Stage.HighAltitudeCorrections && missDistance < 500) { currentStage = Stage.BallisticDescend; } else if (currentStage == Stage.BallisticDescend && (altitude < 25000 || velocity > 1000)) { VesselController.setThrustPercentage(1.0f); currentStage = Stage.ReentryBurn; } else if (currentStage == Stage.ReentryBurn && velocity < 550) { VesselController.setThrustPercentage(0.5f); currentStage = Stage.BallisticDescend2; } else if (currentStage == Stage.BallisticDescend2 && brakeAltitudePrediction <= 500.0) { currentStage = Stage.LandingBurn; } else if (currentStage == Stage.LandingBurn && altitude <= 20.0 && velocity < 2.0f) { currentStage = Stage.Landed; } if (currentStage == Stage.HighAltitudeCorrections) { updateHighAltitudeCorrections(); } if (currentStage == Stage.BallisticDescend) { updateBallisticDescend(); } if (currentStage == Stage.BallisticDescend2) { updateBallisticDescend2(); } if (currentStage == Stage.ReentryBurn) { updateReentryBurn(); } if (currentStage == Stage.LandingBurn) { updateLandingBurn(); } if (currentStage == Stage.Landed) { updateLanded(); } VesselDirectionController.update(); return(false); }