Presentation is loading. Please wait.

Presentation is loading. Please wait.

Integrating STK with other applications (MATLAB, Excel, Python, etc)

Similar presentations


Presentation on theme: "Integrating STK with other applications (MATLAB, Excel, Python, etc)"— Presentation transcript:

1 Integrating STK with other applications (MATLAB, Excel, Python, etc)

2 STK Integration Module
Enhances out-of-the-box automation and integration capabilities that come with STK Automate repetitive tasks from outside the STK application Develop custom applications Leverage the AGI Object Model collection of COM libraries from other applications (e.g. MATLAB, Excel, Python) Read Slide

3 Integrate STK and other applications
Mutually extend and leverage each application’s analytical capabilities STK provides vehicle dynamics, sensors, communications, time-based visualization, physical environment models, figures of mission effectiveness, etc. Other applications provide numerical analysis, advanced plotting capabilities, and a programming environment Read Slide

4 Advantages of Integration
Integrate STK and other applications to automate, extend or visualize your analysis Automate Access the capabilities of both tools without the need to switch between application sessions Extend Extend or augment the types of analysis that you can perform with just one of them alone Visualize Use STK's 2D and 3D visualization to view any geo-referenced or geometric data from other applications Automate You can use MATLAB to modify a scenario or object for trade study analysis and bring those results into MATLAB for further analysis. You can use STK to evaluate mission or relative geometric conditions such as range or inter-visibility between objects or S/N ratios, etc. When a specific figure of mission effectiveness or geometric condition is met, MATLAB can automatically begin additional functions. Extend Use STK's satellite propagators in your MATLAB analysis. Define a customer’s sensor in MATLAB and then load it into STK. Utilize MATLAB’s post-processing on STK-generated data. Create a MATLAB custom vector plugin for STK. Visualize Large data sets from STK can be loaded into MATLAB, where you can use its native 2D and 3D plotting capabilities to help understand the data and communicate the results.

5 Core Programming Libraries
Connect Commands sent using: Object Model: root.ExecuteCommand(command) MexConnect: stkExec(conid, command) Documentation available in the STK Programming Interface help < Contents > STK Programming Interface > Library Reference > Connect Command Library The core programming libraries we’re going to go over are Connect and The Object Model. Connect: The Connect module provides you with an easy way to connect with STK and work in a client-server environment.  Connect commands can be sent off the Object Model using the object root with root.ExecuteCommand. Similarly, with the MexConnect interface you can use the stkExec function to send commands.

6 Core Programming Libraries (Cont)
Object Model Objects created/modified off of the STK application root Documentation available in the STK Programming Interface help < Contents > STK Programming Interface > Library Reference > STK Object Model Object model: The STK Object Model is a collection of COM libraries containing types, interfaces, events and classes representing various aspects of the STK application structure, which is designed to make it easy for you to build custom solutions using STK and the STK Engine. Similarly with Object Model, you can create/modify objects off of the STK Application root.

7 AgSTKObjectRoot Top-level object in the Object Model Hierarchy
Access all other objects and collections exposed by the Object Model The only object that can be created directly The rest of the object model hierarchy can only be accessed indirectly Relies upon the following objects and interfaces:  AgStkObjectRoot, IAgStkObject and AgStkObjectCollection. Read slide

8 Object Model Navigation
AgStkObjectRoot Provides methods and properties to load scenarios, create new ones and access the Object Model Unit preferences IAgStkObject Exposes methods and properties Permits navigation up and down the object hierarchy Learn about the object's name, type, path and subordinate objects, perform access and coverage computations, and invoke the object's data providers IAgStkObjectCollection Holds children objects of a particular object The collection object exposes properties and methods to iterate or enumerate children, create new objects or unload existing ones Read Slide

9 Code Snippets Demonstrate tasks that are commonly encountered when working with the STK Object Model Documentation available in the STK Programming Interface help < Contents > STK Programming Interface > Using Core Libraries > STK Object Model > MATLAB Code Snippets Read slide

10 Let’s Work Together Ease of Use Level of Integration
STK reports for trajectories, access, etc. Simple text file import/export Open API for scripting Uses the Connect Command Library Open API for programming Object Orientated Programing Work with events and data providers Ease of Use Plugins Object Model Connect File Import/Export Dynamic calculations Incorporate customer-specific modeling into STK computations This slide simply shows the progression from ease of use to level of integration.

11 MATLAB/STK Interface Options
The easiest and most over looked method, albeit the least “integrated” for getting data in and out of STK, is the file interoperability path. Generate data, write to disk, read the data. In STK, generate a report and save it to disk. In MATLAB use the file import tool. No Operating System issues, no 32bit vs. 64 bit issues etc. Can be time consuming: disk input/output, asynchronous communication, etc. On another Level, STK has two APIs that allow you to communicate with and control STK. Connect Connect is the language of STK. At a very high level, Connect is a set of command strings that are generated and received as ASCII text. Use any programming language that can get to an open socket. Send the commands via the Object Model. Commands are the same regardless of language (C#, Python, etc.). Very readable. Object Model The other API is the Object Model – which is really a Microsoft COM library. Object oriented: gives you types, interfaces, events, classes and the productivity that modern programming allows. MATLAB offers intellisense. Use languages or applications that are compatible with Microsoft COM. Note the two APIs located at the top and bottom of the application The top line represents the object model leveraging Microsoft COM. - COM is what this tutorial will use. - No version concerns nor 32bit/64bit concerns. - Connect commands can be sent through COM. - Requires a Windows operated PC. The bottom line represents the STK-MATLAB connector available from AGI website. Installed to bridge the Connect with Integration and Plug-in development environment. Should always be able to use the latest version of MATLAB. Installation instructions are online. Need to be aware of 32bit vs. 64 bit concerns. Unlike file interoperability, if you’re using MATLAB to drive STK with either API, that’s where an Integration license is going to be needed. You can use these APIs within STK without the license, but if you’re accessing them externally, you will need it. Finally within the blue box (Aero toolbox) or the green box (Plugins), you have the ability to run pieces of either software from within the other. Aero toolbox provides very basic STK functionality. STK comes with plugins. User plugins allow you to incorporate customer specific modeling into STK computations. All throughout STK there are plug-in points where you can use the custom/classified/proprietary algorithms to add new or to replace existing capabilities. And you can use MATLAB for those plug-in scripts.

12 Interface Decision Tree
Show progression and discuss slide

13 MATLAB Script Code (Task 1)
Open MATLAB_Script.m file in MATLAB. Create an instance of STK. app = actxserver('STK11.application') app.UserControl = 1 Grab a handle on the STK application root. root = app.Personality2 Task 1 Follow the instructions in the tutorial to locate and load the MATLAB script file. Create an instance of STK. A variable is created, in this case app = actxserver, and it is told to connect to STK11. Type app = actxserver('STK11.application‘) and click Enter. You might see the STK 11 splash screen which indicates STK is loading and will see information in the command window indicating STK is initialized. Type app. After the period, click the Tab key to open IntelliSense. Select UserControl and click Enter. After UserControl, type = 1 and click Enter. Grab a handle on the STK application root In the Command Window, type root = app. After the period, click the Tab key to open IntelliSense. Select Personality2 and click Enter in the Command Window and click Enter. You now have your app and root declared. That’s how easy it is to get MATLAB talking to STK!

14 MATLAB Script Code (Task 2)
Create a new scenario, analysis period and reset the animation time. scenario = root.Children.New('eScenario','MATLAB_Starter'); scenario.SetTimePeriod('Today','+24hr') root.ExecuteCommand('Animate * Reset') Task 2 Create a new scenario, analysis period and reset the animation time. Next you need to create a Scenario object. First you create a variable, in this case scenario. The Scenario object is a child object of the root and you make a new one. The syntax is the enumeration for the object type and then the name of the Scenario object. When setting the analysis period, you have a couple of choices. You can the Start and Stop time individually or set them together. For this tutorial, we’ll set them together by using the scenario interface and SetTimePeriod. The syntax is by placing the Start and Stop time in a string. The scenario start time of “Today” sets the analysis start time to midnight local time and the equivalent Zulu time. By resetting the animation time, the new start time will be reflected in the Animation Toolbar. We’ll use the Animate Connect command.

15 MATLAB Script Code (Task 3)
Insert Target and Satellite objects into the scenario. target = scenario.Children.New('eTarget','GroundTarget'); target.Position.AssignGeodetic(50,-100,0) satellite = scenario.Children.New('eSatellite','LeoSat'); root.ExecuteCommand(['SetState */Satellite/LeoSat Classical TwoBody "',scenario.StartTime,'" "',scenario.StopTime,'" 60 ICRF "',scenario.StartTime,'" ']) Task 3 Insert Target and Satellite objects into the scenario. Next create a Target object. First you create a variable, in this case target. The Target object is a child object of the Scenario object and you make a new one. The syntax is the enumeration for the object type and then the name of the Target object. The default Target object’s location is zero degrees latitude and zero degrees longitude. We can use a Connect command or the Object Model to move the Target object to a desired location using the Object Model. Off of target we used Position. There are different coordinate types in STK such as Geodetic, Spherical, Cartesian (Fixed), Cylindrical, and Geocentric. In this case, we used Geodetic coordinates of 50 degrees latitude and -100 degrees longitude. The trailing 0 is altitude which places the target object on the surface of the central body. Add a Satellite object. First you create a variable, in this case satellite. The Satellite object is a child object of the Scenario object and you make a new one. The syntax is the enumeration for the object type and then the name of the Satellite object. The Satellite object has been loaded into the scenario, but the orbit still needs to be propagated. You can use the Object Model to set the orbital parameters individually or the SetState Connect command to set them all at the same time. The syntax for this command is: SetState <VehObjectPath> Classical {Propagator} {NoProp | {TimeInterval}} <StepSize> {CoordSystem} "<OrbitEpoch>" <SemiMajorAxis> <Eccentricity> <Inclination> <ArgOfPerigee> <RAAN> <MeanAnom> ["<CoordEpoch>"] Connect expects certain parameters. If you want to use other parameters beyond those in the Connect command you can do so by using the Object Model. The square bracket allows you to concatenate the command to add custom variables. In this string, you’re setting the state of the Satellite object called LeoSat using Classical parameters and the TwoBody propagator. The ephemeris will begin at the scenario start time and end at the scenario stop time. Next you’re using a 60 second step size and the ICRF reference frame. Then it requires an orbit epoch and in this case you’re using the scenario start time. The semi major axis is based on meters. The only other orbital element that was changed is inclination. Bring STK to the front and you can see the target location and the satellites orbit.

16 MATLAB Script Code (Task 4)
Browse to the STK Programming Interface help files. Locate and manually enter code into MATLAB to compute an access between two STK Objects using the IAgStkObject interface. The access is between the Satellite object and the Target object. access = satellite.GetAccessToObject(target) access.ComputeAccess Task 4 Follow the tutorial instructions to complete the following: Browse to the STK Programming Interface help files. Locate and manually enter code into MATLAB to compute an access between two STK Objects using the IAgStkObject interface. The access is between the Satellite object and the Target object. NOTE: If you can’t find the proper code, expand the tutorial paragraph by clicking the small plus sign.

17 MATLAB Script Code (Task 4 cont.)
Retrieve and view the access data in MATLAB. accessDP = access.DataProviders.Item('Access Data').Exec(scenario.StartTime,scenario.StopTime); accessStartTimes = accessDP.DataSets.GetDataSetByName('Start Time').GetValues accessStopTimes = accessDP.DataSets.GetDataSetByName('Stop Time').GetValues Task 4 Retrieve and view the access data in MATLAB. Grab a handle on the access data providers. The data provider in STK is called Access Data. Next you tell MATLAB how long you want the computation to run by running the public method Exec which will compute the data from the scenario start time until the scenario stop time. The next two commands pull the access data into the Command Window.

18 MATLAB Script Code (Task 5)
Retrieve and view the altitude of the satellite during an access interval. satelliteDP = satellite.DataProviders.Item('LLA State').Group.Item('Fixed').ExecElements(accessStartTimes{1},accessStopTimes{1},60,{'Time';'Alt'}); satellitealtitude = satelliteDP.DataSets.GetDataSetByName('Alt').GetValues Task 5 1. Retrieve and view the altitude of the satellite during an access interval. Grab a handle on the satellite data providers. The data provider in STK is called LLA State which provides Latitude, Longitude and Altitude. The data provider is in a group folder called Fixed, so you tell MATLAB to open the folder. Next you tell MATLAB how long you want the computation to run by running the public method ExecElements (you specify with elements in the folder) which will compute the data from the scenario start time one until the scenario stop time two, using a sixty second time step. The data will be the time and altitude. The final command pulls the satellites altitude data during the first access time into MATLAB.

19 Other Resources Tutorials, Code Samples, Code Snippets, and Online Resources can be found at: < Contents > STK Programming Interface > Tutorials, Code Samples and Snippets, and Online Resources

20 Python – STK Integration
Options include… Python web install ( Pip install comtypes library Anaconda ( Use either Spyder or Jupyter Notebooks WinPython (

21 Python Setup – 1/3 options
Python web install ( Pip install comtypes library Text editor or IDE NOTE: Will not have intellisense

22 Python Setup – 2/3 options
Anaconda ( Comtypes will be installed Spyder or Jupyter Notebooks NOTE: Spyder and Jupyter come installed with these distributions and can be launched individually or from Anaconda

23 Python Setup – 3/3 options
WinPython ( Comtypes will be installed Spyder or Jupyter Notebooks NOTE: Spyder and Jupyter come installed with these distributions and can be launched individually

24 Python Resources FAQ: Getting Started STK COM integration using Python
Github: STK Integration with Python Programming Help: Python Code Snippits

25 Python Lesson NOTE: Demo in Python 3.6 but also Python 2.7 compatible. The STK API works identically on both of these distributions.


Download ppt "Integrating STK with other applications (MATLAB, Excel, Python, etc)"

Similar presentations


Ads by Google