public static bool Is_Error_Propagator(IAgVePropagatorJ2Perturbation prop, ref string type) { // returns true if there is an error with propagator and "type" what was issue // returns false if there isn't an error and will propagate if (IsCircular(prop) && IsApogeeAboveGround(prop) && IsPerigeePositive(prop)) { prop.Propagate(); return(false); } else if (!IsCircular(prop)) { type = "Parabolic or hyperbolic orbit"; } else if (!IsApogeeAboveGround(prop)) { type = "Apogee too low"; } else { type = "Perigee too low"; } return(true); }
public static bool UpdateDelaunayOrbit(IAgSatellite sat, double lD, double gD, double hD, double LD, double GD, double HD, ref string error) { IAgVePropagatorJ2Perturbation prop = sat.Propagator as IAgVePropagatorJ2Perturbation; // there is no AssignDelaunay so we need to do this one at a time IAgOrbitStateDelaunay delaunay = prop.InitialState.Representation.ConvertTo(AgEOrbitStateType.eOrbitStateDelaunay) as IAgOrbitStateDelaunay; delaunay.MeanAnomaly = lD; delaunay.ArgOfPeriapsis = gD; delaunay.RAAN = hD; delaunay.LType = AgEDelaunayLType.eL; IAgDelaunayL delaunayL = delaunay.L as IAgDelaunayL; delaunayL.L = LD; delaunay.GType = AgEDelaunayGType.eG; IAgDelaunayG delaunayG = delaunay.G as IAgDelaunayG; delaunayG.G = GD; delaunay.HType = AgEDelaunayHType.eH; IAgDelaunayH delaunayH = delaunay.H as IAgDelaunayH; delaunayH.H = HD; prop.InitialState.Representation.Assign(delaunay); return(Is_Error_Propagator(prop, ref error)); }
public static bool UpdateCartesianOrbit(IAgSatellite sat, double x, double y, double z, double dx, double dy, double dz, ref string error) { IAgVePropagatorJ2Perturbation prop = sat.Propagator as IAgVePropagatorJ2Perturbation; prop.InitialState.Representation.AssignCartesian(AgECoordinateSystem.eCoordinateSystemICRF, x, y, z, dx, dy, dz); return(Is_Error_Propagator(prop, ref error)); }
public static bool UpdateMixedSphericalOrbit(IAgSatellite sat, double lonM, double latM, double altM, double fpaM, double azM, double velM, ref string error) { IAgVePropagatorJ2Perturbation prop = sat.Propagator as IAgVePropagatorJ2Perturbation; prop.InitialState.Representation.AssignMixedSpherical(AgECoordinateSystem.eCoordinateSystemICRF, latM, lonM, altM, fpaM, azM, velM); return(Is_Error_Propagator(prop, ref error)); }
public static bool UpdateSphericalOrbit(IAgSatellite sat, double raS, double decS, double radS, double fpaS, double azS, double velS, ref string error) { IAgVePropagatorJ2Perturbation prop = sat.Propagator as IAgVePropagatorJ2Perturbation; prop.InitialState.Representation.AssignSpherical(AgECoordinateSystem.eCoordinateSystemICRF, raS, decS, radS, fpaS, azS, velS); return(Is_Error_Propagator(prop, ref error)); }
//Uses a satellite object to create a time component if AWB is not available public static void CreateTimelineComponentNoAwb(GroundEvent currentGroundEvent) { IAgSatellite sat; string mes = null; bool error = false; string satName = "z" + currentGroundEvent.Id + "-TimelineObject"; try { string cmd1 = "Timeline * TimeComponent Remove ContentView \"Event_Timeline\" \"Satellite/" + satName + " AvailabilityTimeSpan Interval\""; CommonData.StkRoot.ExecuteCommand(cmd1); } catch (Exception) { } IAgExecCmdResult result = CommonData.StkRoot.ExecuteCommand("DoesObjExist / */Satellite/" + satName); if (result[0] == "0") { sat = CommonData.StkRoot.CurrentScenario.Children.New(AgESTKObjectType.eSatellite, satName) as IAgSatellite; } else { sat = CommonData.StkRoot.GetObjectFromPath("Satellite/" + satName) as IAgSatellite; } try { ((IAgSatellite)sat).SetPropagatorType(AgEVePropagatorType.ePropagatorJ2Perturbation); IAgVePropagatorJ2Perturbation prop = sat.Propagator as IAgVePropagatorJ2Perturbation; prop.EphemerisInterval.SetExplicitInterval(currentGroundEvent.StartTime, currentGroundEvent.StopTime); prop.Propagate(); } catch (Exception) { error = true; mes = "Error with " + currentGroundEvent.Id + ": Could not update or create time component- Error with Start or Stop Time"; } sat.Graphics.IsObjectGraphicsVisible = false; try { string cmd = "Timeline * TimeComponent Add ContentView \"Event_Timeline\" DisplayName \"" + currentGroundEvent.Id + "-Interval\" \"Satellite/" + satName + " AvailabilityTimeSpan Interval\""; CommonData.StkRoot.ExecuteCommand(cmd); } catch (Exception) { error = true; mes = "Error with " + currentGroundEvent.Id + ": Could not update or create time component- Error with Start or Stop Time"; } CommonData.StkRoot.ExecuteCommand("Timeline * Refresh"); if (error) { MessageBox.Show(mes); } }
// 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); }
public void set_InitStateJx(object InitStateObj, string name, double value) { if (name == "SemiMajorAxis") { SemiMajorAxis = value; } else if (name == "Eccentricity") { Eccentricity = value; } else if (name == "Inclination") { Inclination = value; } else if (name == "ArgOfPerigee") { ArgOfPerigee = value; } else if (name == "RAAN") { RAAN = value; } else if (name == "TrueAnomaly") { TrueAnomaly = value; } IAgSatellite sat = InitStateObj as IAgSatellite; if (sat.PropagatorType == AgEVePropagatorType.ePropagatorJ2Perturbation) { IAgVePropagatorJ2Perturbation prop = sat.Propagator as IAgVePropagatorJ2Perturbation; prop.InitialState.Representation.AssignClassical(AgECoordinateSystem.eCoordinateSystemICRF, SemiMajorAxis, Eccentricity, Inclination, ArgOfPerigee, RAAN, TrueAnomaly); prop.Propagate(); } if (sat.PropagatorType == AgEVePropagatorType.ePropagatorJ4Perturbation) { IAgVePropagatorJ4Perturbation prop = sat.Propagator as IAgVePropagatorJ4Perturbation; prop.InitialState.Representation.AssignClassical(AgECoordinateSystem.eCoordinateSystemICRF, SemiMajorAxis, Eccentricity, Inclination, ArgOfPerigee, RAAN, TrueAnomaly); prop.Propagate(); } if (sat.PropagatorType == AgEVePropagatorType.ePropagatorTwoBody) { IAgVePropagatorTwoBody prop = sat.Propagator as IAgVePropagatorTwoBody; prop.InitialState.Representation.AssignClassical(AgECoordinateSystem.eCoordinateSystemICRF, SemiMajorAxis, Eccentricity, Inclination, ArgOfPerigee, RAAN, TrueAnomaly); prop.Propagate(); } }
public static void CreateSat(IAgSatellite m_satellite) { if (StkRoot.CurrentScenario.Children.Contains(AgESTKObjectType.eSatellite, "OrbitTunerSat")) { return; } m_satellite = StkRoot.CurrentScenario.Children.New(AgESTKObjectType.eSatellite, "OrbitTunerSat") as IAgSatellite; // set prop. to J2 pertubation m_satellite.SetPropagatorType(AgEVePropagatorType.ePropagatorJ2Perturbation); STKHelper.SetMaxViewing(m_satellite); // get the j2 perturbation propagator IAgVePropagatorJ2Perturbation prop = m_satellite.Propagator as IAgVePropagatorJ2Perturbation; prop.Propagate(); }
// 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); }
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); } }
// 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); }
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(); }
public static bool UpdateEquinocitalOrbit(IAgSatellite sat, double aE, double hE, double kE, double pE, double qE, double mE, ref string error, string equinBox) { IAgVePropagatorJ2Perturbation prop = sat.Propagator as IAgVePropagatorJ2Perturbation; try { if (equinBox == "Posigrade") { prop.InitialState.Representation.AssignEquinoctialPosigrade(AgECoordinateSystem.eCoordinateSystemICRF, aE, hE, kE, pE, qE, mE); } else { prop.InitialState.Representation.AssignEquinoctialRetrograde(AgECoordinateSystem.eCoordinateSystemICRF, aE, hE, kE, pE, qE, mE); } } catch { } return(Is_Error_Propagator(prop, ref error)); }
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)); }
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); } } }
//Satellite helpers public static void ChangeSatelliteInterval(IAgSatellite sat, string startTime, string stopTime, bool astgRun) { AgEVePropagatorType propType = sat.PropagatorType; //IAgVePropagator prop = sat.Propagator; switch (propType) { case AgEVePropagatorType.eUnknownPropagator: break; case AgEVePropagatorType.ePropagatorHPOP: IAgVePropagatorHPOP prop = sat.Propagator as IAgVePropagatorHPOP; prop.EphemerisInterval.SetExplicitInterval(startTime, stopTime); prop.Propagate(); break; case AgEVePropagatorType.ePropagatorJ2Perturbation: IAgVePropagatorJ2Perturbation prop1 = sat.Propagator as IAgVePropagatorJ2Perturbation; prop1.EphemerisInterval.SetExplicitInterval(startTime, stopTime); prop1.Propagate(); break; case AgEVePropagatorType.ePropagatorJ4Perturbation: IAgVePropagatorJ4Perturbation prop2 = sat.Propagator as IAgVePropagatorJ4Perturbation; prop2.EphemerisInterval.SetExplicitInterval(startTime, stopTime); prop2.Propagate(); break; case AgEVePropagatorType.ePropagatorLOP: IAgVePropagatorLOP prop3 = sat.Propagator as IAgVePropagatorLOP; prop3.EphemerisInterval.SetExplicitInterval(startTime, stopTime); prop3.Propagate(); break; case AgEVePropagatorType.ePropagatorSGP4: IAgVePropagatorSGP4 prop4 = sat.Propagator as IAgVePropagatorSGP4; prop4.EphemerisInterval.SetExplicitInterval(startTime, stopTime); prop4.Propagate(); break; case AgEVePropagatorType.ePropagatorSPICE: IAgVePropagatorSPICE prop5 = sat.Propagator as IAgVePropagatorSPICE; prop5.EphemerisInterval.SetExplicitInterval(startTime, stopTime); prop5.Propagate(); break; case AgEVePropagatorType.ePropagatorStkExternal: IAgVePropagatorStkExternal prop6 = sat.Propagator as IAgVePropagatorStkExternal; //prop6.EphemerisInterval.SetExplicitInterval(startTime, stopTime); break; case AgEVePropagatorType.ePropagatorTwoBody: IAgVePropagatorTwoBody prop7 = sat.Propagator as IAgVePropagatorTwoBody; prop7.EphemerisInterval.SetExplicitInterval(startTime, stopTime); prop7.Propagate(); break; case AgEVePropagatorType.ePropagatorUserExternal: break; case AgEVePropagatorType.ePropagatorGreatArc: IAgVePropagatorGreatArc prop8 = sat.Propagator as IAgVePropagatorGreatArc; prop8.EphemerisInterval.SetExplicitInterval(startTime, stopTime); prop8.Propagate(); break; case AgEVePropagatorType.ePropagatorBallistic: break; case AgEVePropagatorType.ePropagatorSimpleAscent: break; case AgEVePropagatorType.ePropagatorAstrogator: if (astgRun) { IAgVADriverMCS driver = sat.Propagator as IAgVADriverMCS; driver.RunMCS(); } break; case AgEVePropagatorType.ePropagatorRealtime: break; case AgEVePropagatorType.ePropagatorGPS: IAgVePropagatorGPS prop9 = sat.Propagator as IAgVePropagatorGPS; prop9.EphemerisInterval.SetExplicitInterval(startTime, stopTime); prop9.Propagate(); break; case AgEVePropagatorType.ePropagatorAviator: break; case AgEVePropagatorType.ePropagator11Param: IAgVePropagator11Param prop10 = sat.Propagator as IAgVePropagator11Param; prop10.EphemerisInterval.SetExplicitInterval(startTime, stopTime); prop10.Propagate(); break; case AgEVePropagatorType.ePropagatorSP3: IAgVePropagatorSP3 prop11 = sat.Propagator as IAgVePropagatorSP3; //prop11.EphemerisInterval.SetExplicitInterval(startTime, stopTime); break; default: break; } }