Exemple #1
0
        public override void Drive(FlightCtrlState s)
        {
            if (landStep == LandStep.OFF)
            {
                return;
            }

            descentSpeedPolicy = PickDescentSpeedPolicy();

            predictor.descentSpeedPolicy = PickDescentSpeedPolicy(); //create a separate IDescentSpeedPolicy object for the simulation
            predictor.endAltitudeASL     = DecelerationEndAltitude();

            prediction = predictor.GetResult(); //grab a reference to the current result, in case a new one comes in while we're doing stuff

            if (!PredictionReady && landStep != LandStep.DEORBIT_BURN && landStep != LandStep.PLANE_CHANGE && landStep != LandStep.LOW_DEORBIT_BURN &&
                landStep != LandStep.UNTARGETED_DEORBIT && landStep != LandStep.FINAL_DESCENT)
            {
                return;
            }

            switch (landStep)
            {
            case LandStep.UNTARGETED_DEORBIT:
                DriveUntargetedDeorbit(s);
                break;

            case LandStep.PLANE_CHANGE:
                DrivePlaneChange(s);
                break;

            case LandStep.LOW_DEORBIT_BURN:
                DriveLowDeorbitBurn(s);
                break;

            case LandStep.DEORBIT_BURN:
                DriveDeorbitBurn(s);
                break;

            case LandStep.COURSE_CORRECTIONS:
                DriveCourseCorrections(s);
                break;

            case LandStep.KILLING_HORIZONTAL_VELOCITY:
                DriveKillHorizontalVelocity(s);
                break;

            case LandStep.FINAL_DESCENT:
                DriveUntargetedLanding(s);
                break;

            default:
                break;
            }
        }
        public override void Drive(FlightCtrlState s)
        {
            if (!active)
            {
                return;
            }

            // If the latest prediction is a landing, aerobrake or no-reentry prediciton then keep it.
            // However if it is any other sort or result it is not much use to us, so do not bother!
            {
                ReentrySimulation.Result result = predictor.GetResult();
                if (null != result)
                {
                    if (result.outcome != ReentrySimulation.Outcome.ERROR && result.outcome != ReentrySimulation.Outcome.TIMED_OUT)
                    {
                        this.prediction = result;
                    }
                }
            }
            {
                ReentrySimulation.Result result = predictor.GetErrorResult();
                if (null != result)
                {
                    if (result.outcome != ReentrySimulation.Outcome.ERROR && result.outcome != ReentrySimulation.Outcome.TIMED_OUT)
                    {
                        this.errorPrediction = result;
                    }
                }
            }

            descentSpeedPolicy = PickDescentSpeedPolicy();

            predictor.descentSpeedPolicy            = PickDescentSpeedPolicy(); //create a separate IDescentSpeedPolicy object for the simulation
            predictor.decelEndAltitudeASL           = DecelerationEndAltitude();
            predictor.parachuteSemiDeployMultiplier = this.parachutePlan.Multiplier;

            // Consider lowering the langing gear
            {
                double minalt = Math.Min(vesselState.altitudeBottom, Math.Min(vesselState.altitudeASL, vesselState.altitudeTrue));
                if (deployGears && !deployedGears && (minalt < 1000))
                {
                    DeployLandingGears();
                }
            }

            base.Drive(s);
        }
        void DrawGUIPrediction()
        {
            ReentrySimulation.Result result = predictor.GetResult();
            if (result != null)
            {
                switch (result.outcome)
                {
                case ReentrySimulation.Outcome.LANDED:
                    GUILayout.Label("Landing Predictions:");
                    GUILayout.Label(Coordinates.ToStringDMS(result.endPosition.latitude, result.endPosition.longitude) + "\nASL:" + MuUtils.ToSI(result.endASL, -1, 4) + "m");
                    GUILayout.Label(ScienceUtil.GetExperimentBiome(result.body, result.endPosition.latitude, result.endPosition.longitude));
                    double error = Vector3d.Distance(mainBody.GetRelSurfacePosition(result.endPosition.latitude, result.endPosition.longitude, 0),
                                                     mainBody.GetRelSurfacePosition(core.target.targetLatitude, core.target.targetLongitude, 0));
                    GUILayout.Label("Target difference = " + MuUtils.ToSI(error, 0) + "m"
                                    + "\nMax drag: " + result.maxDragGees.ToString("F1") + "g"
                                    + "\nDelta-v needed: " + result.deltaVExpended.ToString("F1") + "m/s"
                                    + "\nTime to land: " + GuiUtils.TimeToDHMS(result.endUT - Planetarium.GetUniversalTime(), 1));
                    break;

                case ReentrySimulation.Outcome.AEROBRAKED:
                    GUILayout.Label("Predicted orbit after aerobraking:");
                    Orbit o = result.EndOrbit();
                    if (o.eccentricity > 1)
                    {
                        GUILayout.Label("Hyperbolic, eccentricity = " + o.eccentricity.ToString("F2"));
                    }
                    else
                    {
                        GUILayout.Label(MuUtils.ToSI(o.PeA, 3) + "m x " + MuUtils.ToSI(o.ApA, 3) + "m");
                    }
                    GUILayout.Label("Max drag: " + result.maxDragGees.ToString("F1") + "g"
                                    + "\nExit atmosphere in: " + GuiUtils.TimeToDHMS(result.endUT - Planetarium.GetUniversalTime(), 1));
                    break;

                case ReentrySimulation.Outcome.NO_REENTRY:
                    GUILayout.Label("Orbit does not reenter:\n"
                                    + MuUtils.ToSI(orbit.PeA, 3) + "m Pe > " + MuUtils.ToSI(mainBody.RealMaxAtmosphereAltitude(), 3) + "m atmosphere height");
                    break;

                case ReentrySimulation.Outcome.TIMED_OUT:
                    GUILayout.Label("Reentry simulation timed out.");
                    break;
                }
            }
        }
        void DrawGUIPrediction()
        {
            ReentrySimulation.Result result = predictor.GetResult();
            if (result != null)
            {
                switch (result.outcome)
                {
                case ReentrySimulation.Outcome.LANDED:
                    GUILayout.Label("Predicted landing site:");
                    GUILayout.Label(Coordinates.ToStringDMS(result.endPosition.latitude, result.endPosition.longitude));
                    double error = Vector3d.Distance(mainBody.GetRelSurfacePosition(result.endPosition.latitude, result.endPosition.longitude, 0),
                                                     mainBody.GetRelSurfacePosition(core.target.targetLatitude, core.target.targetLongitude, 0));
                    GUILayout.Label("Difference from target = " + MuUtils.ToSI(error, 0) + "m");
                    if (result.maxDragGees > 0)
                    {
                        GUILayout.Label("Predicted max drag gees: " + result.maxDragGees.ToString("F1"));
                    }
                    break;

                case ReentrySimulation.Outcome.AEROBRAKED:
                    GUILayout.Label("Predicted orbit after aerobraking:");
                    Orbit o = result.EndOrbit();
                    if (o.eccentricity > 1)
                    {
                        GUILayout.Label("Hyperbolic, eccentricity = " + o.eccentricity.ToString("F2"));
                    }
                    else
                    {
                        GUILayout.Label(MuUtils.ToSI(o.PeA, 3) + "m x " + MuUtils.ToSI(o.ApA, 3) + "m");
                    }
                    break;

                case ReentrySimulation.Outcome.NO_REENTRY:
                    GUILayout.Label("Orbit does not reenter:");
                    GUILayout.Label(MuUtils.ToSI(orbit.PeA, 3) + "m Pe > " + MuUtils.ToSI(mainBody.RealMaxAtmosphereAltitude(), 3) + "m atmosphere height");
                    break;

                case ReentrySimulation.Outcome.TIMED_OUT:
                    GUILayout.Label("Reentry simulation timed out.");
                    break;
                }
            }
        }