Part 1: Introduction to Connect

STK Pro, STK Premium (Air), STK Premium (Space), or STK Enterprise
You can obtain the necessary licenses for this tutorial by visiting http://licensing.agi.com/stk/evaluation or contacting AGI Support at support@agi.com or 1-800-924-7244.

The results of the tutorial may vary depending on the user settings and data enabled (online operations, terrain server, dynamic Earth data, etc.). It is acceptable to have different results.

Capabilities covered

This lesson covers the following capabilities of the Ansys Systems Tool Kit® (STK®) digital mission engineering software:

  • STK Pro

Problem statement

Programmers, engineers, and operators often need resources to easily build applications that communicate with the STK software. Having a spreadsheet containing data, they need to transfer the data into and out of the STK application quickly and easily. Many of the engineers and operators are not programmers. They need a simple to understand language and syntax with which to create ways to efficiently populate objects into the STK application and extract data from or create automations with the STK application.

Solution

You will learn what an STK Connect command is and how to find and use the Connect Command Library. Using the STK software's Integration capability and the API Demo Utility, explore the Connect Command Library and become familiar with some simple connect commands used to quickly and easily populate objects into and obtain analytical data from an STK scenario.

What you will learn

Upon completion of this tutorial, you will understand the following:

  • The Connect Command Library
  • Simple Connect Commands
  • The API Demo Utility

Video guidance

Watch the following video. Then follow the steps below, which incorporate the systems and missions you work on (sample inputs provided).

Creating a new scenario

Create a new scenario.

  1. Launch the STK application ().
  2. Click Create a Scenarioin the Welcome to STK dialog box.
  3. Enter the following in the STK: New Scenario Wizard:
  4. Option Value
    Name STK_Connect
    Location Default
    Start Default
    Stop Default
  5. Click OK once you are done.
  6. Click Save () once the scenario loads. A folder with the same name as your scenario is created for you in the location specified above.
  7. Verify the scenario name and location and click Save.

Save () often during this lesson!

Preparing your workspace

For this scenario, the Timeline View and the Insert STK Objects tool won't be used. You can close them.

  1. Close the Timeline View.
  2. Close the Insert STK Objects tool.

Using the Web Browser

In the STK application, the Web Browser is a web browser that is an integrated part of the workspace.

  1. Click New Integrated Web Browser () on the Default toolbar.
  2. Click Browse () in the Web Browser - AGI - Resources web browser toolbar.
  3. Click Example HTML Utilities in the Open dialog box.
  4. Select the STK Automation folder.
  5. Click Open.
  6. Select the API Demo folder.
  7. Click Open.
  8. Select API Demo Utility.
  9. Click Open.

Customizing your workspace

You can dock the API Demo Utility to the bottom of the STK application.

  1. Right-click on the Web Browser - API Demo Utility title.
  2. Select Dockable.
  3. Place your cursor on the Web Browser - API Demo Utility title (usually docks below the Object Browser).
  4. Hold down your left mouse button.
  5. Move the web browser to dock it at the bottom of the STK application window.
  6. Open the Window menu at the top of the STK application.
  7. Select Tile Vertically.

Understanding the API Demo Utility

Connect commands are normally sent to the STK software from outside of the STK application using a TCP/IP connection or a COM interface. In this scenario, you'll use the API Demo Utility to practice and understand Connect commands. The API Demo Utility functions inside of the STK application, therefore no outside connections are required (e.g. TCP/IP). The API Demo Utility is a great tool with which to practice Connect commands prior to using them in an actual script.

  1. Look at the API Demo Utility.
    • Examples: On the left side of the API Demo Utility are examples. When you click an example, the associated Connect command appears in the Code Sandbox. Connect isn't compiled code; Connect is simply a string of text written in a way that the STK software understands. Connect is sometimes referred to as "The Language of STK."
    • Code Sandbox: The Code Sandbox is where you enter your Connect commands or load the prebuilt example Connect commands.
      • Connect and Object Model options: When you load an example Connect command, you can view it as a Connect command or you can select Object Model to see examples of how a line of code might look inside an application like MATLAB.
      • Running the code: Clicking Run Code will send your Connect command to your scenario.
    • Output: The Output window is used if you send a Connect command which returns data such as the data inside an access report.

Using the New command

The New command allows you to create a new scenario or add a new object to the current scenario. The Syntax is:

New <ApplicationPath> <ClassPath> <NewObjectName> {NewOptions}

  1. Select Add facility in the In the API Demo Utility's Examples list.
  2. Break down the string of text located in the Code Sandbox:
  3. String of Text in Add Facility Meaning
    New Connect command
    / ApplicationPath
    */Facility ClassPath
    MyFacility_Con NewObjectName
    • Wildcards can be used in Connect commands. To understand wildcards, view the Wildcards in Object Paths help page.
    • <ApplicationPath> is the path to the instance of the current application (e.g. the STK application).
    • <ClassPath> specifies the full class path of the object to be created. In this case, it's the new Facility () object you're entering into the scenario.
    • <NewObjectName> is the name of the Facility () object.
      • Object Names can not be more the 64 characters in length.
      • Object Names can contain only alphanumerics, underscores and hyphens.
      • Object names, in Connect, are not case-sensitive, however Class names are case-sensitive.
      • An object name cannot be "_Default" or "end" (regardless of case), as these are reserved words in the STK software.
  4. Click Run Code.

A Facility () object has been inserted into the scenario using its default properties.

Understanding the Connect Command Library

There is a whole section in STK Help devoted to Connect. You can use the commands in the Connect Command Library to easily build applications that communicate with the STK software.

  1. Select the Help menu in the Menu Bar.
  2. Select STK Help.
  3. Select Integrating with STK in the table of contents.
  4. Select Connect Command Library.

There's a lot of information in the Connect Command Library to include breaking down Connect commands by object, 2D and 3D Graphics windows, by capability, etc. To keep things simple, you'll focus on the API Demo Utility Examples. You can find much more in depth training in the Optional Third-Party Programs (Level 2 - Advanced Training), specifically Integrating STK with MATLAB and Integrating STK with Python. A Level 3 - Focused / Problem Specific lesson that uses Connect is Drive STK with Connect Commands and Excel.

Viewing the Alphabetical Listing of Connect Commands

The Alphabetical listing includes all Connect commands, regardless of their groupings.

  1. Select the Alphabetical Listing of Connect Commands link.
  2. Select N at the top of the page.
  3. Select the New command.

The page describes the command, syntax, related commands, options, and examples. Whenever you're starting to write Connect commands, look at the examples. You'll have to change them to work with your object types and such, but it's a great place to start.

Viewing the SetPosition command page

You can use the SetPosition command to set the position of a facility, place, target or area target.

  1. Return to the Alphabetical Listing of Connect Commands.
  2. Select S at the top of the page.
  3. Select SetPosition (Facility, Place, Target & Area Target).
  4. Ensure you have the correct syntax:
  5. SetPosition <ObjectPath> [{Type}] {CoordType} <Parameters>

  6. Scroll down the page until you find the chart of coordinate types and parameters in the Description section.
  7. Note the Geodetic coordinate type parameters:
  8. <Lat> <Lon> {<Altitude> | Terrain} [MSL].

  9. Return to the STK application.

You don't have to keep jumping back and forth between the STK application and the Connect Command Library. However, feel free to go there on your own as you proceed through the training.

Understanding the SetPosition command

Before you run the code, look at the SetPosition command in the API Demo Utility.

  1. Select Modify facility in the In the API Demo Utility's Examples list.
  2. Right-click on MyFacility_Con () in the Object Browser.
  3. Select Properties ().
  4. Select the Basic - Position page.
  5. Notice the SetPosition code in the Code Sandbox matches the Connect command syntax (e.g. Type, Latitude, Longitude, Altitude).
  6. Click Cancel to close the Properties Browser.
  7. Return to the API Demo Utility.

Modifying the SetPosition command

Update the default SetPosition code and examine the second command before running it.

  1. Remove 0.0 (which is the altitude) at the end of the SetPosition Connect command.
  2. Enter Terrain at the end of the Connect command.
  3. Since you have streaming terrain from Terrain Server, by removing the altitude and inserting Terrain, the Facility object will be placed on top of the terrain at the coordinates in the command.

    The second command is another New command. Note the path. It follows the object type to object name like you see it in the Object Browser. The New command inserts a Sensor () object and attaches it to the MyFacility_Con ().

  4. Click Run Code.

MyFacility_Con () has new coordinates and an attached Sensor () object named MyFacSensor_Con.

Inserting a Satellite object

Using the API Demo Utility to add a Satellite () object to the scenario and name it MySat.

  1. Select Add satellite In the API Demo Utility's Example list.
  2. Change the Satellite () object's name from MySatellite_Con to MySat.
  3. Click Run Code.

MySat () has been added to the scenario, but its orbit still needs to be propagated.

Propagating MySat

The sets the orbit state of the satellite using classical coordinates. The Syntax is:

SetState <VehObjectPath> Classical {Propagator} {NoProp | {TimeInterval}} <StepSize> {CoordSystem} "<OrbitEpoch>" <SemiMajorAxis> <Eccentricity> <Inclination> <ArgOfPerigee> <RAAN> <MeanAnom>

  1. Select Modify satellite in the API Demo Utility's Examples list.
  2. Compare the text in the Code Sandbox to the syntax and change the following:
  3. Option Value
    Object name MySat
    Inclination 45
    RAAN 180

    The value for the SemiMajorAxis is in meters which is the default distance unit when using Connect. Default distances in the STK software are in kilometers.

  4. Click Run Code.

Inserting an Aircraft object

Use the API Demo Utility to insert a new Aircraft () object.

  1. Select Add aircraft in the API Demo Utility's Examples list.
  2. Look at the code in the Code Sandbox.
  3. The New command inserts the Aircraft () object named MyAircraft_Con. Then it sets the propagator to Great Arc, reference mean sea level (MSL) and create waypoints.

    Command Description
    SetPropagator Sets the propagator of a great arc vehicle.
    AltitudeRef Sets the altitude reference for a Great Arc vehicle.
    AddWaypoint Adds waypoints to a great arc vehicle.
  4. Click Run Code.

Modifying MyAircraft_Con

Run the Modify aircraft example code to update MyAircraft_Con.

  1. Select Modify aircraft in the API Demo Utility's Examples list.
  2. Look at the code in the Code Sandbox.
  3. The Waypoints command and the Clear WaypointOption clears the original waypoints and AddWaypoint inserts new waypoints.

    Command Description
    Waypoints Clears all waypoints from a great arc vehicle.
  4. Click Run Code.

Computing access

Compute an access from MySat () to MyFacility_Con ().

  1. Select Compute access in the API Demo Utility's Examples list.
  2. Look at the code in the Code Sandbox.
  3. Command Description
    Access Calculates access intervals between two objects.
  4. Change the Satellite name from MySatellite_Con to MySat.
  5. Click Run Code.
  6. Bring the 2D Graphics window to the front. You will see access lines above MyFacility_Con ().
  7. Look at the API Demo Utility - Output.

You can see the full path to each object followed by individual accesses.

Adding vectors

Add a vector which points from the Facility () object to the Satellite object.

  1. Select Add vectors in the API Demo Utility's Examples list.
  2. Look at the code in the Code Sandbox.
  3. Command Description
    VO SetVectorGeometry Defines the display of geometric components in the 3D Graphics window.
    VO View Sets parameters for the view in a 3D window.
  4. Change the Satellite name from MySatellite to MySat in the VO SetVectorGeometry code line.
  5. View both lines of code.
  6. Click Run Code.
  7. Bring the 3D Graphics window to the front.
  8. Note that the VO View command set the view in the 3D Graphics window to be centered on MyFacility_Con ().
  9. To better view the vector pointing from MyFacility_Con () to MySat (), you might have to set your view in the 3D Graphics window so that you're under the terrain. The vector is only visible above the terrain when MyFacility_Con () has an access to MySat ().

  10. Click Start () to animate the scenario.
  11. Click Reset () when finished.

Saving your work

Clean up your workspace and save your scenario.

  1. Close any open reports, properties and tools which are still open.
  2. Save () your work.

Summary

This was an introduction to the STK Connect module and the Connect Command Library. You were introduced to the API Demo Utility which is just one of a few tools that come with the STK application, which you can use to send Connect commands.

  • STK ButtonTool : The STK ButtonTool is a Perl script with a graphical user interface (GUI) that you can use to associate STK Connect commands with buttons.
  • Send_A_Connect_Command.htm: Located in the Example HTML Utilities folder. This is a utility that allows you to send a Connect command to the STK application by typing it into a text field and submitting it. The Alphabetical Listing of Connect Commands can be displayed to help look up different commands.

Connect is an easy way to automate functions and quickly populate scenarios (for example, Drive STK with Connect Commands and Excel.

On your own

Throughout the tutorial, hyperlinks were provided that pointed to in depth information on Connect commands. Now's a good time to go back through this tutorial and view that information. Create your own Connect commands that add new objects to the scenario. Try creating reports and export them outside of the STK application. If you are planning on writing the simplest script to automate a function in the STK application, now's your chance to practice.

If you're interested in automating and extending your mission building, check out the Integrating STK with Python tutorial.