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
40 changes: 40 additions & 0 deletions StkAutomation/Matlab/STK Object Model/LambertSolver_EarthToMars.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
%% Simple OM Script to compute DeltaV required for an Earth to Mars transit via Lambert Solver

% Get reference to running STK instance
uiApplication = actxGetRunningServer('STK12.application');
% Get our IAgStkObjectRoot interface
root = uiApplication.Personality2;

% create a custom lambert solver
root.ExecuteCommand("ComponentBrowser */ Duplicate ""Design Tools"" ""Lambert Solver"" EarthToMars");

% set the mode
root.ExecuteCommand("ComponentBrowser */ SetValue ""Design Tools"" EarthToMars LambertToolMode ""Specify initial and final central bodies""");

% set the central body
root.ExecuteCommand("ComponentBrowser */ SetValue ""Design Tools"" EarthToMars CentralBody Sun");

% set the propagator
root.ExecuteCommand("ComponentBrowser */ SetValue ""Design Tools"" EarthToMars Propagator Sun_Point_Mass");

% earth centre is the departing place
root.ExecuteCommand("ComponentBrowser */ SetValue ""Design Tools"" EarthToMars Departure.CentralBody Earth");
root.ExecuteCommand("ComponentBrowser */ SetValue ""Design Tools"" EarthToMars Departure.RadiusScaleFactor 0");

% mars centre is the arriving place
root.ExecuteCommand("ComponentBrowser */ SetValue ""Design Tools"" EarthToMars Arrival.CentralBody Mars");
root.ExecuteCommand("ComponentBrowser */ SetValue ""Design Tools"" EarthToMars Arrival.RadiusScaleFactor 0");

% set the departure epoch
root.ExecuteCommand("ComponentBrowser */ SetValue ""Design Tools"" EarthToMars InitEpoch ""15 Jun 2021 00:00:00.000"" UTCG");

% set the ToF
root.ExecuteCommand(strcat("ComponentBrowser */ SetValue ""Design Tools"" EarthToMars MinimumTOF 210 day"));

% compute
root.ExecuteCommand("ComponentBrowser */ LambertCompute ""Design Tools"" EarthToMars");

% get the result from the Lambert solver
deltaVTRes = root.ExecuteCommand("ComponentBrowser_RM */ GetValue ""Design Tools"" EarthToMars LambertResult.DeltaVT");
result = strsplit(deltaVTRes.Item(0));
deltaVT = str2double(result(3));
150 changes: 150 additions & 0 deletions StkAutomation/Matlab/STK Object Model/NoGraphicsTest.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
%% Create scenario, add facility with sensor, add area target, add aircraft, add satellite
% Compute access from facility to satellite, pull times of closest range for each access interval
% Values stored in timeArray and magnitudeArray
% tic/toc displays elapsed time for comparison between Graphics and NoGraphics

clearvars;
clear all;
clc;

%%

tic

%% With Graphics
STKApplication = actxserver('STK12.application');
root = STKApplication.Personality2;

%% NoGraphics mode
% Before instantiating AgStkObjectRoot an instance of AgSTKXApplication or an STK X control must be created.
% This also requires a STKX license to be present
% STKXApplication = actxserver('STKX12.application');
% STKXApplication.NoGraphics = true;
% root = actxserver('AgStkObjects12.AgStkObjectRoot');

%% Create new scenario
root.NewScenario('NoGraphicsModeTest');
scenario = root.CurrentScenario;
% set time units
root.UnitPreferences.Item('DateFormat').SetCurrentUnit('EpSec');
root.ExecuteCommand('SetUnits / EpSec');
% Get units
root.UnitPreferences.SetCurrentUnit('DateFormat','EpSec');
root.UnitPreferences.GetCurrentUnitAbbrv('DateFormat');
%root.ExecuteCommand('Animate * Reset');

%% Create Facility Object
facility = scenario.Children.New('eFacility','MyFacility');
facility = root.GetObjectFromPath('*/Facility/MyFacility');

facility.Position.AssignPlanetodetic(40,-80,0);

%% Create Sensor and define Type
sensor = facility.Children.New('eSensor','MySensor');
sensor.SetPatternType('eSnComplexConic');
sensor.CommonTasks.SetPatternComplexConic(50,90,0,90);
% add constraint to sensor
rangeConstraint = sensor.AccessConstraints.AddConstraint('eCstrRange');
rangeConstraint.EnableMax = true;
rangeConstraint. Max = 40;

%% Create area target
area = root.CurrentScenario.Children.New('eAreaTarget','MyArea');
area.AreaType = 'eEllipse';
ellipse = area.AreaTypeData;
ellipse.SemiMajorAxis = 100;
area.Position.AssignGeodetic(40,-80,0);

%% Create vehicle (aircraft) using GreatArc propagator
aircraft = root.CurrentScenario.Children.New('eAircraft','MyAircraft');
aircraft.SetRouteType('ePropagatorGreatArc');
greatArcPropagator = aircraft.Route;
% Create Aircraft Route
waypoint1 = greatArcPropagator.Waypoints.Add();
waypoint1.Latitude = 39;
waypoint1.Longitude = -79;
waypoint1.Altitude = 10;

waypoint2 = greatArcPropagator.Waypoints.Add();
waypoint2.Latitude = 40;
waypoint2.Longitude = -80;
waypoint2.Altitude = 10;

waypoint3 = greatArcPropagator.Waypoints.Add();
waypoint3.Latitude = 41;
waypoint3.Longitude = -81;
waypoint3.Altitude = 10;

greatArcPropagator.Propagate();

%% Create vehicle (satellite) using SPG4 propagator
satellite = root.CurrentScenario.Children.New('eSatellite','MySatellite');
% satellite.SetPropagatorType('ePropagatorSGP4');
% propagator = satellite.Propagator;
% propagator.CommonTasks.AddSegsFromOnlineSource('25544');
% propagator.Propagate();

% alternative code to set orbit with Keplerian elements
keplerian = satellite.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 = 600; % km
keplerian.SizeShape.ApogeeAltitude = 600; % km

% Assign the other desired orbital parameters:
keplerian.Orientation.Inclination = 40; % 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:
satellite.Propagator.InitialState.Representation.Assign(keplerian);
satellite.Propagator.Propagate;

% add access constraints to object
lightingConstraint = satellite.AccessConstraints.AddConstraint('eCstrLighting');
lightingConstraint.Condition = 'eDirectSun';

%% Create and calculate access
access = facility.GetAccessToObject(satellite);
access.ComputeAccess()

accessIntervals = access.ComputedAccessIntervalTimes;
accecssDataProvider = access.DataProviders.Item('AER Data').Group.Item('Default');
dataProviderElements = {'Time';'Azimuth';'Elevation';'Range'};

for i = 1:accessIntervals.Count
[start,stop] = accessIntervals.GetInterval(i-1);
dataProviderResult = accecssDataProvider.ExecElements(start,stop,1,dataProviderElements);
timeValues{i} = cell2mat(dataProviderResult.DataSets.GetDataSetByName('Time').GetValues);
azimuthValues{i} = cell2mat(dataProviderResult.DataSets.GetDataSetByName('Azimuth').GetValues);
elevationValues{i} = cell2mat(dataProviderResult.DataSets.GetDataSetByName('Elevation').GetValues);
rangeValues{i} = cell2mat(dataProviderResult.DataSets.GetDataSetByName('Range').GetValues);
end

% Create vector between objects
vector = facility.Vgt.Vectors.Factory.Create('FromTo','Vector description','eCrdnVectorTypeDisplacement');
vector.Destination.SetPoint(satellite.Vgt.Points.Item('Center'));

% Visualize the vector
% boresightVector = facility.VO.Vector.RefCrdns.Add('eVectorElem','Facility/MyFacility FromTo Vector');
% facility.VO.Vector.VectorSizeScale = 4.0;

%% Get built in Calculation object from Analysis Workbench
parameterSets = access.Vgt.ParameterSets.Item('From-To-AER(Body)');
% Get magnitude vector
magnitude = parameterSets.EmbeddedComponents.Item('From-To-AER(Body).Cartesian.Magnitude');
% Get times of the minimum value for each access interval
root.UnitPreferences.Item('DateFormat').SetCurrentUnit('UTCG');
minTimes = parameterSets.EmbeddedComponents.Item('From-To-AER(Body).Cartesian.Magnitude.TimesOfLocalMin');
timeArray = cell2mat(minTimes.FindTimes().Times);

for i = 1:size(timeArray,1)
result = magnitude.Evaluate(cell2mat(timeArray(i)));
magnitudeArray(i) = result.Value;
end

toc
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
DisplayName="Sensor Boresight View"
TypeName="SensorBoresightViewPlugin.SensorBoresightViewPlugin"
AssemblyName="SensorBoresightViewPlugin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"
CodeBase="Directory name where dll is found">
CodeBase="Directory/to/dll/file">
</NETUiPlugin>
</Category>
</CategoryRegistry>
</AGIRegistry>
</AGIRegistry>
Original file line number Diff line number Diff line change
Expand Up @@ -65,27 +65,27 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="AGI.STKObjects.Interop">
<HintPath>..\..\..\..\..\..\Program Files\AGI\STK 11\bin\Primary Interop Assemblies\AGI.STKObjects.Interop.dll</HintPath>
<HintPath>..\..\..\..\..\..\..\..\..\Program Files\AGI\STK 12\bin\Primary Interop Assemblies\AGI.STKObjects.Interop.dll</HintPath>
<EmbedInteropTypes>True</EmbedInteropTypes>
</Reference>
<Reference Include="AGI.STKUtil.Interop">
<HintPath>..\..\..\..\..\..\Program Files\AGI\STK 11\bin\Primary Interop Assemblies\AGI.STKUtil.Interop.dll</HintPath>
<HintPath>..\..\..\..\..\..\..\..\..\Program Files\AGI\STK 12\bin\Primary Interop Assemblies\AGI.STKUtil.Interop.dll</HintPath>
<EmbedInteropTypes>True</EmbedInteropTypes>
</Reference>
<Reference Include="AGI.STKVgt.Interop">
<HintPath>..\..\..\..\..\..\Program Files\AGI\STK 11\bin\Primary Interop Assemblies\AGI.STKVgt.Interop.dll</HintPath>
<HintPath>..\..\..\..\..\..\..\..\..\Program Files\AGI\STK 12\bin\Primary Interop Assemblies\AGI.STKVgt.Interop.dll</HintPath>
<EmbedInteropTypes>True</EmbedInteropTypes>
</Reference>
<Reference Include="AGI.Ui.Application.Interop">
<HintPath>..\..\..\..\..\..\Program Files\AGI\STK 11\bin\Primary Interop Assemblies\AGI.Ui.Application.Interop.dll</HintPath>
<HintPath>..\..\..\..\..\..\..\..\..\Program Files\AGI\STK 12\bin\Primary Interop Assemblies\AGI.Ui.Application.Interop.dll</HintPath>
<EmbedInteropTypes>True</EmbedInteropTypes>
</Reference>
<Reference Include="AGI.Ui.Core.Interop">
<HintPath>..\..\..\..\..\..\Program Files\AGI\STK 11\bin\Primary Interop Assemblies\AGI.Ui.Core.Interop.dll</HintPath>
<HintPath>..\..\..\..\..\..\..\..\..\Program Files\AGI\STK 12\bin\Primary Interop Assemblies\AGI.Ui.Core.Interop.dll</HintPath>
<EmbedInteropTypes>True</EmbedInteropTypes>
</Reference>
<Reference Include="AGI.Ui.Plugins.Interop">
<HintPath>..\..\..\..\..\..\Program Files\AGI\STK 11\bin\Primary Interop Assemblies\AGI.Ui.Plugins.Interop.dll</HintPath>
<HintPath>..\..\..\..\..\..\..\..\..\Program Files\AGI\STK 12\bin\Primary Interop Assemblies\AGI.Ui.Plugins.Interop.dll</HintPath>
<EmbedInteropTypes>True</EmbedInteropTypes>
</Reference>
<Reference Include="Microsoft.CSharp" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ public void CreateSensorWindow(int intVertPixels)
_root.ExecuteCommand("VO * Annotation ViewerPos Show Off WindowID " + _windowId);
_root.ExecuteCommand("VO * Annotation Frame Show Off WindowID " + _windowId);

string[] toolbars = { "3D Window Defaults", "3D Graphics", "3D Camera Control", "3D Object Editing", "3D Aircraft Mission Modeler Editing",
"Animation", "ArcGIS", "Globe Manager", "Microsoft Bingtm Maps"};
string[] toolbars = { "3D Window Defaults", "3D Graphics", "3D Camera Control", "3D Object Editing", "3D Aviator Editing",
"Animation", "ArcGIS", "Globe Manager", "Microsoft Bing Maps"};

foreach (var item in toolbars)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("SensorBoresightViewPlugin")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Analytical Graphics, Inc.")]
[assembly: AssemblyProduct("SensorBoresightViewPlugin")]
[assembly: AssemblyCopyright("Copyright © Analytical Graphics, Inc. 2008")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("5fa0b066-8e03-4a4e-b89d-80f541ebd4a4")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading