root.ExecuteCommand('New / */Satellite MySatellite');
root.ExecuteCommand('SetUnits / km');%Default Connect Units are meters
root.ExecuteCommand('SetState */Satellite/MySatellite Cartesian J4Perturbation "UseAnalysisStartTime" "UseAnalysisStopTime" 60 ICRF "UseAnalysisStartTime" 6678.14 0 0 0 6.78953 3.68641');
root.ExecuteCommand('SetUnits / km');%Default Connect Units are meters
root.ExecuteCommand('SetState */Satellite/MySatellite Classical TwoBody "UseAnalysisStartTime" "UseAnalysisStopTime" 60 ICRF "UseAnalysisStartTime" 6678.14 0 28 180 0 180');
root.ExecuteCommand('SetState */Satellite/MySatellite SGP4 "UseAnalysisStartTime" "UseAnalysisStopTime" 60 25544 TLESource Automatic Source AGIServer UseTLE All SwitchMethod Epoch'); %25544 is the International Space Station
root.ExecuteCommand('SetUnits / km');%Default Connect Units are meters
root.ExecuteCommand('SetState */Satellite/MySatellite Cartesian HPOP "UseAnalysisStartTime" "UseAnalysisStopTime" 60 Fixed "UseAnalysisStartTime" 6406.92 -1787.59 -506.422 2.10185 6.48871 3.64041');
root.ExecuteCommand('HPOP */Satellite/MySatellite Force Gravity "C:/Program Files/AGI/STK 12/STKData/CentralBodies/Earth/WGS84.grv" 21 21');
root.ExecuteCommand('HPOP */Satellite/MySatellite Drag On 0.01 0.01 "Jacchia 1960"');
root.ExecuteCommand('HPOP */Satellite/MySatellite Force SRP Off');
root.ExecuteCommand('HPOP */Satellite/MySatellite Integrator IntegMethod RKF78 StepControl RelativeError 1.0e-13 MinStepSize 0.1 MaxStepSize 30 InterpMethod LaGrange 7');
root.ExecuteCommand('SetState */Satellite/MySatellite SPICE File "C:/Program Files/AGI/STK 12/STKData/Spice/planets.bsp" BodyID 4 TimePeriod UseScenarioInterval');
scenPath = root.ExecuteCommand('GetDirectory / Scenario').Item(0);
root.ExecuteCommand(['ExportDataFile */Satellite/MySatellite Ephemeris "' scenPath '\MySatellite.e" Type STK CoordSys J2000 CentralBody Earth InterpBoundaries Include']);
uiap = actxserver('STK11.application');
root = uiap.Personality2;
root.NewScenario('MyScenario');
root.ExecuteCommand('New / */Satellite MySatellite');
root.ExecuteCommand('SetUnits / km');%Default Connect Units are meters
root.ExecuteCommand('SetState */Satellite/MySatellite Classical TwoBody "UseAnalysisStartTime" "UseAnalysisStopTime" 60 ICRF "UseAnalysisStartTime" 6678.14 0 28 180 0 180');
scenPath = root.ExecuteCommand('GetDirectory / Scenario').Item(0);
root.ExecuteCommand(['ExportDataFile */Satellite/MySatellite Ephemeris "' scenPath '\MySatellite.e" Type STK CoordSys J2000 CentralBody Earth InterpBoundaries Include']);
命令行输入:
cd(scenPath);
open MySatellite.e
root.ExecuteCommand('SetAttitude */Satellite/MySatellite Profile Spinning Inertial Axis 0 1 0 Body Axis 0 0 1 6 0 "UseAnalysisStartTime"');
root.ExecuteCommand('SetAttitude */Satellite/MySatellite File Filename "C:/Program Files/AGI/STK 11/Help/stktraining/text/AttitudeTimeEulerAngles_Example.a"');
uiap = actxserver('STK11.application');
root = uiap.Personality2;
root.NewScenario('MyScenario');
root.ExecuteCommand('New / */Satellite MySatellite');
root.ExecuteCommand('SetUnits / km');%Default Connect Units are meters
root.ExecuteCommand('SetState */Satellite/MySatellite Classical TwoBody "UseAnalysisStartTime" "UseAnalysisStopTime" 60 ICRF "UseAnalysisStartTime" 6678.14 0 28 180 0 180');
root.ExecuteCommand('SetAttitude */Satellite/MySatellite Profile Spinning Inertial Axis 0 1 0 Body Axis 0 0 1 6 0 "UseAnalysisStartTime"');
root.ExecuteCommand('SetAttitude */Satellite/MySatellite File Filename "C:/Program Files/AGI/STK 11/Help/stktraining/text/AttitudeTimeEulerAngles_Example.a"');
在stk的卫星三维视图中确实可以看到卫星姿态变化
注意:博主在测试官方例子的时候发现 root.ExecuteCommand('SetAttitude */Satellite/MySatellite File Filename "C:/Program Files/AGI/STK 11/Help/stktraining/text/AttitudeTimeEulerAngles_Example.a"');其中官方的代码与我电脑中AttitudeTimeEulerAngles_Example.a所在的路径有出入,如果不更改会出现调用错误
root.ExecuteCommand('SetAttitude */Satellite/MySatellite Target On');
root.ExecuteCommand('SetAttitude */Satellite/MySatellite Target Clear');
root.ExecuteCommand('SetAttitude */Satellite/MySatellite Target Add AreaTarget/MyAreaTarget Times UseAccess On');
uiap = actxserver('STK11.application');
root = uiap.Personality2;
root.NewScenario('MyScenario');
root.ExecuteCommand('New / */AreaTarget MyAreaTarget');
root.ExecuteCommand('SetBoundary */AreaTarget/MyAreaTarget Pattern LatLon 3 0 -75 20 -60 0 0');
root.ExecuteCommand('New / */Satellite MySatellite');
root.ExecuteCommand('SetUnits / km');%Default Connect Units are meters
root.ExecuteCommand('SetState */Satellite/MySatellite Classical TwoBody "UseAnalysisStartTime" "UseAnalysisStopTime" 60 ICRF "UseAnalysisStartTime" 6678.14 0 28 180 0 180');
root.ExecuteCommand('SetAttitude */Satellite/MySatellite Target On');
root.ExecuteCommand('SetAttitude */Satellite/MySatellite Target Clear');
root.ExecuteCommand('SetAttitude */Satellite/MySatellite Target Add AreaTarget/MyAreaTarget Times UseAccess On');
可实现卫星扫描到区域目标都会改变朝向
root.ExecuteCommand('SetAttitude */Satellite/MySatellite Target On');
root.ExecuteCommand('SetAttitude */Satellite/MySatellite Target Clear');
root.ExecuteCommand('SetAttitude */Satellite/MySatellite Target Add AreaTarget/MyAreaTarget Times UseAccess On');
root.ExecuteCommand('SetAttitude */Satellite/MySatellite Target Slew Mode Constrained MaxSlewTime 20 SlewTimingBetweenTgts Optimal');
root.ExecuteCommand('SetAttitude */Satellite/MySatellite Target Slew Mode Constrained RateMagnitude 10 RateAxisX On RateAxisY On RateAxisZ On AccelMagnitude 10 AccelAxisX On AccelAxisY On AccelAxisZ On');
root.ExecuteCommand('SetAttitude */Satellite/MySatellite Target Slew Mode Constrained RateAxisX 5 RateAxisY 5 RateAxisZ 5 AccelAxisX 5 AccelAxisY 5 AccelAxisZ 5');
root.ExecuteCommand('VO */Satellite/MySatellite ModelPointing "Solar_PanelsNode" Target Sun');
root.ExecuteCommand('Astrogator */Satellite/MySatellite SetProp');
ASTGSegments = root.ExecuteCommand('Astrogator_RM */Satellite/MySatellite GetValue MainSequence.SegmentList');
for j = 0:ASTGSegments.Count - 2
Segment = strread(ASTGSegments.Item(j), '%s');
root.ExecuteCommand(['Astrogator */Satellite/MySatellite DeleteSegment ' Segment{1}]);
end
root.ExecuteCommand('Astrogator */Satellite/MySatellite InsertSegment - Initial_State'); root.ExecuteCommand('Astrogator */Satellite/MySatellite SetValue MainSequence.SegmentList.Initial_State.ComponentName Inner_Orbit'); %change name of the segment
root.ExecuteCommand('Astrogator */Satellite/MySatellite SetValue MainSequence.SegmentList.Inner_Orbit.InitialState.Epoch 0 EpSec'); %set epoch
root.ExecuteCommand('Astrogator */Satellite/MySatellite SetValue MainSequence.SegmentList.Inner_Orbit.InitialState.Keplerian.ElementType Osculating');
root.ExecuteCommand('Astrogator */Satellite/MySatellite SetValue MainSequence.SegmentList.Inner_Orbit.InitialState.Keplerian.PeriapsisRadSize 6700 km'); %default units are m
root.ExecuteCommand('Astrogator */Satellite/MySatellite SetValue MainSequence.SegmentList.Inner_Orbit.InitialState.Keplerian.w 0');
root.ExecuteCommand('Astrogator */Satellite/MySatellite SetValue MainSequence.SegmentList.Inner_Orbit.InitialState.Keplerian.ecc 0');
root.ExecuteCommand('Astrogator */Satellite/MySatellite SetValue MainSequence.SegmentList.Inner_Orbit.InitialState.Keplerian.inc 0');
root.ExecuteCommand('Astrogator */Satellite/MySatellite SetValue MainSequence.SegmentList.Inner_Orbit.InitialState.Keplerian.RAAN 0');
root.ExecuteCommand('Astrogator */Satellite/MySatellite SetValue MainSequence.SegmentList.Inner_Orbit.InitialState.Keplerian.TA 0');
root.ExecuteCommand('Astrogator */Satellite/MySatellite InsertSegment - Propagate');
root.ExecuteCommand('Astrogator */Satellite/MySatellite SetValue MainSequence.SegmentList.Propagate.ComponentName Transfer_Ellipse'); %change name of the segment
root.ExecuteCommand('Astrogator */Satellite/MySatellite SetValue MainSequence.SegmentList.Transfer_Ellipse.Propagator "Earth Point Mass"');
root.ExecuteCommand('Astrogator */Satellite/MySatellite SetValue MainSequence.SegmentList.Transfer_Ellipse.StoppingConditions Duration');
root.ExecuteCommand('Astrogator */Satellite/MySatellite SetValue MainSequence.SegmentList.Transfer_Ellipse.StoppingConditions.Duration.TripValue 7200 Sec');
root.ExecuteCommand('Astrogator */Satellite/MySatellite SetValue MainSequence.SegmentList.Transfer_Ellipse.SegmentColor 16711680'); %set segment color to blue
root.ExecuteCommand('Astrogator */Satellite/MySatellite InsertSegment - Propagate');
root.ExecuteCommand('Astrogator */Satellite/MySatellite SetValue MainSequence.SegmentList.Propagate.ComponentName Propagate2'); %change name of the segment
root.ExecuteCommand('Astrogator */Satellite/MySatellite SetValue MainSequence.SegmentList.Propagate2.StoppingConditions Apoapsis'); %overwrites any stopping conditions already there, unless specified
root.ExecuteCommand('Astrogator */Satellite/MySatellite InsertSegment - Target_Sequence');
root.ExecuteCommand('Astrogator */Satellite/MySatellite SetValue MainSequence.SegmentList.Target_Sequence.ComponentName Start_Transfer'); %change name of the segment
root.ExecuteCommand('Astrogator */Satellite/MySatellite InsertSegment MainSequence.SegmentList.Start_Transfer.SegmentList.- Maneuver');
root.ExecuteCommand('Astrogator */Satellite/MySatellite SetValue MainSequence.SegmentList.Start_Transfer.SegmentList.Maneuver.ComponentName DV1');
root.ExecuteCommand('Astrogator */Satellite/MySatellite SetValue MainSequence.SegmentList.Start_Transfer.SegmentList.DV1.MnvrType Impulsive');
root.ExecuteCommand('Astrogator */Satellite/MySatellite SetValue MainSequence.SegmentList.Start_Transfer.SegmentList.DV1.AttitudeControl Thrust Vector');
root.ExecuteCommand('Astrogator */Satellite/MySatellite SetValue MainSequence.SegmentList.Start_Transfer.SegmentList.DV1.ThrustAxes "Satellite VNC(Earth)"');
root.ExecuteCommand('Astrogator */Satellite/MySatellite AddMCSSegmentControl MainSequence.SegmentList.Start_Transfer.SegmentList.DV1 ImpulsiveMnvr.Cartesian.X');
root.ExecuteCommand('Astrogator */Satellite/MySatellite SetValue MainSequence.SegmentList.Start_Transfer.SegmentList.DV1.Results "Radius Of Apoapsis"');
root.ExecuteCommand('Astrogator */Satellite/MySatellite SetMCSControlValue MainSequence.SegmentList.Start_Transfer.Profiles.Differential_Corrector DV1 ImpulsiveMnvr.Cartesian.X Active true');
root.ExecuteCommand('Astrogator */Satellite/MySatellite SetMCSControlValue MainSequence.SegmentList.Start_Transfer.Profiles.Differential_Corrector DV1 ImpulsiveMnvr.Cartesian.X MaxStep 0.3 m/sec');
root.ExecuteCommand('Astrogator */Satellite/MySatellite SetMCSConstraintValue MainSequence.SegmentList.Start_Transfer.Profiles.Differential_Corrector DV1 "Radius Of Apoapsis" Active true');
root.ExecuteCommand('Astrogator */Satellite/MySatellite SetMCSConstraintValue MainSequence.SegmentList.Start_Transfer.Profiles.Differential_Corrector DV1 "Radius Of Apoapsis" Desired 42238 km');
root.ExecuteCommand('Astrogator */Satellite/MySatellite SetMCSConstraintValue MainSequence.SegmentList.Start_Transfer.Profiles.Differential_Corrector DV1 "Radius Of Apoapsis" Tolerance 0.1 km');
root.ExecuteCommand('Astrogator */Satellite/MySatellite SetValue MainSequence.SegmentList.Start_Transfer.Profiles.Differential_Corrector.MaxIterations 50');
root.ExecuteCommand('Astrogator */Satellite/MySatellite SetValue MainSequence.SegmentList.Start_Transfer.Action Run active profiles');
root.ExecuteCommand('Astrogator */Satellite/MySatellite RunMCS');
root.ExecuteCommand('Astrogator */Satellite/MySatellite RunMCS');