FreeFlyer Scripting Samples

Top  Previous  Next

These Mission Plans demonstrate the use of several of FreeFlyer's built-in math functions and the syntax and implementation of FreeFlyer's logic control statements. After exploring these Mission Plans, continue to the Functions and Flow Control script references for more information.

 

Jump to a Mission Plan Description:

 

Mission Plan

Engineer

Mission

Conversion Functions

For Loop

Get/Put Formation with Child Objects

Heap Sort

If/Then

Keplerian Conversion

Launch Site Visualization

Matrix Math

Monte Carlo

Script Aliases

Sort Examples

Struct Example

Switch - Determine Output

Switch - Maneuver Spacecraft

Sync TLEs

TimeSpans

 

 

Conversion Functions

This Mission Plan exercises FreeFlyer's various built-in conversion functions.

 

The 'Attitude Conversion' FreeForm converts attitude values from LVLH to MJ2000 reference system.

The 'Element Conversion' FreeForm converts Keplerian elements to Cartesian elements.

The 'Coordinate System Conversion' FreeForm converts position and velocity in MJ2000 Earth Equator to:

oPosition in True-of-Date Earth Equator

oVelocity in True-of-Date Earth Equator

oPosition and Velocity in True-of-Date Earth Equator

The 'Coordinate System Conversion for Coordinate Systems at Different Epoch' FreeForm converts position in Earth-Fixed at an epoch to True Date of Earth Equator at a different epoch.

The resulting output file is opened in the default text editor in the Mission edition of this Mission Plan.

 

Output Report:

 

 

For Loop

This Mission Plan demonstrates use of the For Loop in logic control. To learn more about topics related to this sample Mission Plan, see the For statement.

 

Get/Put Formation with Child Objects

This Mission Plan demonstrates the use of a Procedure, defined in an external .FFProcedure file, which copies a Spacecraft object and all of its child objects using the Put command. Another Procedure that takes advantage of the Get command is then used to populate a Formation object of identical Spacecraft with identical hardware.

 

Formation of eight identical spacecraft copied using Procedures

Formation of eight identical spacecraft copied using Procedures

 

 

Heap Sort

This Mission Plan demonstrates the 'heap' sorting of an array in FreeFlyer. The array values are initialized using a UniformNoise function to generate pseudo-random numbers. The initial array and the final sorted array are reported to the Console.

 

If/Then

This Mission Plan demonstrates use of If/Then decision control. In this example, propagation is terminated when spacecraft height falls below a given value. To learn more about topics related to this sample Mission Plan, see the If statement.

 

Output Plot of the height of a Spacecraft in a Low Earth Orbit

Output Plot of the height of a Spacecraft in a Low Earth Orbit

 

 

Keplerian Conversion

This Mission Plan demonstrates how to convert various Keplerian orbital elements into different sets of elements. The first option converts apogee and radius values (in km) to semi-major axis and eccentricity. The second option converts eccentric anomaly and eccentricity into true anomaly.

 

LaunchSiteVisualization

This Mission Plan shows the various launch sites around the world in a 2D view. Each ground station has a Region to show the direction in which spacecraft may be launched. This Mission Plan also demonstrates how to create and work with Lists of GroundStation objects and Region objects.

 

A visualization of the launch sites around the world

A visualization of the launch sites around the world

 

Matrix Math

This Mission Plan demonstrates various mathematical operations using the Matrix, Array, and Variable objects in FreeFlyer, including Matrix filling, Matrix statistics, Matrix slicing and resizing, Matrix decompositions, Matrix-Variable operations, Array-Variable operations, Array-Array operations, concatenating Arrays, and operations with row Matrices, differently-sized Matrices, and square, same-sized Matrices.

 

Monte Carlo

This Mission Plan demonstrates the usage of FreeFlyer GaussianNoise and UniformNoise statistical functions in a Monte Carlo analysis for a Low-Earth Orbit (LEO) to Geosynchronous Orbit (GEO) impulsive maneuver. In this example, given normal distributions in the error associated with the radius and velocity, and uniform distribution in the error associated with the impulsive maneuver, the final end apogee for the transfer orbit is calculated, plotted and reported for each case along with the mean, standard deviation, minimum, and maximum values.

 

The mission plan targets the optimal impulsive burn using a Targeting loop with the given initial state and then the errors are applied to the trajectory for each Monte Carlo case. The Mission version utilizes a User Interface to input the initial state values and Monte Carlo case size.

 

Output results of the Monte Carlo SMP

Output results of the Monte Carlo SMP

 

Script Aliases

This Mission Plan demonstrates the use of Script Aliases in FreeFlyer. Script Aliases allow you to create simple abbreviations for more complex expressions in FreeForm script. An Alias can refer to any of the following types of expressions:

 

Objects

Child Objects

Child Objects with type casting

Object Properties

Object Methods with set input arguments

 

In this example, Script Aliases are used to propagate a Spacecraft for two days, while generating a 3D output view and two plots.

 

Sort Examples

This Mission Plan exercises FreeFlyer's built-in sorting functions.

 

The 'Array Sort' FreeForm demonstrates how to sort a numerical Array in increasing and decreasing order.

The 'String Array Sort' FreeForm demonstrates how to sort a StringArray in increasing and decreasing order.

The 'Rank Sort' FreeForm demonstrates how to use the RankSort method to sort all input argument Arrays according to the precedence defined in the calling Array.

The 'Split Sort' FreeForm demonstrates how to use the SplitSort method to sort a StringArray. Each element of the calling StringArray will be split into columns based on the specified delimiter, then the columns will be sorted based on the specified precedence. Then, the rows are reformed, using a space to merge the columns.

 

Output Report:

 

Struct Example

This Mission Plan demonstrates the use of Structs in FreeFlyer. The script defines a few example Structs and demonstrates creating and working with instances of those Structs. In particular, this example demonstrates computing the time of closest approach (TCA) and miss distance for two Spacecraft objects contained within a HighInterestConjunction Struct.

 

 

Switch - Determine Output

This Mission Plan demonstrates the use of the Switch statement to determine what type of output will be generated. In this example, while the Spacecraft is propagated for one day, the Switch enforces the following:

 

Case 0: Do nothing

Case 1: Generate a plot

Case 2: Generate a report

Case 3: Generate an ephemeris

Default: Generate a watch window

 

You can change which Case is executed by adjusting the value of the Variable 'a' in the FreeForm script.

 

Switch - Maneuver Spacecraft

This Mission Plan demonstrates the use of the Switch statement to determine when a Spacecraft should be maneuvered. The Switch statement monitors how many hours have elapsed, and when this value equals '1' or '3', a maneuver is executed. At all other times, the Spacecraft is simply stepped forward in time.

 

Orbital path of the maneuvered Spacecraft

Orbital path of the maneuvered Spacecraft

 

Sync TLEs

This Mission Plan demonstrates how to synchronize all of the Spacecraft state vectors in a TLE file to the same epoch. Synched epochs are important if the TLEs are going to be imported into a Formation: when stepping the Formation, synched Epochs are important to keep the output coherent.

 

The Mission Plan starts by importing the states in a TLE file into a Formation, then finding the maximum state epoch. All states are then propagated to the maximum epoch and reported out to a file. This technique can be used to synch an unlimited number of states in a file; this is especially useful for Conjunction Assessment analyses.

 

TimeSpans

This Mission Plan demonstrates various usages of the TimeSpan object introduced to extend timing precision in FreeFlyer beyond millisecond to the nanosecond level. It is designed to showcase the syntax primarily, and thus to supplement Mission Plan development using the nanosecond timing precision mode.

 

Output ConsoleWindow showcasing TimeSpan syntax

Output ConsoleWindow showcasing TimeSpan syntax