Matlab and STK Integration
Matlab and STK Integration
Matlab and STK Integration
net/publication/270086615
CITATIONS READS
8 2,566
3 authors, including:
Some of the authors of this publication are also working on these related projects:
All content following this page was uploaded by Marco Ciarcià on 16 June 2015.
animated for analysis. MATLAB script with necessary formatting is used for Satellite Tool Kit initialization and
animation. The MATLAB/Satellite Tool Kit simulation interface allows variations in number, shape, and dimensions
of spacecraft. Additionally, numerous model and simulation parameters can be selected and synchronized between
MATLAB and Satellite Tool Kit. Furthermore, either predetermined, or randomly distributed, initial spacecraft
positions and orientations are permitted by the interface. The paper gives enough details to allow the interested
readers to adapt to their needs and further develop the proposed software interface.
I. Introduction
M ODEL validation and simulation visualization are critical aspects of engineering analysis and performance evaluation for spacecraft
control algorithms [1]. An effective test scenario simulates the environment in which the control algorithm is expected to operate. For
spacecraft control system design, it is common for engineers to use The MathWorks, Inc. products MATLAB and Simulink [2,3] for dynamics and
kinematics modeling. These models are often independently developed and coded by separate researchers; therefore, modeling discrepancies can
be difficult to troubleshoot. This research suggests a method of spacecraft model validation by comparison with the Satellite Tool Kit (STK)
spacecraft analysis software [4]. STK, developed by Analytical Graphics Inc., can be used as an orbital propagator for both simulation and
emulation of the desired spacecraft models. In addition to spacecraft model validation, STK can be used for detailed animation of spacecraft
simulations.
In our research, a multiple-spacecraft six-degree-of-freedom (6-DOF) simulation was developed for the purpose of control algorithm
development during close-proximity operations. The simulator incorporates a 6-DOF MATLAB/Simulink numerical model with three-
dimensional (3-D) STK visualization. Both the model validation and 3-D visualization are intended to support engineering evaluation during
control algorithm development.
Since STK is not as commonly used in engineering fields as MATLAB, the developed simulation interface between the two software programs
is of high potential interest to many. In this research, MATLAB-developed spacecraft models were compared and validated based on the STK
standard. This paper serves an introduction to the capabilities of a MATLAB/STK simulation interface and gives enough details to allow the
readers to adapt and further develop it for their purposes [1]. As a sample case application of the developed software interface, we present the cross
validation of a multiple-spacecraft dynamic model and of a novel control algorithm. The paper is organized as follows. Section II introduces the
newly developed MATLAB/STK simulation interface, Sec. III reports the sample application of the developed interface for spacecraft modeling
verification, and Sec. IV introduces the use of the software interface for multiple-spacecraft model animation.
Presented as Paper 2007-6805 at the AIAA Modeling and Simulation Technologies Conference and Exhibit, Hilton Head, SC, 20–23 August 2007; received 5
May 2008; revision received 10 December 2012; accepted for publication 23 January 2013; published online 26 July 2013. This material is declared a work of the
U.S. Government and is not subject to copyright protection in the United States. Copies of this paper may be made for personal or internal use, on condition that the
copier pay the $10.00 per-copy fee to the Copyright Clearance Center, Inc., 222 Rosewood Drive, Danvers, MA 01923; include the code 2327-3097/13 and $10.00 in
correspondence with the CCC.
*Ph.D. Candidate, ECE Department, 700 Dyer Road; Major, U.S. Air Force; sbmccami@nps.edu.
†
Research Associate, Spacecraft Robotics Laboratory, Mechanical and Aerospace Engineering Department; mciarcia@nps.edu.
‡
Associate Professor and Director, Spacecraft Robotics Laboratory, Mechanical and Aerospace Engineering Department and Space Systems Academic Group;
mromano@nps.edu. Associate Fellow AIAA.
348
MCCAMISH, CIARCIÀ, AND ROMANO 349
MATLAB &&SIMULINK
MATLAB Simulink Satellite
SatelliteTool Kit(STK)
Tool Kit (STK)
Version
Version7.3.0267 (R2006b)
7.3.0267 (R2006b) Version 7.0.1
STK 7.0.1
The MathWorks Inc Analytical Graphics, Inc
Several parameters must be assigned before multiple-spacecraft simulations can be executed. These parameters can include the number of
simulations, initial time, selection of the acting perturbations, number of spacecraft and obstacles, selection of control algorithms, and duration of
simulation. For each simulation, a reference start time must be selected. In this research, the Universal Time (UT1) in the format of [year, month,
day, hour, minute, second] was used.
The inclusion of perturbations is critical to the fidelity of the 6-DOF spacecraft model. These perturbations forces and torques modify the
spacecraft’s simple two-body orbital propagation. Variations in the Earth’s shape and mass (J2–J4 coefficients), atmospheric drag on the
spacecraft, third-body (sun and moon) forces, and solar-radiation pressure result in disturbances in a spacecraft’s orbit [5] and attitude dynamics
(gravity gradient, and aero- and solar torque).
Once the number of chase spacecraft is selected, their initial positions must be assigned. These positions can be provided in classical orbital
elements, Earth-centered inertial (ECI), or target spacecraft’s RSW reference frame, as described in Fig. 3. Sample values of simulation conditions
are summarized in Table 1. Similar to chase spacecraft, stationary obstacles can also be included in the simulation. The control algorithm
development is discussed more in detail in [6,7].
For detailed 3-D simulations, each spacecraft’s physical characteristics must be further defined. The spacecraft size, shape, and mass are
variable for each simulation. The center of mass of the spacecraft is assumed to be located at the geometric center, and the moments of inertia are
calculated based on the spacecraft’s shape [8]. Each spacecraft is assumed to have six thrusters (for translational control) aligned along the positive
and negative primary body axes of the spacecraft. For the attitude control system, we consider three orthogonal reaction wheels aligned along the
primary spacecraft body axis. Selected spacecraft model characteristics for a sample spacecraft are listed in Table 2.
350 MCCAMISH, CIARCIÀ, AND ROMANO
Downloaded by UNIVERSITY OF CALIFORNIA on September 4, 2013 | http://arc.aiaa.org | DOI: 10.2514/1.35328
Parameter Value
Physical properties Length/width 1.0 m
Height 1.0 m
Mass 100 kg
Moment of inertia X 16.67–50 kg · m2
Moment of inertia Y 16.67–50 kg · m2
Moment of inertia Z 16.67–50 kg · m2
Thrusters Number of thrusters 1–6
Propellant type Hydrazine
Max thrust per axis 1.0 N
Specific impulse 100–200 s
Steady-state impulse 200 s
Min pulse duration 0.05 s
Min Δv 0.0005 m∕s
Max total Δv 30–120 m∕s
Propellant mass 3% of total
Attitude actuators Reaction wheels (RWs) 3
RW max torque 0.055 N · m
RW max angular momentum 4–12 N · m · s
Initial RW angular rate 0 RPMa
RW spin axis inertia 0.1426 kg · m2
Magnetotorquers 3
Max dipole moment 100 A · m2
Docking tolerances Max axial 2.0 mm
Max lateral 2.0 mm
Max angular 0.1 deg
a
RPM denotes revolutions per minute.
MCCAMISH, CIARCIÀ, AND ROMANO 351
such as spacecraft, to be loaded with desired constraints. Additionally, sensors can be defined and attached to the satellites. The GUI has dropdown
menus with layers to define basic characteristic: two-dimensional (2-D) graphic animation, 3-D graphic animation, and related constraints.
Several additional STK-supported modules may be useful for spacecraft proximity maneuver simulations. These modules supplement the core
STK visualization environment and assist in the evaluation of mission sequences. In particular, the Astrogator module can be used to support
detailed maneuver analysis and operations [10]. Similarly, the Advanced Close Approach Tool (ACAT) module may be useful in collision-
avoidance maneuver planning. This STK module allows for the additional situational awareness of any spacecraft or object in the referenced
database. The ACAT module enables proximity indications and visual cues for variable close-approach calculations.
C. MATLAB/STK Interface
The MATLAB/STK interface allows overall simulation parameters and spacecraft physical characteristics to be defined in MATLAB and
related to STK via the mexConnect MATLAB commands or formatted native STK commands. This interface technique takes advantage of STK’s
standard connection protocol for initializing STK from MATLAB. Once it is initialized, native STK commands can be called from MATLAB. In
addition, formatted ephemeris and attitude files can be passed from MATLAB to STK. Similarly, data can be retrieved from STK by using the
stkReport command. Getting ephemeris from STK and passing it to the MATLAB engine allows for comparison of independently generated
STK and MATLAB spacecraft propagation. Evaluating the results of this comparison allows for validation of a developed MATLAB model based
on the STK’s High-Precision Orbital Propagator (HPOP). The satellite of interest must be initialized and assigned with HPOP before the
propagation parameters and perturbations can be tailored via HPOP commands.
The MATLAB/STK simulation interface code was written in MATLAB (.m file format) with some MATLAB/Simulink files nested within it.
Downloaded by UNIVERSITY OF CALIFORNIA on September 4, 2013 | http://arc.aiaa.org | DOI: 10.2514/1.35328
These subfiles serve as modular components of the MATLAB/STK interface, allowing easier simulation variation and modification
between users.
For the standard MATLAB/STK connection, both MATLAB and STK applications should be loaded and launched. Once launched, STK can be
initialized from MATLAB by using the commands stkInit or agiInit. Information on the path setting established can be found by using
agiGetConfig. The next step in the connection processes is to open a socket by using stkOpen. This configures the path and assigns a socket
variable and a MATLAB variable, called STKError, for reference. Via the established MATLAB/STK connection, STK can be commanded by
using either a select number of mexConnect commands or native STK commands. The command paths for these two methods are slightly
different. The mexConnect commands are a limited subset of core MATLAB/STK interface commands that can be found by exploring the
MATLAB help menu. These mexConnect commands are all prefixed with stk, such as the stkInit commands mentioned previously. Since
the mexConnect commands are limited, there is a general command that allows native STK commands to be executed from MATLAB. The
general execution of STK commands via MATLAB can be conducted by using stkExec(ConID, ‘Command Path Parameter’). A full
listing of native STK commands that can be implemented in this fashion are listed in the STK help menu under the path <Automate/Extend/
Integrate>, <Command Listings>, <Alphabetical Listing>. The first step is usually to open a new STK scenario and ensure that any previous
scenarios are closed. The initial MATLAB/STK interface code is listed in MATLAB code excerpt 1 (Fig. 4). The conID variable serves as a
numeric representation of the established connection, and it will be used often in stkExec commands. The STK scenario name was determined
by a MATLAB variable, such as CONST.simnum, which can be selected by the user to represent the number of simulations or scenarios desired.
The same name was then used to establish the new STK scenario. The stkNewObj command path is establishing the new scenario at the highest-
level path level. All subsequent STK objects, such as spacecraft, will be assigned under this current scenario.
The selected simulation initial date and time must be properly formatted and passed to STK. For STK applications, the date and time must be
rearranged and passed in the format of [21 Jul 2007 12:30:00.0]. If the MATLAB datestr command is used to determine the date and time, then
a method of reformatting and passing the date and time to STK is listed in MATLAB code excerpt 2 (Fig. 5).
In the newpara variable, the second-to-last number is the animation time step in seconds, and the last number is the highest speed or refresh
rate in seconds. The scale of these rates will influence the simulation by changing the animation of the scenario. These values can also be assigned
as variables in the stkConnect command, where the variable scen_nam is used.
Multiple-spacecraft simulations require several spacecraft to be created. The sample code in MATLAB code excerpt 3 (Fig. 6) shows a
spacecraft, called target, being created. The visualization option (VO) command is used to call a general spacecraft graphical model that is
available to STK. The spacecraft graphical model can be selected from a default list, usually located at C:\Program Files\AGI\STK 7
\STKData\VO\Models\Space, or a custom user-generated spacecraft graphical model. The development of simple spacecraft graphical
models will be discussed in more detail in Sec. IV.
mass (J2–J4 coefficients), atmospheric drag on the spacecraft, third-body (sun and moon) forces, and solar-radiation pressure, were sequentially
evaluated. Table 3 reports the average differences, in terms of position and velocity, of several low-Earth-orbit orbital propagations of 10
spacecraft at various initial conditions. Each orbit was propagated for 30 min and 1 min durations with fixed 1 s step sizes [11].
The HPOP command allows for assignment of both a numerical integration method, such as the fourth-order Runge–Kutta, and an Earth
gravitational model (EGM), such as EGM96 [2,3,5]. The HPOP command is of the general form stkExec(ConID, ‘HPOP Path
Parameter’). Once the HPOP is assigned to a spacecraft, the perturbation forces can be further defined. The desired perturbations can be
related to the enabling condition on the Simulink model so that the various perturbations can be independently evaluated.
Selection of the perturbation parameter, CONST.PERT.choice, activates the desired perturbation code. The coefficients can be
synchronized with any particular user-defined model by modifying the .grv file selected. As previously discussed, the variable can be passed into
the STK command. For instance, the coefficient of drag, represented by Cd, was incorporated into the Drag and SolarRad command settings.
Once the HPOP settings are completed, the actual propagation can be computed. The initial stop time, tstopdummy, is replaced with the final
desired propagation time, tstop. The spacecraft propagation command is listed in MATLAB code excerpt 5 (Fig. 7), where the propagation
parameters of stepsize, orbitepoch, STATE.ri, and STATE.vi are the same as in the initial propagation command.
The data from STK propagation can be passed to the MATLAB workspace. This will allow any desired postprocessing and evaluation of the
data. STK spacecraft state data can be passed in several formats. For this research, the ECI position and velocity were desired. The sample code for
passing spacecraft ephemeris is listed in MATLAB code excerpt 5 (Fig. 8), with the variables, prefixed with STATE.STK, arbitrarily assigned. The
STK ephemeris data are in column format, with each row representing a numerical integration step. Although not the focus of this research, the
user can also pass spacecraft attitude data back to the MATLAB workspace as shown in MATLAB code excerpt box 6 (Fig. 9).
visualization are prewritten in STK Modeler. Once the model is loaded and the scenario is established, data can be passed between STK and
MATLAB. For this research, visualization included basic cubic, spherical, and cylindrical spacecraft graphical models. A snapshot of a sample
3-D animation of multiple spacecraft is shown in Fig. 10. Three cubic chase spacecraft are shown converging toward a common target spacecraft,
with a spherical obstacle in the background on the right.
MATLAB code excerpt 8 (Fig. 12). The variable L represents user-defined dimensional parameters that can be implemented in the model. In this
code, the face component was defined first. Next, this component was translated and rotated as necessary to determine all sides of the cubic
spacecraft. Additional components (cone, cylinder, etc.) can also be defined. More detailed components can be generated by combining additional
subcomponents.
Once the primary spacecraft components, including the cubic faces, docking ports, and thrusters, are defined, they can be assembled. Each of
the six cubic components will make the basic spacecraft shape. Next, a thruster with flame articulation will be centered on each face of the cubic
spacecraft. Finally, the desired number of docking ports will be added based on the total number of spacecraft.
research, a conical ranging and docking sensor was added to each chase spacecraft. The ranging sensor represents the local sensor view from the
chase spacecraft to the target spacecraft, or position. The simple conic range sensor is assigned in MATLAB code excerpt 13 (Fig. 17). First, the
sensor is positioned and defined on a spacecraft with an exclusive name. In this example, Chase is an alphanumeric label unique to each chase
Fig. 16 MATLAB code excerpt 12: spacecraft model 3-D body reference frame.
spacecraft. Next, the pointing direction of the sensor is determined. The range sensor continually points toward the target spacecraft and adjusts its
projection based on the relative distance from the target, represented by rsw_norm. This modification of the projection may not be necessary for
most sensor applications. Finally, the color of the sensor projection can be modified as desired. Similarly, a docking sensor may be added to the
spacecraft graphical model, as listed in MATLAB code excerpt 14 (Fig. 18).
The docking sensor is located at the same position, but it has a much wider cone of 45 deg. The docking sensor points in a fixed direction from
the spacecraft body axis, with a limited projection of half of the spacecraft’s length. Next, the sensor projection color is selected from a matrix,
called dockc. These simple sensors are useful in visually representing ranges and fields of view (FOVs) as spacecraft are animated through their
dynamics and kinematics. A sample cubic spacecraft with labels and sensor projections is shown in Fig. 19. The three-body axes are labeled
“Body X”, “Body Y”, and “Body Z”. The projection on the right side of the spacecraft is the docking sensor projection, and the small line
extending to the bottom left is the range sensor. The white protrusions on the top and right are thruster firings.
One additional sensor projection was useful in visualizing spacecraft exclusion regions during close-proximity operations. A boundary sensor
projection was placed around regions that spacecraft were intended to avoid. These areas were referred to as obstacles and labeled with Obstcl.
Downloaded by UNIVERSITY OF CALIFORNIA on September 4, 2013 | http://arc.aiaa.org | DOI: 10.2514/1.35328
Spherical projections encompassing these regions can be generated using a conical sensor defined with a 360 deg FOV, such as listed in MATLAB
code excerpt 15 (Fig. 20). The spherical sensor projections were made translucent in order to not obscure the view of maneuvering spacecraft. A
sample spherical boundary sensor projection about a spherical object is shown in Fig. 21. The sensor projection is the globular grid with the chase
Fig. 17 MATLAB code excerpt 13: simple conic range sensor for spacecraft model.
Fig. 18 MATLAB code excerpt 14: simple conic docking sensor for spacecraft model.
spacecraft in the upper right. These sensors allowed for robust engineering evaluation of the collision-avoidance function of spacecraft control
algorithms [6,7,12,13]. From these basic examples, the user can develop a vast array of representative sensors. Sensor projection ranges and colors
can be varied based on logical condition. For instance, ranging sensors may be programmed to modify their color as the distance to a target varies.
This may allow for quick visual analysis of multiple-spacecraft maneuver performance.
folder. The first few fprintf lines are used to establish the desired reference frame and interpolation for the data. The variables STATE.time and
para_now are used to synchronize the data points with the time constraints, as discussed in Sec. I.C.2. The data are formatted into seven
columns, represented by time, position vector, and velocity vector. Each row represents an iteration, or step size, of the data. Similarly, a STK
quaternion attitude file can be created, such as in MATLAB code excerpt 17 (Fig. 23). The STK attitude file name and path are arbitrary, as long as
it has the proper .a suffix. This sample STK attitude file is formatted into five columns with time, the three-element quaternion vector, and the
quaternion scalar (rotational) term.
C. Sample Visualization
STK scenarios can be made into video files that can offer useful representation of complex situations and maneuvers. For instance, a sample
visualization of a docking maneuver between seven cubic spacecraft is shown in Fig. 24. The docking maneuver consists of a target spacecraft at
the center of the screen with six chase spacecraft converging from different initial positions. The six chase spacecraft are labeled Chase1–Chase6,
Fig. 22 MATLAB code excerpt 16: formating MATLAB/Simulink ephemeris data for STK.
Downloaded by UNIVERSITY OF CALIFORNIA on September 4, 2013 | http://arc.aiaa.org | DOI: 10.2514/1.35328
Fig. 23 MATLAB code excerpt 17: formating MATLAB/Simulink attitude data for STK.
respectively. Chase spacecraft 1 through 3 have obstacles placed along their primary maneuver paths. The three obstacles are labeled Object1–
Object3, respectively. The obstacles are 2.0 m spheres with globular mesh region of influence projections.
The solid line through the center of the screen is the targets spacecraft’s orbital path. The lighter lines are range sensors from each chase
spacecraft toward the target spacecraft. The Earth’s horizon can be seen at the bottom of the figure.
This sample animation was developed to the collision-avoidance and close-proximity maneuver capabilities of a novel new control algorithm
described in detail in [6,7]. This sample animation has been made available online.
V. Conclusions
A MATLAB/ Satellite Tool Kit (STK) simulation interface was developed for spacecraft model validation and visualization. By using the
proposed interface, the spacecraft characteristics and parameters, together with simulation results, can be interchanged between MATLAB/
Simulink and STK. In particular, using STK via MATLAB is a versatile and effective method of animating six-degree-of-freedom spacecraft
models. The resulting STK animation of spacecraft propagations is useful for engineering evaluation and result presentations.
The proposed interface was used during the development of a multiple-spacecraft control algorithm for close-proximity operations. Model
validation gave confidence in the performance results, and visualization allowed for straightforward evaluation. The animation allowed for
immediate identification of undesirable performance, such that modifications and improvements could be made to the control algorithm.
Acknowledgments
This research has been supported in part by the U.S. Department of Defense. S. B. McCamish gratefully acknowledges the support from both
faculty and students at the Naval Postgraduate School.
References
Downloaded by UNIVERSITY OF CALIFORNIA on September 4, 2013 | http://arc.aiaa.org | DOI: 10.2514/1.35328
[1] McCamish, S. B., and Romano, M., “Simulations of Relative Multiple-Spacecraft Dynamics and Control by MATLAB–Simulink and Satellite Tool Kit,”
AIAA Modeling and Simulation Technologies Conference, AIAA Paper 2007-6805, Aug. 2007.
[2] MATLAB version 7.3, THE MATHWORKS INC., Natick, Massachusetts, 2006.
[3] Simulink version 6.5, THE MATHWORKS INC., Natick, Massachusetts, 2006.
[4] Satellite Tool Kit, Software Package, ANALYTICAL GRAPHICS INC., Exton, PA, 2006.
[5] Vallado, D. A., Fundamentals of Astrodynamics and Applications, 2nd ed., Microcosm Press, El Segundo, CA, 2001.
[6] McCamish, S. B., Romano, M., and Yun, X., “Autonomous Distributed Control Algorithm for Multiple Spacecraft in Close Proximity Operations,” AIAA
Guidance, Navigation and Control Conference, AIAA Paper 2007-6857, Aug. 2007.
[7] McCamish, S. B., Romano, M., and Yun, X., “Autonomous Distributed LQR/APF Control Algorithm for Multiple Small Spacecraft during Simultaneous
Close Proximity Operations,” 21st Annual AIAA/USU Conference on Small Satellites, SSC07-XIII-3, Logan, UT, Aug. 2007.
[8] Larson, W.J., and Wertz, J.R., Space Mission Analysis and Design, 3rd ed., Microcosm Press, El Segundo, CA, 2004.
[9] Endres, S. M., “Simulation and Emulation of the Space Networking Environment,” M.S. Thesis, Dept. of Electrical Engineering and Computer Science, Case
Western Reserve Univ., Cleveland, OH, Jan. 2005.
[10] Carrico, T., Langster, T., Carrico, J., Vallado, D., Loucks, M., and Alfano, S., “Proximity Operations for Space Situational Awareness,” Advanced Maui Optical
and Space Surveillance Technologies Conference, Wailea Maui, HI, Sept. 2006, pp. 1–11.
[11] McCamish, S. B., “Distributed Autonomous Control of Multiple Spacecraft During Close Proximity Operations,” Ph.D. Dissertation, Naval Postgraduate
School, Monterey, CA, Dec. 2007.
[12] McCamish, S. B., Romano, M., and Yun, X., “Autonomous Distributed Control of Simultaneous Multiple Spacecraft Proximity Maneuvers,” IEEE
Transaction on Automation Science and Engineering, Vol. 7, No. 3, 2010, pp. 630–643.
doi:10.1109/TASE.2009.2039010
[13] McCamish, S. B., Romano, M., Nolet, S., Edwards, C. M., and Miller, D. W., “Flight Testing of Multiple Spacecraft Control on SPHERES During Close
Proximity Operations,” Journal of Spacecraft and Rockets, Vol. 46, No. 6, 2009, pp. 1202–1213.
doi:10.2514/1.43563
G. Brat
Associate Editor