Working with Objects

Top  Previous  Next

When working within FreeFlyer, you will create both objects and commands.


Objects represent both physical objects, such as a Spacecraft or Groundstation, as well as processes, such as a FiniteBurn or OrbitDetermination.

Commands allow you to perform actions on the objects you have created. You might use the Step command to propagate a spacecraft state, or use the View command to create a 3D visualization of your simulation.


Some facts about objects:


Every FreeFlyer Mission Plan contains objects.

Each instance of an object is defined with a unique name.

Most objects can be created and edited through Object Editors and FreeForm Script Editors.

Each object instance can be manipulated through the use of properties, methods, and commands within the Mission Sequence to generate output.


This guide covers the following topics:


Object Constructors - Discusses the creation of objects in FreeFlyer. Some of FreeFlyer's more complex objects may require input arguments.

Constant and Global Keywords - Objects can be declared as Global to make them available to any Procedures that may be called.

Type Casting - Allows you to work with base type objects, which provide sets of commonly needed properties to other objects.



Object Constructors

In order to create a basic object within a FreeForm Script Editor, the simple <Object Type> <Object Name> format, or "constructor", is used, as shown here:


Variable Variable1;


However, to create some of FreeFlyer's more complex objects, you may want to specify input arguments when creating the object. The constructor format for creating an object using input arguments is <Object Type> <Object Name>(Input1, Input2, ...). For example:


Spacecraft Spacecraft1(Propagator1, AttitudeEphemeris1);


ViewWindow ViewWindow1({Spacecraft1, GroundStation1, Formation1});


Custom descriptions of objects can be created using the following syntax. The custom description will show up in the tooltip mouse-over.


Spacecraft Spacecraft1; /// estimated Spacecraft



For a complete list of objects with constructors that have input arguments, see the List of Object Constructors in the Appendix.



Constant and Global Keywords

FreeFlyer supports constant Variables and Strings. The value of a String or Variable that is created using the Constant keyword can not be changed later in the Mission Plan. The value of the Variable or String is assigned in-line with the creation of the object, as seen in the examples below.


Constant Variable PI = 3.14159265;

Constant String String1 = "FreeFlyer";


FreeFlyer also supports global objects, which can be accessed from a Procedure without having to be included in the list of arguments passed to the Procedure. An object that is declared as Global is available in all Procedures that are called from the scope in which the Global Object is defined.


Global Variable MU = 398600.4415;

Global String String2 = "FreeFlyer Mission Plan";


The Global and Constant keywords can be used in conjunction. To specify a Variable or String as a Global Constant, the Global identifier must be declared before the Constant identifier, as seen in the example below.


Global Constant Variable MU = 398600.4415;


Global Objects in Procedures

The example below demonstrates how Global objects can be accessed in Procedures without being passed in as input arguments to the Procedure. If an object is not Global, it must be passed as an argument in order to be accessible within a Procedure.


In the Mission Plan:


Global Variable Variable1;
Global Array Array1[3];


Include "Procedure1.FFProcedure";

// Global objects do not need to be passed as arguments
Call Procedure1(Spacecraft1);


In the Procedure:


// Global objects are automatically accessible within the Procedure

Define Procedure Procedure1(Spacecraft Spacecraft1);
     Array1[0] = Spacecraft1.A + Variable1;


Note: Procedures referring to Global Objects will only work with Mission Plans that contain the required global objects.


Always Available Global Object Instances

Global instances of the following objects exist in every Mission Plan. With the exception of the ConsoleWindow object and StarField object, these objects are not creatable by the user. In the case of the ConsoleWindow and StarField objects, the user can create any number of ConsoleWindows or StarFields in addition to the built-in global instances. Through these objects, you can edit FreeFlyer properties relating to display, data files, and more. The following table lists the global object types and their instance names.


Global Type

Global Instance Name

Additional Information






Color Reference



Using the Debugger



Output Layout Control



FreeFlyer Configuration



Solar System






Parsing Dates and Times


Examples of editing these objects through script are given below.


// Set the Console color using the ColorTools object, and show the Console

Console.BackColor = ColorTools.Black;



// Reporting to the Debugger Log Window

Report mySpacecraft.A to DebuggerLog;


// Editing FF Preferences

FF_Preferences.RecordUIResponses = 1;

FF_Preferences.UIOutputResponsesFilename = "UserInterfaceResponses.txt";


// Editing the FF Solar System

FF_SolarSystem.ComputePolarMotion = 1;

FF_SolarSystem.DefaultSGFFile = "Fdfstatn.dat";


// Accessing the built-in Stars

Report Stars.CatalogFilename, Stars.Count;



Type Casting

Many of the object types in FreeFlyer are base types, which can refer to several different object types when used in FreeForm script. For example, a Spacecraft's Propagator could be a Two-Body, Runge-Kutta, Ephemeris, or any other type of propagator. The AsType, IsType, and TypeOf operators allow users to interact with base types, as shown in the examples below.


While we will use the "Propagator" example to illustrate how to work with base types and the type casting operators, these concepts also apply to other object types.


Base Types

FreeFlyer base object types provide sets of commonly needed properties to other objects. An object type that derives from a base type will inherit all the properties and methods of its base object type(s). For example, at the highest level, the Object base type provides a property called "ObjectId" to all objects. The inheritance tree for all the FreeFlyer objects and base types is given on the Object Hierarchy page.


Instances of base object types can not be created via the Object Browser or through FreeFlyer script, but they can be passed to a Procedure. In the following example, a Procedure called "PropType" receives a Propagator base object from a Mission Plan, and assigns a tolerance to the Propagator based on its sub-type. In this example, only two possible types are called out: RK45 and RK89. If the Propagator were a different type, its tolerance would not be changed by this script. This example uses the TypeOf, IsType, and AsType operators, which are discussed in further detail below.


Define Procedure SetTolerance(Propagator prop);


     If (prop IsType RK45);

           (prop AsType RK45).Tolerance = 2.0e-9;



     If (prop IsType RK89);

           (prop AsType RK89).Tolerance = 1.0e-9;






Spacecraft Spacecraft1;


// Set up Spacecraft1 to use a RK45 propagator



// The propagator's tolerance will be set to 2.0e-9

Call SetTolerance(Spacecraft1.Propagator);


TypeOf Operator

The TypeOf operator can be used to convert any type in FreeFlyer script into a string containing the name of that type. This allows you to use the autocomplete menu when typing the object type, and helps avoid runtime errors due to typos.


For example, the Spacecraft.SetPropagatorType method expects a string as input. The TypeOf operator can be used to convert a Propagator Type, such as RK45, to string format for use with this method, as demonstrated in the example above. This operator can be used with any object type:


Report TypeOf(Spacecraft), TypeOf(SphericalTank), TypeOf(SpiceEphemeris);


Output report:


"Spacecraft" "SphericalTank" "SpiceEphemeris"


IsType Operator

The IsType operator can be used to determine the type of an object in FreeForm script. This operator returns a 1 or 0, depending on whether the condition is true or false, making it useful when working with the If and While statements. This can be useful when the type of an object is unknown, perhaps because it has been passed into a generic Procedure which is used by multiple Mission Plans. The example below demonstrates using the IsType Operator to check whether a Spacecraft is being propagated with an Ephemeris.


If (Spacecraft1.Propagator IsType Ephemeris);

 Report "Spacecraft is using an ephemeris for propagation";


 Report "Spacecraft is not using an ephemeris for propagation";



AsType Operator

The AsType operator can be used to cast an object to the desired object type in order to access properties that are only available at the sub-type level. This is especially useful when an object has been passed to a Procedure as a base type or when the object type has been set in script.


While we have thus far used the "Propagator" example to illustrate these type casting operators, the concepts also apply to other object types:


Example: Tanks


(Spacecraft1.Tanks[0] AsType SphericalTank).TankMass = 500;

(Spacecraft1.Tanks[0] AsType ElectricalTank).TankPower = 0.1;


Example: Burns


Define Procedure SetBurn(Burn burn1);


 If (burn1 IsType FiniteBurn);

         (burn1 AsType FiniteBurn).BurnDuration = TIMESPAN(100 seconds);

 ElseIf (burn1 IsType ImpulsiveBurn);

         (burn1 AsType ImpulsiveBurn).BurnDirection = {2, 0, 0};





The inheritance tree for all the FreeFlyer objects and base types, which shows all the objects that can be cast to other object types, is given on the Object Hierarchy page.


See Also

Using Procedures

Properties and Methods with a State


Object Presets