Scripting Tool
As a stand-alone profile, it can be used as an initial guess tool that sets control values inside the target sequence - based on calculation objects - before the control values are refined by a differential corrector, optimizer, or plugin search profile.
When the scripting tool is attached to a search profile, it can be used to map an independent variable to multiple segments in the target sequence. For instance, use it to force two maneuvers to use the same delta-V value, where that value is solved for by the search profile.
The Scripting Tool can also be used to make Sequences and Backward Sequences more generic by exposing a parameter that is used in multiple places in the sequence. The parameter can then be changed in only one place in the sequence and the Scripting Tool will push the value into all of the places that it is used. In addition, on a repeating Sequence or Backward Sequence, the Scripting Tool can make the sequence use different values on each iteration.
Using the Scripting Tool
To create a script using the Scripting Tool, first select Enabled to activate the tool, and then add and define the object attributes, calculation object components, and parameters that you want the script to interact with.
Click to place a copy of the script - including the object attributes, calculation object components, and parameters defined for it - on the clipboard. Click
to replace the current script with a copy of the one currently on the clipboard.
Each time that the script is run, Astrogator produces a summary report of it that includes the initial value of its object attributes, calculation object components, and parameters and the final values of the object attributes. Click to view this report.
Scripting Toolbar
You can add, copy, delete and perform other actions on object properties, calculation objects, and parameters by right-clicking in the table that lists them or by using the following toolbar buttons:
Button | Name | Function |
---|---|---|
![]() |
Properties... | Opens a properties window that lists all of the object properties, calculation objects or parameters defined for the script. Advanced properties of individual object properties, calculation objects, and parameters can be modified from this window. |
![]() |
New... | Inserts a new object property, calculation object, or parameter with default properties settings. |
![]() |
Cut | Removes the currently selected object property, calculation object, or parameter from the list and copies it to the clipboard. |
![]() |
Copy | Makes a copy of the currently selected object property, calculation object, or parameter to the clipboard. |
![]() |
Paste | Inserts a copy of the object property, calculation object, or parameter that is currently on the clipboard. |
![]() |
Delete | Deletes the currently selected object property, calculation object, or parameter. |
Object Properties
The script will be able to use and modify object properties that are assigned to it. For each property, choose the Object that contains the property. All segments nested within the sequence in which the Scripting Tool is located are available for selection; for stand-alone Scripting Tool profiles, other profiles in the same Target Sequence are also available.
Next, choose the Attribute that corresponds to the property that the script will use and/or change. The attributes of each object are described in detail in the Connect documentation. To choose an attribute that is read-only (e.g., the estimated burn duration of an impulsive maneuver) set the ReadOnlyProperty to true; otherwise, only attributes that are editable are available. If the attribute is a quantity, select the Unit in which the script will interact with the value. Finally, give the object property a Name; this name can then be used as a variable in the script.
Calc Objects
The script will be able to use the values of calculation objects that are assigned to it. For each component, select the calculation object that the script needs to be able to access and edit its properties.
In the properties window, double-click the Calc Object field to bring up an Embedded Component Link Selection window and configure the calculation object.
Click Change... to select a calculation object from the Component Browser. You can use the button to copy the currently selected calculation object to the clipboard and the
button to replace the current calculation object with a copy of the one that is on the clipboard. Click
to save a copy of the current calculation object to the Component Browser. Click OK or Cancel to accept or reject the changes you have made and return to the properties window.
If the calculation object gives a quantity, select the Unit in which the script will get the value. Finally, give the calculation object a Name; this name can then be used as a variable in the script.
The calculation objects are evaluated at the initial state of the sequence in which the scripting tool is located. To get a calculation object evaluated at a different state, use the Value at Segment calculation object located in the Segments folder.
Parameters
There are seven types of parameters that can be used in a script - Boolean, Date, Double, Enumeration, Integer, Quantity, and String. Each parameter is displayed on a separate line with Name, Value, Unit, Type, Dimension, and User Comment fields. The Name field is used to identify the parameter and can be used as a variable in the script. The User Comment field is used to give the parameter a reference description. The Value, Unit, and Dimension fields are all dependent on the parameter's type and are defined in the table below.
Parameter Type | Properties Configuration |
---|---|
Boolean | Value can be true or false. Dimension and Unit are disabled. |
Date | Value can be any date. Dimension is disabled and fixed to DateFormat. Unit can be any date format supported by STK. In addition, in the properties window you can set minimum and maximum values for the parameter. |
Double | Value can be any real number. Dimension and Unit are disabled. In addition, in the properties window you can set minimum and maximum values for the parameter. |
Enumeration | Value can be any value in the enumeration. The enumeration can be defined in the EnumChoices field using the properties window. Dimension and Unit are disabled. |
Integer | Value can be any integer. Dimension and Unit are disabled. In addition, in the properties window you can set minimum and maximum values for the parameter. |
Quantity | Value can be any real number. Dimension can be any unit type supported by STK. Unit can be any unit of the selected Dimension that is supported by STK. In addition, in the properties window you can set minimum and maximum values for the parameter. |
String | Value can be any character string. Dimension and Unit are disabled. |
Inheriting Parameters
If you have scripts attached to multiple search profiles within the same target sequence, you can pass the value of a double, quantity, or date parameter from one search profile to the next by selecting Inherit. The Inherit field appears in the parameters of all search profile scripts after the first search profile of a target sequence. The field is active if you give the parameter a name and type that is the same as a parameter in a previous search profile and if that profile is active and the attached script is enabled. If you set a parameter to inherit its value then the Value, Unit, and Type fields will be inactive.
When you apply corrections to the target sequence, the Inherit field will be disabled so that the script does not reinitialize the parameter the next time that it is run and write over the value that you applied.
Script
Once you have selected and defined the object attributes, calculation objects, and parameters that you want to make available to the script, select the scripting language from the Language drop-down menu and enter the script in the space beneath. The object attributes, calculation objects and parameters are all available as variables in the script, using the same names that they have in the lists above. In the script the variables will be initialized to the value of the object properties, calculation objects, and parameters in the units associated with them, if applicable. Setting the value of a variable associated with an editable object property in the script will set the object property to that value in the MCS, in the specified unit of the object property, if applicable.
The variable type of object properties depends on the property. If the property refers to a numerical quantity, the variable will represent a real number in the specified unit. If the property refers to a Boolean, such as the Active flag of a stopping condition, then the variable is also a Boolean in the script. If the property refers to a component, such as an engine model, the variable is a string that corresponds to the name of the component. To set the property to a different component, assign the variable to a string with the name of the new component to use. Other object properties that represent strings, such as a property with a drop-down list of choices, are also treated as strings in the script.
Object property and calculation object variables that refer to dates are either treated as number or strings depending on the unit type of the variable. If the unit type is EpSec, EpMin, EpHr, EpDay, EpYr, JDate, ModJDate, JDateOff, YYDDD, YYYYDDD, JED, EarthEpTU, SunEpTU, or GPSZ it is treated as a number; otherwise it is treated as a string.
Special Variables
In addition to the attributes and calculation objects visible in the respective drop-down menus of the Scripting Tool, there is a selection of special variables that are available to the scripts that you write using it.
Variable | Definition |
---|---|
iteration | The iteration count of the sequence segment that contains the script. |
abortMCS | Stops the run of the MCS. Initialized to false; if true after the script runs, the MCS will be stopped. |
Parameters and Search Profiles
Parameters that are defined for a script can be used as control variables for search profiles in a Target Sequence. By default, the following rules apply to parameters of scripts nested within a Target Sequence:
- Parameters in a Sequence or Backward Sequence within a Target Sequence can be used by search profiles assigned to that Target Sequence.
- Parameters in a Scripting Tool Profile can be used by search profiles assigned to the immediate parent Target Sequence.
- Parameters in a script defined for a search profile can be used by that search profile.
If the Allow target sequences to use nested target sequence controls and resultsMCS Option is selected, then parameters of scripts nested anywhere within a Target Sequence are available to all parent Target Sequences.