Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 79 additions & 0 deletions StkAutomation/Matlab/STK Astrogator/PassiveSafety.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
function [passiveCheck,minRangeP, badManeuverTimes] = PassiveSafety(root, SatName, TargetName, userTrip, userMinRange)
%Get initial handles
scenario = root.CurrentScenario;
sat = root.GetObjectFromPath(strcat('Satellite/',SatName));
maneuverDP = sat.DataProviders.Item('Astrogator Maneuver Ephemeris Block Final').Group.Item('Cartesian Elems').Exec(scenario.StartTime,scenario.StopTime,60);
maneuverData = maneuverDP.DataSets;
%Get min range of overall trajectory
satDP = sat.DataProviders.Item('RIC Coordinates');
satDP.PreData = strcat('Satellite/',TargetName);
satDP2 = satDP.Exec(scenario.StartTime,scenario.StopTime,60);
range = satDP2.DataSets.GetDataSetByName('Range').GetValues();
minRange = min(cell2mat(range));

%Get total number of maneuvers in MCS
summaryDP1 = sat.DataProviders.Item('Maneuver Summary');
summaryDP = summaryDP1.Exec(scenario.StartTime,scenario.StopTime);
maneuverNumbers = summaryDP.DataSets.GetDataSetByName('Maneuver Number').GetValues();
maxManeuverNum = cell2mat(maneuverNumbers(length(maneuverNumbers)));


mcount =1;
if maneuverData.Count~=0
badManeuvers = 0;
%Create or grab handle to PassiveCheck Satellite
result = root.ExecuteCommand("DoesObjExist / */Satellite/PassiveCheck");
if result.Item(0)=="0"
passiveSat = scenario.Children.New('eSatellite','PassiveCheck');
else
passiveSat = root.GetObjectFromPath('Satellite/PassiveCheck');
end
passiveSat.SetPropagatorType('ePropagatorAstrogator');
passiveDriver = passiveSat.Propagator;
%Get handle to initial state and propagate segments in new sat
is = passiveDriver.mainSequence.Item(0);
prop = passiveDriver.mainSequence.Item(1);
sc = prop.StoppingConditions.Item(0);
sc.Properties.Trip = userTrip;
%Loop through each maneuver end state and assign it to the PassiveCheck
%satellite and propagate
for n=0:7:(maxManeuverNum*7-7)
is.OrbitEpoch = char(maneuverData.Item(n).GetValues());
is.Element.Vx = cell2mat(maneuverData.Item(n+1).GetValues());
is.Element.Vy = cell2mat(maneuverData.Item(n+2).GetValues());
is.Element.Vz = cell2mat(maneuverData.Item(n+3).GetValues());
is.Element.X = cell2mat(maneuverData.Item(n+4).GetValues());
is.Element.Y = cell2mat(maneuverData.Item(n+5).GetValues());
is.Element.Z = cell2mat(maneuverData.Item(n+6).GetValues());
passiveDriver.RunMCS();

%Movie Record Steps (movie record on in GUI)
% root.ExecuteCommand('Animate * Step Forward');
% root.ExecuteCommand('Animate * Step Forward');

%Pull minimum range data for run
psatDP = passiveSat.DataProviders.Item('RIC Coordinates');
psatDP.PreData = strcat('Satellite/',TargetName);
psatDP2 = psatDP.Exec(scenario.StartTime,scenario.StopTime,60);
range = psatDP2.DataSets.GetDataSetByName('Range').GetValues();
minRangeP(mcount) = min(cell2mat(range));
%Determine if minimum range meets requirements
if minRangeP(mcount)<userMinRange
badManeuvers = badManeuvers +1;
passiveCheck(mcount) = -1;
badManeuverTimes{badManeuvers} = maneuverData.Item(n).GetValues();
else
passiveCheck(mcount) = 1;
end
mcount = mcount + 1;
end
%If there is no maneuvers then check the minimum range for the trajectory
elseif minRange < userMinRange %km
passiveCheck(mcount) = -1;
minRangeP(mcount) = minRange;
else
passiveCheck(mcount) = 1;
minRangeP(mcount) = minRange;
end

end
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
%% Setup
clear all; close all; clc;

app=actxserver('STK11.application')
app.UserControl=1
root=app.personality2


%Define scenario name, time interval, and reset animation
scenario=root.Children.New('eScenario','SateliiteCoverage');
scenario.SetTimePeriod('Today','+1days');
root.ExecuteCommand('Animate * Reset');

%% Define Satellite
Sat=scenario.Children.New('eSatellite','MySat');
keplerian = Sat.Propagator.InitialState.Representation.ConvertTo('eOrbitStateClassical'); % Use the Classical Element interface
keplerian.SizeShapeType = 'eSizeShapeAltitude'; % Changes from Ecc/Inc to Perigee/Apogee Altitude
keplerian.LocationType = 'eLocationTrueAnomaly'; % Makes sure True Anomaly is being used
keplerian.Orientation.AscNodeType = 'eAscNodeLAN'; % Use LAN instead of RAAN for data entry

% Assign the perigee and apogee altitude values:
keplerian.SizeShape.PerigeeAltitude = 500; % km
keplerian.SizeShape.ApogeeAltitude = 600; % km

% Assign the other desired orbital parameters:
keplerian.Orientation.Inclination = 45; % deg
keplerian.Orientation.ArgOfPerigee = 0; % deg
keplerian.Orientation.AscNode.Value = 0; % deg
keplerian.Location.Value = 0; % deg

% Apply the changes made to the satellite's state and propagate:
Sat.Propagator.InitialState.Representation.Assign(keplerian);
Sat.Propagator.Propagate;

%% Define Coverage Definition and FOM
coverage = scenario.Children.New('eCoverageDefinition', 'MyCoverage');
coverage.Grid.BoundsType = 'eBoundsLatLonRegion';

coverage.Grid.Bounds.MinLatitude = -20; %deg lat
coverage.Grid.Bounds.MaxLatitude = 20; %deg lat
coverage.Grid.Bounds.MinLongitude = -20; %deg long
coverage.Grid.Bounds.MaxLongitude = 20; %deg long
resolution = coverage.Grid.Resolution;
resolution.LatLon=0.5;
coverage.AssetList.Add('Satellite/MySat');
coverage.ComputeAccesses;

fom=coverage.Children.New('eFigureOfMerit','NumDailyAccesses');
fom.SetDefinitionType('eFmNumberOfAccesses');
fom.Definition.SetComputeType('eMaxPerDay');

%% Pull FOM values

fomDP = fom.DataProviders.Item('Time Value By Point');
fomDP.PreData = '8 Nov 2018 05:00:00.000';
fomDP2 =fomDP.Exec;
pointLatitude = fomDP2.DataSets.GetDataSetByName('Latitude').GetValues;
pointLongitude = fomDP2.DataSets.GetDataSetByName('Longitude').GetValues;
pointFOMValue = fomDP2.DataSets.GetDataSetByName('FOM Value').GetValues;


81 changes: 81 additions & 0 deletions StkAutomation/Matlab/STK Object Model/SetLineThickness.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
% Attach to Scenario
app = actxGetRunningServer('STK11.Application');
root = app.Personality2;

% Inputs
[objPaths] = FilterObjectsByType('Satellite');
width = 'e3'; % Default is e1
res = 60*30; % sec

% Options
setLineWidth = 0;
setRes = 0;
setOrbitPass = 0;
setGroundPass = 0;
setDetailThresholds = 0;
removeTimeBeforeZero = 1;

%% Execute
% Turn of Ground Tracks
sc = root.CurrentScenario;
sc.Graphics.GndTracksVisible = 0;
sc.Graphics.GndMarkersVisible = 0;

% Adjust Settings For Each Object
for j = 1:length(objPaths)
obj = root.GetObjectFromPath(objPaths{j});

% Set Line Width, And Turn of GroundTracks
if setLineWidth == 1
obj.Graphics.Attributes.Default.Inherit = 1;
obj.Graphics.Attributes.Default.Line.Width = width;
numOfIntervals = obj.Graphics.Attributes.Intervals.Count;

for i = 0:numOfIntervals-1
interval = obj.Graphics.Attributes.Intervals.Item(i);
interval.GfxAttributes.Line.Width = width;
end
end


if removeTimeBeforeZero == 1
zeroUTCG = root.ConversionUtility.ConvertDate('EpSec','UTCG','0');
interval = obj.Graphics.Attributes.Intervals.Item(0);
StartEP = str2num(root.ConversionUtility.ConvertDate('UTCG','EpSec',interval.StartTime));
StopEP = str2num(root.ConversionUtility.ConvertDate('UTCG','EpSec',interval.StopTime));
if StartEP < 0 && StopEP > 0
intNew = obj.Graphics.Attributes.Intervals.Add(zeroUTCG,interval.StopTime);
interval.GfxAttributes.Inherit = false;
interval.GfxAttributes.IsOrbitVisible = false;
interval.GfxAttributes.IsGroundTrackVisible = false;
interval.StopTime = zeroUTCG;
intNew.GfxAttributes.Color = interval.GfxAttributes.Color;
end
end

% Set Orbit Resolution
if setRes == 1
obj.Graphics.Resolution.Orbit = res;
end

% Turn off Ground tracks
if setGroundPass == 1
obj.Graphics.PassData.GroundTrack.SetLeadDataType('eDataNone');
obj.Graphics.PassData.GroundTrack.SetTrailSameAsLead;
end

% Show only previous orbit tracks
if setOrbitPass == 1
obj.Graphics.PassData.Orbit.SetLeadDataType('eDataNone')
obj.Graphics.PassData.Orbit.SetTrailDataType('eDataAll');
end


if setDetailThresholds == 1
obj.VO.Model.DetailThreshold.All = 0.7;
obj.VO.Model.DetailThreshold.ModelLabel = 2; % [km]
obj.VO.Model.DetailThreshold.MarkerLabel = 1e6; % [km]
obj.VO.Model.DetailThreshold.Marker = 1e6; % [km]
obj.VO.Model.DetailThreshold.Point = 1e12; % [km]
end
end
Binary file added StkAutomation/VbScript/AdvCatAutomation.xlsm
Binary file not shown.
Binary file not shown.