Ejemplo n.º 1
0
        public void get_InitStateJx(IAgOrbitStateClassical keplerState)
        {
            keplerState.SizeShapeType = AgEClassicalSizeShape.eSizeShapeSemimajorAxis;
            IAgClassicalSizeShapeSemimajorAxis Orbitsize = keplerState.SizeShape as IAgClassicalSizeShapeSemimajorAxis;

            keplerState.LocationType = AgEClassicalLocation.eLocationTrueAnomaly;
            IAgClassicalLocationTrueAnomaly OrbitLocation = keplerState.Location as IAgClassicalLocationTrueAnomaly;

            IAgClassicalOrientation OrbitOrientation = keplerState.Orientation as IAgClassicalOrientation;

            OrbitOrientation.AscNodeType = AgEOrientationAscNode.eAscNodeRAAN;
            IAgOrientationAscNodeRAAN OrbitAsc = keplerState.Orientation.AscNode as IAgOrientationAscNodeRAAN;


            SemiMajorAxis = Orbitsize.SemiMajorAxis;
            Eccentricity  = Orbitsize.Eccentricity;
            Inclination   = OrbitOrientation.Inclination;
            ArgOfPerigee  = OrbitOrientation.ArgOfPerigee;
            RAAN          = OrbitAsc.Value;
            TrueAnomaly   = OrbitLocation.Value;

            //Console.WriteLine(Orbitsize.SemiMajorAxis);
            //IAgQuantity a = OrbitOrientation as IAgQuantity;
            //Console.WriteLine(OrbitOrientation.Inclination);
        }
Ejemplo n.º 2
0
        // check if the resulting orbit is circular or parabolic/hyperbolic
        private static bool IsCircular(IAgVePropagatorJ2Perturbation prop)
        {
            IAgOrbitStateClassical testOrbit = prop.InitialState.Representation.ConvertTo(AgEOrbitStateType.eOrbitStateClassical) as IAgOrbitStateClassical;

            testOrbit.SizeShapeType = AgEClassicalSizeShape.eSizeShapeSemimajorAxis;
            IAgClassicalSizeShapeSemimajorAxis testSizeShape = testOrbit.SizeShape as IAgClassicalSizeShapeSemimajorAxis;

            if (testSizeShape.Eccentricity < 1.0)
            {
                return(true);
            }

            return(false);
        }
Ejemplo n.º 3
0
        private void CreateSat1TwoBody()
        {
            try
            {
                try
                { root.ExecuteCommand("Unload / */Satellite/Sat1"); }
                catch
                { }

                IAgSatellite sat1 = root.CurrentScenario.Children.New(AgESTKObjectType.eSatellite, "Sat1") as IAgSatellite;
                sat1.SetPropagatorType(AgEVePropagatorType.ePropagatorTwoBody);

                IAgVePropagatorTwoBody propSat1 = sat1.Propagator as IAgVePropagatorTwoBody;
                propSat1.Step = 60;

                IAgVeGfxAttributesOrbit sat1Graph = sat1.Graphics.Attributes as IAgVeGfxAttributesOrbit;
                sat1Graph.Color      = Color.LimeGreen;
                sat1Graph.Line.Width = AgELineWidth.e2;

                //'Definisco i parametri Kepleriani classici del satellite
                IAgOrbitStateClassical classical2B = propSat1.InitialState.Representation.ConvertTo(AgEOrbitStateType.eOrbitStateClassical) as IAgOrbitStateClassical;
                classical2B.CoordinateSystemType = AgECoordinateSystem.eCoordinateSystemJ2000;

                //'Uso il semiasse maggiore e l'eccentricità per definire la forma e la dimensione dell'orbita
                classical2B.SizeShapeType = AgEClassicalSizeShape.eSizeShapeSemimajorAxis;
                IAgClassicalSizeShapeSemimajorAxis semi2B = classical2B.SizeShape as IAgClassicalSizeShapeSemimajorAxis;
                semi2B.SemiMajorAxis = semimajorAxisSat1;
                semi2B.Eccentricity  = eccentricitySat1;

                //'Per definire l'orientamento dell'orbita nello spazio uso l'inclinazione, l'argomento del perigeo e la RAAN
                classical2B.Orientation.Inclination  = inclinationSat1;
                classical2B.Orientation.ArgOfPerigee = argOfPerigeeSat1;
                classical2B.Orientation.AscNodeType  = AgEOrientationAscNode.eAscNodeRAAN;
                IAgOrientationAscNodeRAAN raan = classical2B.Orientation.AscNode as IAgOrientationAscNodeRAAN;
                raan.Value = raanSat1;

                //'uso l'anomalia vera per definire la posizione iniziale del satellite lungo la sua orbita
                classical2B.LocationType = AgEClassicalLocation.eLocationTrueAnomaly;
                IAgClassicalLocationTrueAnomaly trueAnomaly = classical2B.Location as IAgClassicalLocationTrueAnomaly;
                trueAnomaly.Value = trueAnomSat1;

                //'Infine assegno i parametri orbtali così definiti al satellite e lo propago
                propSat1.InitialState.Representation.Assign(classical2B);
                propSat1.Propagate();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Ejemplo n.º 4
0
        // check if perigee radius is positive
        private static bool IsPerigeePositive(IAgVePropagatorJ2Perturbation prop)
        {
            IAgOrbitStateClassical testOrbit = prop.InitialState.Representation.ConvertTo(AgEOrbitStateType.eOrbitStateClassical) as IAgOrbitStateClassical;

            testOrbit.SizeShapeType = AgEClassicalSizeShape.eSizeShapeSemimajorAxis;
            IAgClassicalSizeShapeSemimajorAxis testSizeShape = testOrbit.SizeShape as IAgClassicalSizeShapeSemimajorAxis;

            // perigee radius = a(1-e)
            double rPeri = testSizeShape.SemiMajorAxis * (1 - testSizeShape.Eccentricity);

            if (rPeri > 3000.0)
            {
                return(true);
            }

            return(false);
        }
Ejemplo n.º 5
0
        private void CreateSat2J2()
        {
            try
            {
                try
                { root.ExecuteCommand("Unload / */Satellite/Sat2"); }
                catch
                { }

                IAgSatellite sat2 = root.CurrentScenario.Children.New(AgESTKObjectType.eSatellite, "Sat2") as IAgSatellite;
                sat2.SetPropagatorType(AgEVePropagatorType.ePropagatorJ2Perturbation);

                IAgVePropagatorJ2Perturbation propSat2 = sat2.Propagator as IAgVePropagatorJ2Perturbation;
                propSat2.Step = 60;

                IAgVeGfxAttributesOrbit sat2Graph = sat2.Graphics.Attributes as IAgVeGfxAttributesOrbit;
                sat2Graph.Color      = Color.Orange;
                sat2Graph.Line.Width = AgELineWidth.e2;

                IAgOrbitStateClassical classicalJ2 = propSat2.InitialState.Representation.ConvertTo(AgEOrbitStateType.eOrbitStateClassical) as IAgOrbitStateClassical;
                classicalJ2.CoordinateSystemType = AgECoordinateSystem.eCoordinateSystemJ2000;

                classicalJ2.SizeShapeType = AgEClassicalSizeShape.eSizeShapeSemimajorAxis;
                IAgClassicalSizeShapeSemimajorAxis semiJ2 = classicalJ2.SizeShape as IAgClassicalSizeShapeSemimajorAxis;
                semiJ2.SemiMajorAxis = semimajorAxisSat2;
                semiJ2.Eccentricity  = eccentricitySat2;

                classicalJ2.Orientation.Inclination  = inclinationSat2;
                classicalJ2.Orientation.ArgOfPerigee = argOfPerigeeSat2;
                classicalJ2.Orientation.AscNodeType  = AgEOrientationAscNode.eAscNodeRAAN;
                IAgOrientationAscNodeRAAN raan = classicalJ2.Orientation.AscNode as IAgOrientationAscNodeRAAN;
                raan.Value = raanSat2;

                classicalJ2.LocationType = AgEClassicalLocation.eLocationTrueAnomaly;
                IAgClassicalLocationTrueAnomaly trueAnomaly = classicalJ2.Location as IAgClassicalLocationTrueAnomaly;
                trueAnomaly.Value = trueAnomSat2;

                propSat2.InitialState.Representation.Assign(classicalJ2);
                propSat2.Propagate();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Ejemplo n.º 6
0
        // check if apogee is above the Earth
        private static bool IsApogeeAboveGround(IAgVePropagatorJ2Perturbation prop)
        {
            IAgOrbitStateClassical testOrbit = prop.InitialState.Representation.ConvertTo(AgEOrbitStateType.eOrbitStateClassical) as IAgOrbitStateClassical;

            testOrbit.SizeShapeType = AgEClassicalSizeShape.eSizeShapeSemimajorAxis;
            IAgClassicalSizeShapeSemimajorAxis testSizeShape = testOrbit.SizeShape as IAgClassicalSizeShapeSemimajorAxis;

            // apogee radius = a(1+e)
            double rApo = testSizeShape.SemiMajorAxis * (1 + testSizeShape.Eccentricity);


            if (rApo > 6380.0)
            {
                return(true);
            }

            return(false);
        }
Ejemplo n.º 7
0
        public static void CreateSatellite(string satName, double orbitPeriod, double eccentricity, double inclination, double rightAscension, double meanAnomaly, double argOfPerigee)
        {
            AgStkObjectRoot root;
            AgUiApplication app;

            app = System.Runtime.InteropServices.Marshal.GetActiveObject("STK11.Application") as AGI.Ui.Application.AgUiApplication;
            root = (AgStkObjectRoot)app.Personality2;
    
            // new satellite
            IAgSatellite sat = root.CurrentScenario.Children.New(AgESTKObjectType.eSatellite, satName) as IAgSatellite;

            // set the propagator to J2
            sat.SetPropagatorType(AgEVePropagatorType.ePropagatorJ2Perturbation);

            // get the propagator
            IAgVePropagatorJ2Perturbation j2 = (IAgVePropagatorJ2Perturbation) sat.Propagator;


            //Define the satellite's orbit using classical (Keplerian) orbital elements
            IAgOrbitStateClassical classical = (IAgOrbitStateClassical) j2.InitialState.Representation.ConvertTo(AgEOrbitStateType.eOrbitStateClassical);

            //Use period and eccentricity to define the size and shape of the orbit
            classical.SizeShapeType = AgEClassicalSizeShape.eSizeShapePeriod;
            IAgClassicalSizeShapePeriod period = (IAgClassicalSizeShapePeriod)classical.SizeShape;
            period.Eccentricity = eccentricity;
            period.Period = orbitPeriod;

            //Use argument of perigee, inclination and RAAN to define the orientation of the orbit
            classical.Orientation.ArgOfPerigee = argOfPerigee;
            classical.Orientation.Inclination = inclination;
            classical.Orientation.AscNodeType = AgEOrientationAscNode.eAscNodeRAAN;
            IAgOrientationAscNodeRAAN raan = (IAgOrientationAscNodeRAAN)classical.Orientation.AscNode;
            raan.Value = rightAscension;

            //Use mean anomaly to specify the position of the satellite in orbit
            classical.LocationType = AgEClassicalLocation.eLocationMeanAnomaly;
            IAgClassicalLocationMeanAnomaly ma = (IAgClassicalLocationMeanAnomaly)classical.Location;
            ma.Value = meanAnomaly;

            //Assign the orbital elements to the satellite's propagator and propagate the orbit	
            j2.InitialState.Representation.Assign(classical);
            j2.Propagate();
        }
Ejemplo n.º 8
0
        public static bool UpdateClassicalOrbit(IAgSatellite sat, double a, double e, double i, double aop, double raan, double ta, ref string error)
        {
            IAgVePropagatorJ2Perturbation prop = sat.Propagator as IAgVePropagatorJ2Perturbation;
            // need to set everything individually because true vs mean anomaly
            IAgOrbitStateClassical keplerian = prop.InitialState.Representation.ConvertTo(AgEOrbitStateType.eOrbitStateClassical) as IAgOrbitStateClassical;

            keplerian.SizeShapeType = AgEClassicalSizeShape.eSizeShapeSemimajorAxis;
            IAgClassicalSizeShapeSemimajorAxis sizeShape = keplerian.SizeShape as IAgClassicalSizeShapeSemimajorAxis;

            sizeShape.SemiMajorAxis = a;
            sizeShape.Eccentricity  = e;

            keplerian.Orientation.Inclination  = i;
            keplerian.Orientation.ArgOfPerigee = aop;
            (keplerian.Orientation.AscNode as IAgOrientationAscNodeRAAN).Value = raan;

            keplerian.LocationType = AgEClassicalLocation.eLocationTrueAnomaly;
            (keplerian.Location as IAgClassicalLocationTrueAnomaly).Value = ta;

            prop.InitialState.Representation.Assign(keplerian);

            return(Is_Error_Propagator(prop, ref error));
        }
Ejemplo n.º 9
0
        public Satellite_OrbitData(IAgStkObject Object0)
        {
            m_ElemsType = "Classical";

            if (Object0.ClassName == "Satellite")
            {
                IAgSatellite sat = Object0 as IAgSatellite;
                if (sat.PropagatorType == AgEVePropagatorType.ePropagatorJ2Perturbation)
                {
                    IAgVePropagatorJ2Perturbation prop = sat.Propagator as IAgVePropagatorJ2Perturbation;
                    m_ObjectTimes = prop.EphemerisInterval as AgCrdnEventIntervalSmartInterval;
                    Step_Size     = prop.Step;
                    IAgOrbitStateClassical keplerState = prop.InitialState.Representation.ConvertTo(AgEOrbitStateType.eOrbitStateClassical) as IAgOrbitStateClassical;
                    m_ultimateObject = Object0;
                    get_InitStateJx(keplerState);
                }

                else if (sat.PropagatorType == AgEVePropagatorType.ePropagatorJ4Perturbation)
                {
                    IAgVePropagatorJ4Perturbation prop = sat.Propagator as IAgVePropagatorJ4Perturbation;
                    m_ObjectTimes = prop.EphemerisInterval as AgCrdnEventIntervalSmartInterval;
                    Step_Size     = prop.Step;
                    IAgOrbitStateClassical keplerState = prop.InitialState.Representation.ConvertTo(AgEOrbitStateType.eOrbitStateClassical) as IAgOrbitStateClassical;
                    m_ultimateObject = keplerState;
                    get_InitStateJx(keplerState);
                }
                else if (sat.PropagatorType == AgEVePropagatorType.ePropagatorTwoBody)
                {
                    IAgVePropagatorTwoBody prop = sat.Propagator as IAgVePropagatorTwoBody;
                    m_ObjectTimes = prop.EphemerisInterval as AgCrdnEventIntervalSmartInterval;
                    Step_Size     = prop.Step;
                    IAgOrbitStateClassical keplerState = prop.InitialState.Representation.ConvertTo(AgEOrbitStateType.eOrbitStateClassical) as IAgOrbitStateClassical;
                    m_ultimateObject = keplerState;
                    get_InitStateJx(keplerState);
                }
            }
        }
Ejemplo n.º 10
0
        /* This code takes a set of Cartesian coordinates in a fixed frame and converts them into Keplerian orbital elements in an inertial frame
         * without using a satellite object (using conversion utility within STK Engine). The Keplerian elements you would like to return can be specified
         * by changing the enum values near the top of the Main function.
         */
        static void Main(string[] args)
        {
            AgSTKXApplication app = new AgSTKXApplication();

            app.NoGraphics = true;
            AgStkObjectRoot root = new AgStkObjectRoot();

            // Here are some preliminary variables for the classical coordinate elements you would like to obtain
            SizeShapeTypes SizeShapeType = SizeShapeTypes.Altitude;
            AscNodeTypes   AscNodeType   = AscNodeTypes.RAAN;
            LocationTypes  LocationType  = LocationTypes.ArgumentOfLatitude;

            // Here we create a new AgOrbitState object
            IAgConversionUtility ConversionUtility = root.ConversionUtility;
            IAgOrbitState        cartesianOrbit    = ConversionUtility.NewOrbitStateOnEarth();

            // Here is how you display and change the epoch
            Console.WriteLine("Epoch:");
            cartesianOrbit.Epoch = "1 Jun 2003 17:00:00.000";
            Console.WriteLine(cartesianOrbit.Epoch);

            // Here we assign whatever Cartesian coordinates we would like to in a fixed frame
            cartesianOrbit.AssignCartesian(AgECoordinateSystem.eCoordinateSystemFixed, 5598.42, -14988.6, 4.80738, 3.408, 1.27376, 2.60903);

            // Now we convert the orbit to a classical orbit state
            IAgOrbitStateClassical classicalOrbit = cartesianOrbit.ConvertTo(AgEOrbitStateType.eOrbitStateClassical) as IAgOrbitStateClassical;

            Console.WriteLine(classicalOrbit.CoordinateSystemType);

            // Prints out the first two classical orbit elements
            switch (SizeShapeType)
            {
            case SizeShapeTypes.Altitude:
                classicalOrbit.SizeShapeType = AgEClassicalSizeShape.eSizeShapeAltitude;
                IAgClassicalSizeShapeAltitude sizeShapeAltitude = classicalOrbit.SizeShape as IAgClassicalSizeShapeAltitude;
                Console.WriteLine("Apogee Altitude:");
                Console.WriteLine(sizeShapeAltitude.ApogeeAltitude);
                Console.WriteLine("Perigee Altitude:");
                Console.WriteLine(sizeShapeAltitude.PerigeeAltitude);
                break;

            case SizeShapeTypes.MeanMotion:
                classicalOrbit.SizeShapeType = AgEClassicalSizeShape.eSizeShapeMeanMotion;
                IAgClassicalSizeShapeMeanMotion sizeShapeMeanMotion = classicalOrbit.SizeShape as IAgClassicalSizeShapeMeanMotion;
                Console.WriteLine("Mean Motion:");
                Console.WriteLine(sizeShapeMeanMotion.MeanMotion);
                Console.WriteLine("Eccentricity:");
                Console.WriteLine(sizeShapeMeanMotion.Eccentricity);
                break;

            case SizeShapeTypes.Period:
                classicalOrbit.SizeShapeType = AgEClassicalSizeShape.eSizeShapePeriod;
                IAgClassicalSizeShapePeriod sizeShapePeriod = classicalOrbit.SizeShape as IAgClassicalSizeShapePeriod;
                Console.WriteLine("Period:");
                Console.WriteLine(sizeShapePeriod.Period);
                Console.WriteLine("Eccentricity:");
                Console.WriteLine(sizeShapePeriod.Eccentricity);
                break;

            case SizeShapeTypes.Radius:
                classicalOrbit.SizeShapeType = AgEClassicalSizeShape.eSizeShapeRadius;
                IAgClassicalSizeShapeRadius sizeShapeRadius = classicalOrbit.SizeShape as IAgClassicalSizeShapeRadius;
                Console.WriteLine("Apogee Radius:");
                Console.WriteLine(sizeShapeRadius.ApogeeRadius);
                Console.WriteLine("Perigee Radius:");
                Console.WriteLine(sizeShapeRadius.PerigeeRadius);
                break;

            case SizeShapeTypes.SemimajorAxis:
                classicalOrbit.SizeShapeType = AgEClassicalSizeShape.eSizeShapeSemimajorAxis;
                IAgClassicalSizeShapeSemimajorAxis sizeShapeSemimajorAxis = classicalOrbit.SizeShape as IAgClassicalSizeShapeSemimajorAxis;
                Console.WriteLine("Semimajor Axis:");
                Console.WriteLine(sizeShapeSemimajorAxis.SemiMajorAxis);
                Console.WriteLine("Eccentricity:");
                Console.WriteLine(sizeShapeSemimajorAxis.Eccentricity);
                break;
            }

            // Prints the inclination and argument of perigee
            IAgClassicalOrientation orientation = classicalOrbit.Orientation;

            Console.WriteLine("Inclination:");
            Console.WriteLine(orientation.Inclination);
            Console.WriteLine("Argument of Perigee:");
            Console.WriteLine(orientation.ArgOfPerigee);

            // This section prints the ascending node value
            Console.WriteLine("Ascending Node:");
            switch (AscNodeType)
            {
            case AscNodeTypes.RAAN:
                orientation.AscNodeType = AgEOrientationAscNode.eAscNodeRAAN;
                IAgOrientationAscNodeRAAN ascNodeRAAN = orientation.AscNode as IAgOrientationAscNodeRAAN;
                Console.WriteLine(ascNodeRAAN.Value);
                break;

            case AscNodeTypes.LAN:
                orientation.AscNodeType = AgEOrientationAscNode.eAscNodeLAN;
                IAgOrientationAscNodeLAN ascNodeLAN = orientation.AscNode as IAgOrientationAscNodeLAN;
                Console.WriteLine(ascNodeLAN.Value);
                break;
            }

            // This section prints the location of the satellite along the orbit in terms of whatever you would like
            Console.WriteLine("Location:");
            switch (LocationType)
            {
            case LocationTypes.ArgumentOfLatitude:
                classicalOrbit.LocationType = AgEClassicalLocation.eLocationArgumentOfLatitude;
                IAgClassicalLocationArgumentOfLatitude locationArgumentOfLatitude = classicalOrbit.Location as IAgClassicalLocationArgumentOfLatitude;
                Console.WriteLine(locationArgumentOfLatitude.Value);
                break;

            case LocationTypes.EccentricAnomaly:
                classicalOrbit.LocationType = AgEClassicalLocation.eLocationEccentricAnomaly;
                IAgClassicalLocationEccentricAnomaly locationSpecificEccentricAnomaly = classicalOrbit.Location as IAgClassicalLocationEccentricAnomaly;
                Console.WriteLine(locationSpecificEccentricAnomaly.Value);
                break;

            case LocationTypes.MeanAnomaly:
                classicalOrbit.LocationType = AgEClassicalLocation.eLocationMeanAnomaly;
                IAgClassicalLocationMeanAnomaly locationSpecificMeanAnomaly = classicalOrbit.Location as IAgClassicalLocationMeanAnomaly;
                Console.WriteLine(locationSpecificMeanAnomaly.Value);
                break;

            case LocationTypes.TimePastAN:
                classicalOrbit.LocationType = AgEClassicalLocation.eLocationTimePastAN;
                IAgClassicalLocationTimePastAN locationSpecificTimePastAN = classicalOrbit.Location as IAgClassicalLocationTimePastAN;
                Console.WriteLine(locationSpecificTimePastAN.Value);
                break;

            case LocationTypes.TimePastPerigee:
                classicalOrbit.LocationType = AgEClassicalLocation.eLocationTimePastPerigee;
                IAgClassicalLocationTimePastPerigee locationSpecificTimePastPerigee = classicalOrbit.Location as IAgClassicalLocationTimePastPerigee;
                Console.WriteLine(locationSpecificTimePastPerigee.Value);
                break;

            case LocationTypes.TrueAnomaly:
                classicalOrbit.LocationType = AgEClassicalLocation.eLocationTrueAnomaly;
                IAgClassicalLocationTrueAnomaly locationTrueAnomaly = classicalOrbit.Location as IAgClassicalLocationTrueAnomaly;
                Console.WriteLine(locationTrueAnomaly.Value);
                break;
            }

            Console.ReadLine();
        }
Ejemplo n.º 11
0
        /// <summary>
        /// 新建一个SARSYS在当前sc文件中
        /// 需要建立最基础的系统
        /// 参数大多数有默认值
        /// </summary>
        public void newsarsys()
        {
            #region 写入信息
            AGI.STKX.IAgExecCmdResult resultmsg = rootapp.ExecuteCommand("SetDescription * long SARSYS");
            #endregion

            #region 设定单位、仿真时间
            // Reset the units to the STK defaults
            dimensions = root.UnitPreferences;
            dimensions.ResetUnits();

            // Set the date unit, acquire an interface to the scenario and use
            // it to set the time period and epoch
            dimensions.SetCurrentUnit("DateFormat", "UTCG");

            scene = (IAgScenario)root.CurrentScenario;
            scene.StartTime = simstarttime;
            scene.StopTime = simstoptime;
            scene.Epoch = simstarttime;

            // Set new preference for Temperature
            dimensions.SetCurrentUnit("Temperature", "degC");
            #endregion

            #region 放置发射站
            //SATELLITE #1: TDRS
            //Assign a two-body propagator to propagate it
            tdrs = (IAgSatellite)root.CurrentScenario.Children.New(AgESTKObjectType.
                eSatellite, "TDRS");
            tdrs.SetPropagatorType(AgEVePropagatorType.ePropagatorTwoBody);
            twobody = (IAgVePropagatorTwoBody)tdrs.Propagator;

            //Define the TDRS satellite's orbit using
            //classical (Keplerian) orbital elements
            classical = (IAgOrbitStateClassical)twobody.InitialState.Representation.ConvertTo(AgEOrbitStateType.eOrbitStateClassical);

            //Set J2000 as the coordinate system
            //and set the time period and time step
            classical.CoordinateSystemType = AgECoordinateSystem.eCoordinateSystemJ2000;
            twobody.EphemerisInterval.SetStartAndStopTimes(simstarttime, simstoptime);
            twobody.Step = 60;

            //定义半主轴长度,离心率
            //Use period and eccentricity to define the size
            //and shape of the orbit
            classical.SizeShapeType = AgEClassicalSizeShape.eSizeShapeSemimajorAxis;
            IAgClassicalSizeShapeSemimajorAxis semi = (IAgClassicalSizeShapeSemimajorAxis)classical.SizeShape;
            semi.SemiMajorAxis = 35860;
            semi.Eccentricity = 0.0;

            //定义轨道倾角,升交点赤经,近地点幅角
            //Use argument of perigee, inclination
            //and longitude of ascending node to
            //define the orientation of the orbit
            classical.Orientation.ArgOfPerigee = 15.0;
            classical.Orientation.Inclination = 40.0;
            classical.Orientation.AscNodeType = AgEOrientationAscNode.eAscNodeLAN;
            IAgOrientationAscNodeLAN lan = (IAgOrientationAscNodeLAN)classical.Orientation.AscNode;
            lan.Value = 259.999982;

            //定义真近点角(?)来定义初始位置
            //Use true anomaly to specify the position of
            //the satellite in orbit
            classical.LocationType = AgEClassicalLocation.eLocationTrueAnomaly;
            IAgClassicalLocationTrueAnomaly trueAnomaly = (IAgClassicalLocationTrueAnomaly)classical.Location;
            trueAnomaly.Value = 178.845262;

            //Assign the orbital elements to the TDRS
            //satellite's propagator and propagate the orbit
            twobody.InitialState.Representation.Assign(classical);
            twobody.Propagate();

            root.Rewind();

            #endregion

            #region 放置接收站
            cruise = (IAgAircraft)root.CurrentScenario.Children.New(AgESTKObjectType.eAircraft, "Cruise");
            cruise.SetRouteType(AgEVePropagatorType.ePropagatorGreatArc);
            greatArc = (IAgVePropagatorGreatArc)cruise.Route;
            greatArc.EphemerisInterval.SetStartAndStopTimes(simstarttime, simstoptime);
            greatArc.Method = AgEVeWayPtCompMethod.eDetermineTimeAccFromVel;

            ((IAgVOModelFile)cruise.VO.Model.ModelData).Filename = @"\STKData\VO\Models\Air\e-3a_sentry_awacs.mdl";
            cruise.VO.Offsets.Rotational.Enable = true;
            cruise.VO.Offsets.Rotational.X = 180;

            //Use the convenience method defined above
            //to add waypoints specifying the ship's route
            AddWaypoint(greatArc.Waypoints, -42.1, -121.5, 3.0, .15, 0.0);
            AddWaypoint(greatArc.Waypoints, 62.0, -56.6, 3.0, .15, 0.0);

            cruise.SetAttitudeType(AgEVeAttitude.eAttitudeStandard);
            IAgVeRouteAttitudeStandard attitude = (IAgVeRouteAttitudeStandard)cruise.Attitude;
            attitude.Basic.SetProfileType(AgEVeProfile.
                eProfileECFVelocityAlignmentWithRadialConstraint);
            cruise.Graphics.WaypointMarker.IsWaypointMarkersVisible = true;
            cruise.Graphics.WaypointMarker.IsTurnMarkersVisible = true;
            greatArc.Propagate();
            root.Rewind();

            #endregion

            #region 放置发射站雷达
            horizon = (IAgSensor)root.CurrentScenario.Children["TDRS"].Children.
                    New(AgESTKObjectType.eSensor, "Horizon");
            horizon.SetPatternType(AgESnPattern.eSnSimpleConic);
            IAgSnSimpleConicPattern simpleConic = (IAgSnSimpleConicPattern)horizon.Pattern;
            simpleConic.ConeAngle = 0.1;

            //Select a Fixed pointing type and the Az-El
            //orientation type, and set the elevation angle to
            //90 deg, so that the sensor points straight down
            //with reference to the satellite
            horizon.SetPointingType(AgESnPointing.eSnPtFixed);
            IAgSnPtFixed fixedPt = (IAgSnPtFixed)horizon.Pointing;
            IAgOrientationAzEl azEl = (IAgOrientationAzEl)fixedPt.Orientation.ConvertTo(AgEOrientationType.eAzEl);
            azEl.Elevation = 89.2;
            azEl.AboutBoresight = AgEAzElAboutBoresight.eAzElAboutBoresightRotate;
            fixedPt.Orientation.Assign(azEl);

            root.Rewind();

            #endregion
        }
Ejemplo n.º 12
0
        /// <summary>
        /// 读出当前sc文件中已经存在的SARSYS
        /// </summary>
        public void readsarsys()
        {

            AGI.STKX.IAgExecCmdResult resultmsg = rootapp.ExecuteCommand("GetDescription * long");


            dimensions = root.UnitPreferences;
            scene = (IAgScenario)root.CurrentScenario;
            tdrs = (IAgSatellite)root.CurrentScenario.Children["TDRS"];
            
            twobody = (IAgVePropagatorTwoBody)tdrs.Propagator;
            classical = (IAgOrbitStateClassical)twobody.InitialState.Representation.ConvertTo(AgEOrbitStateType.eOrbitStateClassical);

            cruise = (IAgAircraft)root.CurrentScenario.Children["Cruise"];
            greatArc = (IAgVePropagatorGreatArc)cruise.Route;

            radar_t = (IAgSensor)root.CurrentScenario.Children["TDRS"].Children["radar_t"];

            radar_r = (IAgSensor)root.CurrentScenario.Children["Cruise"].Children["radar_r"];

            target = (IAgSensor)root.CurrentScenario.Children["TDRS"].Children["target"];

            simstarttime = scene.StartTime;
            simstoptime = scene.StopTime;
            simstep = scene.Animation.AnimStepValue;
            IAgClassicalSizeShapeSemimajorAxis semi = (IAgClassicalSizeShapeSemimajorAxis)classical.SizeShape;
            sasem = semi.SemiMajorAxis;
            saecc = semi.Eccentricity;
            saaop = classical.Orientation.ArgOfPerigee;
            sainc = classical.Orientation.Inclination;
            salan = ((IAgOrientationAscNodeLAN)classical.Orientation.AscNode).Value;
            satra = ((IAgClassicalLocationTrueAnomaly)classical.Location).Value;
            racoang = ((IAgSnSimpleConicPattern)radar_t.Pattern).ConeAngle;

            IAgSnPtFixed fixedPt = (IAgSnPtFixed)radar_t.Pointing;
            IAgOrientationAzEl azEl = (IAgOrientationAzEl)fixedPt.Orientation.ConvertTo(AgEOrientationType.eAzEl);
            raeleva = azEl.Elevation;

            plwaypoints = new double[5 * greatArc.Waypoints.Count];
            for(int ii=0;ii<greatArc.Waypoints.Count;ii++)
            {
                plwaypoints[ii * 5] = greatArc.Waypoints[ii].Latitude;
                plwaypoints[ii * 5 + 1] = greatArc.Waypoints[ii].Longitude;
                plwaypoints[ii * 5 + 2] = greatArc.Waypoints[ii].Altitude;
                plwaypoints[ii * 5 + 3] = greatArc.Waypoints[ii].Speed;
                plwaypoints[ii * 5 + 4] = greatArc.Waypoints[ii].TurnRadius;
            }




        }
Ejemplo n.º 13
0
        /// <summary>
        /// 新建一个SARSYS在当前sc文件中
        /// 需要建立最基础的系统
        /// 参数大多数有默认值
        /// </summary>
        public void newsarsys()
        {
            #region 写入信息
            AGI.STKX.IAgExecCmdResult resultmsg = rootapp.ExecuteCommand("SetDescription * long SARSYS");
            #endregion


            #region 设定单位、仿真时间
            // Reset the units to the STK defaults
            dimensions = root.UnitPreferences;
            dimensions.ResetUnits();

            // Set the date unit, acquire an interface to the scenario and use
            // it to set the time period and epoch
            dimensions.SetCurrentUnit("DateFormat", "UTCG");

            scene = (IAgScenario)root.CurrentScenario;
            scene.StartTime = simstarttime;
            scene.StopTime = simstoptime;
            scene.Epoch = simstarttime;

            //rootapp.ExecuteCommand("MapTracking * UTM");

            // Set new preference for Temperature
            dimensions.SetCurrentUnit("Temperature", "degC");
            #endregion

            #region 放置发射站
            //SATELLITE #1: TDRS
            //Assign a two-body propagator to propagate it
            tdrs = (IAgSatellite)root.CurrentScenario.Children.New(AgESTKObjectType.
                eSatellite, "TDRS");
            tdrs.SetPropagatorType(AgEVePropagatorType.ePropagatorTwoBody);
            twobody = (IAgVePropagatorTwoBody)tdrs.Propagator;

            //Define the TDRS satellite's orbit using
            //classical (Keplerian) orbital elements
            classical = (IAgOrbitStateClassical)twobody.InitialState.Representation.ConvertTo(AgEOrbitStateType.eOrbitStateClassical);

            //Set J2000 as the coordinate system
            //and set the time period and time step
            classical.CoordinateSystemType = AgECoordinateSystem.eCoordinateSystemJ2000;
            twobody.EphemerisInterval.SetStartAndStopTimes(simstarttime, simstoptime);
            twobody.Step = 60;

            //定义半主轴长度,离心率
            //Use period and eccentricity to define the size
            //and shape of the orbit
            classical.SizeShapeType = AgEClassicalSizeShape.eSizeShapeSemimajorAxis;
            IAgClassicalSizeShapeSemimajorAxis semi = (IAgClassicalSizeShapeSemimajorAxis)classical.SizeShape;
            semi.SemiMajorAxis = sasem;
            semi.Eccentricity = saecc;


            //定义轨道倾角,升交点赤经,近地点幅角
            //Use argument of perigee, inclination
            //and longitude of ascending node to
            //define the orientation of the orbit
            classical.Orientation.ArgOfPerigee = saaop;
            classical.Orientation.Inclination = sainc;
            classical.Orientation.AscNodeType = AgEOrientationAscNode.eAscNodeLAN;
            IAgOrientationAscNodeLAN lan = (IAgOrientationAscNodeLAN)classical.Orientation.AscNode;
            lan.Value = salan;

            //定义真近点角(?)来定义初始位置
            //Use true anomaly to specify the position of
            //the satellite in orbit
            classical.LocationType = AgEClassicalLocation.eLocationTrueAnomaly;
            IAgClassicalLocationTrueAnomaly trueAnomaly = (IAgClassicalLocationTrueAnomaly)classical.Location;
            trueAnomaly.Value = satra;


            //Assign the orbital elements to the TDRS
            //satellite's propagator and propagate the orbit	
            twobody.InitialState.Representation.Assign(classical);
            twobody.Propagate();

            root.Rewind();

            #endregion

            
            #region 放置接收站
            cruise = (IAgAircraft)root.CurrentScenario.Children.New(AgESTKObjectType.eAircraft, "Cruise");
            cruise.SetRouteType(AgEVePropagatorType.ePropagatorGreatArc);
            greatArc = (IAgVePropagatorGreatArc)cruise.Route;
            greatArc.EphemerisInterval.SetStartAndStopTimes(simstarttime, simstoptime);
            greatArc.Method = AgEVeWayPtCompMethod.eDetermineTimeAccFromVel;

            ((IAgVOModelFile)cruise.VO.Model.ModelData).Filename = @"\STKData\VO\Models\Air\rq-4a_globalhawk.mdl";
            cruise.VO.Offsets.Rotational.Enable = true;
            cruise.VO.Offsets.Rotational.X = 180;

            //Use the convenience method defined above
            //to add waypoints specifying the ship's route
            for (int ii = 0; ii < plwaypoints.Length; ii += 5)
            {
                AddWaypoint(greatArc.Waypoints, plwaypoints[ii], plwaypoints[ii + 1], plwaypoints[ii + 2], plwaypoints[ii + 3], plwaypoints[ii + 4]);
            }
              
            
            cruise.SetAttitudeType(AgEVeAttitude.eAttitudeStandard);
            IAgVeRouteAttitudeStandard attitude = (IAgVeRouteAttitudeStandard)cruise.Attitude;
            attitude.Basic.SetProfileType(AgEVeProfile.
                eProfileECFVelocityAlignmentWithRadialConstraint);
            cruise.Graphics.WaypointMarker.IsWaypointMarkersVisible = true;
            cruise.Graphics.WaypointMarker.IsTurnMarkersVisible = true;
            greatArc.Propagate();
            root.Rewind();


            #endregion

            #region 放置发射站雷达
            radar_t = (IAgSensor)root.CurrentScenario.Children["TDRS"].Children.New(AgESTKObjectType.eSensor, "radar_t");
            radar_t.SetPatternType(AgESnPattern.eSnSimpleConic);
            ((IAgSnSimpleConicPattern)radar_t.Pattern).ConeAngle = racoang;



            //Select a Fixed pointing type and the Az-El
            //orientation type, and set the elevation angle to
            //90 deg, so that the sensor points straight down
            //with reference to the satellite
            radar_t.SetPointingType(AgESnPointing.eSnPtFixed);
            IAgSnPtFixed fixedPt = (IAgSnPtFixed)radar_t.Pointing;
            IAgOrientationAzEl azEl = (IAgOrientationAzEl)fixedPt.Orientation.ConvertTo(AgEOrientationType.eAzEl);
            azEl.Elevation = raeleva;
            azEl.AboutBoresight = AgEAzElAboutBoresight.eAzElAboutBoresightRotate;
            fixedPt.Orientation.Assign(azEl);

            radar_t.Graphics.FillVisible = true;
            radar_t.VO.FillVisible = true;
            

            root.Rewind();


            #endregion


            #region 放置接收站雷达


            target = (IAgSensor)root.CurrentScenario.Children["TDRS"].Children.New(AgESTKObjectType.eSensor, "target");

            target.SetLocationType(AgESnLocation.eSnLocationCrdnPoint);
            IAgLocationCrdnPoint vgtPoint = target.LocationData as IAgLocationCrdnPoint;
            //vgtPoint.PointPath = "TDRS/radar_t BoresightIntersection(Terrain)";
            vgtPoint.PointPath = "Satellite/TDRS/Sensor/radar_t BoresightIntersection(Terrain)";
            target.SetPatternType(AgESnPattern.eSnSimpleConic);
            ((IAgSnSimpleConicPattern)target.Pattern).ConeAngle = 0.00001;
           
            

            IAgSnPtTargeted targetedSensor1 = target.CommonTasks.SetPointingTargetedTracking(
   AgETrackModeType.eTrackModeTranspond, AgEBoresightType.eBoresightRotate, "*/Aircraft/Cruise");


            target.SetPointingType(AgESnPointing.eSnPtTargeted);
            IAgSnPtTargeted rpt1 = (IAgSnPtTargeted)target.Pointing;
            rpt1.Boresight = AgESnPtTrgtBsightType.eSnPtTrgtBsightTracking;
            root.Rewind();
            rootapp.ExecuteCommand("Graphics */Satellite/TDRS/Sensor/target Show Off");


            /////////////////////////
            radar_r = (IAgSensor)root.CurrentScenario.Children["Cruise"].Children.New(AgESTKObjectType.eSensor, "radar_r");
            radar_r.SetPatternType(AgESnPattern.eSnSimpleConic);
            ((IAgSnSimpleConicPattern)radar_r.Pattern).ConeAngle = 3;
        

            IAgSnPtTargeted targetedSensor = radar_r.CommonTasks.SetPointingTargetedTracking(
    AgETrackModeType.eTrackModeTranspond, AgEBoresightType.eBoresightRotate, "*/Satellite/TDRS/Sensor/target");   

            
            radar_r.SetPointingType(AgESnPointing.eSnPtTargeted);
            IAgSnPtTargeted rpt = (IAgSnPtTargeted)radar_r.Pointing;
            rpt.Boresight = AgESnPtTrgtBsightType.eSnPtTrgtBsightTracking;
            

            root.Rewind();
            #endregion
        }
Ejemplo n.º 14
0
        //added selected TDRSs into the model
        private void add_tdrs(station_str passed)
        {
            IAgSatellite localtdrs;

            localtdrs = (IAgSatellite)m_oApplication.CurrentScenario.Children.New(AGI.STKObjects.AgESTKObjectType.eSatellite, passed.name);
            //AGI.STKObjects.IAgSatellite sat = (IAgSatellite)m_oApplication.CurrentScenario.Children.NewOnCentralBody(AGI.STKObjects.AgESTKObjectType.eSatellite, orbitdata[i].name, centerbodyname);
            //disable the leading ground track
            localtdrs.Graphics.PassData.GroundTrack.SetLeadDataType(AgELeadTrailData.eDataNone);
            //disable trailing ground track
            localtdrs.Graphics.PassData.GroundTrack.SetTrailDataType(AgELeadTrailData.eDataNone);
            localtdrs.VO.Pass.TrackData.PassData.GroundTrack.SetLeadDataType(AgELeadTrailData.eDataNone);
            localtdrs.VO.Pass.TrackData.PassData.GroundTrack.SetTrailDataType(AgELeadTrailData.eDataNone);

            localtdrs.VO.Pass.TrackData.PassData.Orbit.SetLeadDataType(AgELeadTrailData.eDataNone);
            localtdrs.VO.Pass.TrackData.PassData.Orbit.SetTrailDataType(AgELeadTrailData.eDataNone);

            //set the propagator type to HPOP
            localtdrs.SetPropagatorType(AGI.STKObjects.AgEVePropagatorType.ePropagatorJ2Perturbation);


            AGI.STKObjects.IAgVePropagatorJ2Perturbation hpop = (AGI.STKObjects.IAgVePropagatorJ2Perturbation)localtdrs.Propagator;

            IAgOrbitState orbit = hpop.InitialState.Representation;
            //create the string to hold the missions epoch date & time
            string cmb_epoch = startdate, cmb_end = enddate;

            cmb_epoch += " 00:00:00";
            DateTime epochDT    = Convert.ToDateTime(cmb_epoch);
            DateTime endepochDT = Convert.ToDateTime(cmb_end);


            //hpop.InitialState.Representation.Assign(orbit);
            Console.Write("epochtime = " + epochDT.ToString("dd MMM yyyy ") + "00:00:00" + "\n");
            hpop.InitialState.Representation.Epoch = (epochDT.ToString("dd MMM yyyy ") + "00:00:00");

            // hpop.InitialState.Representation.Assign(ia)
            //hpop.InitialState.Representation.AssignClassical(AgECoordinateSystem.eCoordinateSystemJ2000, orbitdata[i].sma, orbitdata[i].ecc, orbitdata[i].inc, orbitdata[i].aop, orbitdata[i].raan, orbitdata[i].ma);
            //hpop.Propagate();


            IAgOrbitStateClassical classical = (IAgOrbitStateClassical)hpop.InitialState.Representation.ConvertTo(AgEOrbitStateType.eOrbitStateClassical);

            classical.CoordinateSystemType = AGI.STKUtil.AgECoordinateSystem.eCoordinateSystemJ2000;
            IAgCrdnEventIntervalSmartInterval interval = hpop.EphemerisInterval;

            interval.SetExplicitInterval((epochDT.ToString("dd MMM yyyy ") + "00:00:00"), (endepochDT.ToString("dd MMM yyyy ") + "00:00:00"));

            hpop.Step = 60;
            classical.LocationType = AgEClassicalLocation.eLocationTrueAnomaly;
            IAgClassicalLocationTrueAnomaly trueAnomaly = (IAgClassicalLocationTrueAnomaly)classical.Location;

            trueAnomaly.Value = 178.845262;

            classical.SizeShapeType = AgEClassicalSizeShape.eSizeShapePeriod;
            IAgClassicalSizeShapePeriod period = (IAgClassicalSizeShapePeriod)classical.SizeShape;

            period.Eccentricity = 0.0;

            period.Period = 86164.090540;

            classical.Orientation.ArgOfPerigee = 0.0;

            classical.Orientation.Inclination = 0.0;

            classical.Orientation.AscNodeType = AgEOrientationAscNode.eAscNodeLAN;
            IAgOrientationAscNodeLAN lan = (IAgOrientationAscNodeLAN)classical.Orientation.AscNode;

            lan.Value = (360 - passed.lon);

            hpop.InitialState.Representation.Assign(classical);

            hpop.Propagate();
        }