/// <summary> /// Start and execute the flight sequence /// <param name="countdown"></param> /// </summary> public void Execute(bool countdown = true) { if (countdown) { LaunchWithCountdown(); } else { LaunchWithoutCountdown(); } while (UpperStage == null) { new LaunchGuidance.LiftOff(LaunchVehicle, 1, 0).Execute(until: () => LaunchVehicle.VerticalSpeed > 100); new LaunchGuidance.GravityTurn(LaunchVehicle, 1, 1).Execute(until: () => LaunchVehicle.MeanAltitude > _meco); var ss = new LaunchGuidance.StageSeparation(LaunchVehicle, 1, 2); ss.OnComplete += (s, e) => UpperStage = ss.GetNextStage(); } UpperStage.AutoPilot.Engage(); LaunchVehicle.AutoPilot.Engage(); LaunchVehicle.Control.RCS = true; LaunchVehicle.AutoPilot.TargetPitchAndHeading(-5, 270); LaunchVehicle.ActivateCenterEngines(); while (Math.Abs(LaunchVehicle.Flight(LaunchVehicle.Orbit.Body.ReferenceFrame).Heading - 270) < 10) { ; } UpperStage.Control.Throttle = 1; LaunchVehicle.Control.Throttle = 1; }
private void GravityTurn(ref int runmode) { //LaunchVehicle.AutoPilot.TargetPitchAndHeading(Math.Max(5, (float)InterpolatePitch(LaunchVehicle.MeanAltitude)), 90); LaunchVehicle.AutoPilot.TargetPitchAndHeading(Math.Max(5, (float)VelocityAnglePitch()), 90); Print("Altitude: " + LaunchVehicle.MeanAltitude, 1, 0); Print("Pitch to: " + InterpolatePitch(LaunchVehicle.MeanAltitude), 2, 0); if (LaunchVehicle.MeanAltitude >= _meco) { LaunchVehicle.Control.Throttle = 0; //runmode++; //LaunchVehicle.Control.ActivateNextStage(); LaunchVehicle.ActivateCenterEngines(); Thread.Sleep(4000); LaunchVehicle.Control.Throttle = 1; } }