Part 5: Introduction to Connect

STK Pro, STK Premium (Air), STK Premium (Space), or STK Enterprise
You can obtain the necessary licenses for this training by contacting AGI Support at support@agi.com or 1-800-924-7244.

Capabilities covered

This lesson covers the following STK Capabilities:

  • STK Pro

Problem statement

Programmers, engineers, and operators often need resources to easily build applications that communicate with STK. Having a spreadsheet containing data, they need to transfer the data into and out of STK 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 STK and extract data from STK or create automation.

Solution

You will learn what an STK Connect command is and how to find and use the Connect Command Library. Using the STK 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).

Create a new scenario

Create a new scenario.

  1. Launch STK ().
  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 STK

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.

The Web Browser

In STK, 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 STK Automation.
  5. Click Open.
  6. Select API Demo.
  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 workspace.

  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 STK.
  6. Open the Window menu at the top of STK.
  7. Select Tile Vertically.

API Demo Utility

Connect commands are normally sent to STK from outside of STK 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 STK, 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 STK 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 radio buttons: When you load an example Connect command, you can view it as a Connect command or select Object Model to see examples of how a line of code might look inside an application like MATLAB.
      • Run 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.

Syntax: 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 Help page WILDCARDS IN OBJECT PATHS.
    • The <ApplicationPath> is the path to the instance of the current Application (e.g. STK).
    • The <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.
    • The <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 STK.
  4. Click Run Code.
  5. A Facility () object has been entered 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 library to easily build applications that communicate with STK.

  1. Extend the Help menu.
  2. Select STK Help.
  3. Select Integrating with STK on the left.
  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, we'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, Integrating STK with Python and Integrating STK with Excel. A Level 3 - Focused / Problem Specific lesson that uses Connect is Using STK Connect to Plan a Predator Mission.

Alphabetical listing

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

  1. Select Alphabetical Listing of Connect Commands.
  2. Select N at the top of the page.
  3. Select the New command.
  4. 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.

SetPosition Command

Use the SetPosition command to set the position of a facility, place, target or area target.

  1. Return to the alphabetical listing.
  2. Select S at the top of the page.
  3. Select SetPosition (Facility, Place, Target & Area Target).
  4. Ensure you have the correct syntax: SetPosition <ObjectPath> [{Type}] {CoordType} <Parameters>
  5. Scroll down the page until you find the {CoordType} <Parameters> chart.
  6. Note the Geodetic <Parameters> <Lat> <Lon> {<Altitude> | Terrain} [MSL].
  7. Return to STK.

Understanding the SetPosition Connect Command

Before you run the code, look at the SetPosition command.

  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 code

  1. Remove 0.0 (altitude) at the end of the SetPosition Connect command.
  2. Type 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.
  5. MyFacility_Con () has new coordinates and an attached Sensor () object named MyFacSensor_Con.

Inserting a Satellite () object

We won't keep jumping back and forth between STK and the Connect Command Library. However, feel free to go there on your own as we proceed through the training. 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.
  4. MySat () has been added to the scenario but it needs to be propagated.

Propagating MySat ()

  1. Select Modify satellite in the API Demo Utility's Examples list.
  2. The SetState Classical command sets the orbit state of the satellite using classical coordinates.

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

  3. Compare the text in the Code Sandbox to the syntax and change the following:
  4. Option Value
    Object name MySat
    Inclination 45 (deg)
    RAAN 180 (deg)

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

  5. Click Run Code.

Inserting an 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. Then you set the propagator to Great Arc, reference mean sea level (MSL) and create waypoints.

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

Modifying 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 Clear all waypoints from a great arc vehicle.
  4. Click Run Code.

Computing an 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 Calculate 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 Define the display of geometric components in the 3D Graphics window.
    VO View Set 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. Right-click on MyFacility_Con () in the Object Browser.
  9. Select Zoom To.
  10. To 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 ().

  11. Click Start () to animate the scenario.
  12. Click Reset () when finished.
  13. 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 STK that you can use to send Connect commands.

  • STK Button Tool : The Button Tool 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 Example HTML Utilities. This is a utility that allows you to send a Connect command to STK 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 (e.g. Using STK Connect to Plan a Predator Mission).

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 STK. If you are planning on writing the simplest script to automate a function in STK, now's your chance to practice.

If you're interested in automating and extending your mission building, check out the STK Python UI, available with an STK Integration License.