Customizing computations with STK
Plug-ins using compiled code
Dr. Vince Coppola – Analytical Graphics, Inc.
October 2005
AGI
Pg 1 of 59
www.agiuc.com
Outline
• What is an STK plug-in?
• Motivation: TDRS SRP Model
• COM based plug-ins
• Access constraint example
• Questions and answers
AGI
Pg 2 of 59
www.agiuc.com
What is an STK plug-in?
• Custom software that STK uses during
computations
• Purpose
– Customize models used in STK computations to specific
needs
AGI
Pg 3 of 59
www.agiuc.com
What is an STK plug-in? (cont.)
• Differs from STK/Connect
– Not used to control task flow
• Differs from STK/X and 4DX
– Not used for custom GUIs
– Not used for creating a custom application
AGI
Pg 4 of 59
www.agiuc.com
Example: TDRS SRP model
• TDRS
– GEO Communication satellite
– Solar panels track Sun
– Solar sail, AW C-band antenna, and SGL antenna are nominally
Earth-pointing
• Need
– Generate ephemeris using a high-fidelity force model
• Force Model Contributors
–
–
–
–
AGI
Gravity field (solid tides?) (ocean tides?)
Third body gravity (Sun, Moon, others?)
General relativity effect
Solar radiation pressure (SRP)
Pg 5 of 59
www.agiuc.com
TDRS SRP model (cont.)
• Solar radiation pressure force
– Depends on particle absorption and reflection
– Depends on surface orientation
– Surface orientation varies along the trajectory
• Generic model: spherical shape
– Accel = Cr * (Area/mass) * Illumination * Irradiance / c
– Directed along apparent sun line
– Supported by STK
AGI
Pg 6 of 59
www.agiuc.com
TDRS SRP model (cont.)
• Better model for TDRS
–
–
–
–
Based on Pechenick, K. and Hujsak, R. (1987)
Account for surface orientation of main parts
Account for diffuse and specular reflection
Accel = Cr *(1.0/mass)* Illumination * Irradiance / c *
{A1 k + A2 k x ( k x N ) + A3 k x ( k x M ) }
– k – along sun line, N normal to solar panels, M radial
– A1, A2, A3 depends on area, reflection values
AGI
Pg 7 of 59
www.agiuc.com
TDRS SRP model (cont.)
• Use a HPOP Plug-in
– Code the model in a computer language of choice
• C++, C#, VB.NET, Perl, VBScript, Jscript, etc.
– Adhere to the published plug-in interface
• Sample code provided
– Choose to use the plug-in from the HPOP GUI
• Just like the other force model settings
– Set any plug-in specific parameters from the GUI
• Similar to the other force model settings
– Configure the remaining force model parameters
– HPOP generates the ephemeris using the force model
AGI
Pg 8 of 59
www.agiuc.com
TDRS SRP model (cont.)
• What you don’t code (nor test, doc, maintain)
–
–
–
–
–
All the other force model contributions
The numerical integration algorithm
The VOP formulation
The time regularization algorithm
The covariance propagation algorithm
• Save time and avoid risk
– Code only the custom part
AGI
Pg 9 of 59
www.agiuc.com
Purpose
Plug-ins provide the means for custom
modeling while leveraging STK’s tested
generic computational framework
Only code the custom part of the model
AGI
Pg 10 of 59
www.agiuc.com
HPOP plug-in uses
• Attitude dependent SRP
• Attitude dependent Drag
• Density model
• Satellite thermal emission
• Micrometeorite particle collisions
• Re-entry drag and lift
• Outgasssing (thrust without mass loss)
– Models non-physical accelerations
AGI
Pg 11 of 59
www.agiuc.com
Outgassing
AGI
Pg 12 of 59
www.agiuc.com
Performance
90 days propagation
329
350
300
seconds
250
200
143
168
150
100
50
0
C++
AGI
C#
Pg 13 of 59
Jscript
www.agiuc.com
Plug-in evolution
• STK 4.3 introduced plug-in scripts (2002)
– Perl, VBScript, Matlab scripts
– AGI-developed interface
•
•
•
•
AGI
Installation
Calling conventions
Debugging ideas
Troubleshooting
Pg 14 of 59
www.agiuc.com
Available plug-in points
• 15 plug-in points
–
–
–
–
–
AGI
Astrogator
Vector Tool
Access constraint
Attitude simulator
Communications modeling
Pg 15 of 59
www.agiuc.com
Plug-in scripts
• Use
– Only needed when generic models are insufficient
– Several customers rely on this capability
• Limitations
–
–
–
–
–
AGI
3 languages – Perl, VBScript, Matlab
Not as fast as compiled code
Non-standard function calling conventions
Requested input data must be known a priori
Unable to get/set plug-in parameter data
Pg 16 of 59
www.agiuc.com
COM-based plug-ins
• Computer programmer-friendly plug-ins
– Based on Microsoft’s COM technology
• STK 6.1 introduced COM Plug-ins (2004)
– HPOP
• STK 6.2 (2005)
– Astrogator engine model, Astrogator attitude controller
• STK 7.0 (2005)
– Alpha prototype for Access constraints, dynamic phase
array antenna
AGI
Pg 17 of 59
www.agiuc.com
COM
• Component Object Model
– Standard Microsoft protocol
– Many languages (Windows operating system)
• C++, C#, VB.NET, Perl, VBScript, Jscript
– Sun Java
• No samples yet  customer interest?
– Microsoft J++ / J#
• No samples yet
AGI
Pg 18 of 59
www.agiuc.com
Plug-in concepts
• Focused on a computational task
–
–
–
–
HPOP: evaluating the force model
Attitude controller: steering an engine
Engine model: modeling thrust and flow rate
Access constraint: providing a visibility measure
• Plug-in point
– Own triggering events
– Provides interface for setting/getting input/output data
AGI
Pg 19 of 59
www.agiuc.com
Plug-In Points
• Must modify STK to make a plug-in point
–
–
–
–
Identify a computation
Identify a need for user customization
Identify the triggering events
Identify inputs and outputs
• Made available as need arises
AGI
Pg 20 of 59
www.agiuc.com
Matlab plug-ins
• Previous capability supported Matlab
– Compatible with Matlab version 6.x and 7.x
• Matlab is COM-aware
– Can use COM objects
– Can be used as a COM object
• Recommendation
– Use a scripting language plug-in to STK
– Call Matlab from scripting language
AGI
Pg 21 of 59
www.agiuc.com
HPOP plug-in
• Custom force model
• Supported by STK and ODTK
• Plug-in scripts
– Astrogator propagator plug-in
– Custom force model
– Migration to COM plug-ins  soon!
AGI
Pg 22 of 59
www.agiuc.com
HPOP plug-in events
• Init()
• PrePropagate()
• PreNextStep()
• Evaluate()
• PostEvaluate()
• PostPropagate()
• Free()
AGI
Pg 23 of 59
www.agiuc.com
Hpop plug-in events (cont.)
PrePropagate()
while needing to take another step
{
PreNextStep()
while haven’t taken a good step
{
Attempt the step
Assess whether step is good
}
}
PostPropagate()
AGI
Pg 24 of 59
www.agiuc.com
Hpop plug-in events (cont.)
Attempt the step:
Evaluate force model :
Perform preliminary computations
Evaluate()
Compute all force model contributions
PostEvaluate()
Add all force model contributions
AGI
Pg 25 of 59
www.agiuc.com
Calling convention
• Plug-in scripts passed input / output data
• COM based plug-ins pass interfaces
– Each event has an interface appropriate for that event
– The interface has properties and methods for getting
inputs and outputs
bool
Evaluate( IAgAsHpopPluginResultEval interface)
AGI
Pg 26 of 59
www.agiuc.com
Calling Convention (cont.)
bool
Evaluate( IAgAsHpopPluginResultEval interface)
illum = interface.SolarIntensity
if(illum > 0)
{
interface.SunPosition(eSRP, eInertial,
sunX, sunY, sunZ)
… <compute SRP acceleration> …
interface.AddAccleration(eInertial, aX, aY, aZ)
}
AGI
Pg 27 of 59
www.agiuc.com
Calling Convention (cont.)
Init( IAgUtPluginSite siteInterface)
PrePropagate( IAgAsHpopPluginResult interface)
PreNextStep( IAgAsHpopPluginResult interface)
Evaluate( IAgAsHpopPluginResultEval interface)
PostEvaluate( IAgAsHpopPluginResultPostEval
interface)
PostPropagate( IAgAsHpopPluginResult interface)
Free()
AGI
Pg 28 of 59
www.agiuc.com
Exception handling
• Event calls return a Boolean value
– True: everything is okay
– False: an unrecoverable error occurred
• Turns this event off – no longer called
• STK code captures exceptions raised by a plug-in
– Exception text sent to message viewer
• Certain interface function may fail
– Sets a defined error code
AGI
Pg 29 of 59
www.agiuc.com
Inputs and outputs
• Specific to each interface
• Ephemeris
• Variables pertaining to the plug-in point
– HPOP: Cd, Drag Area, Cr, SRP Area, Mass, etc.
– Engine Model: thrust, mass flow rate, Isp
– Attitude Controller: Euler angles, quaternion
• Methods and properties
AGI
Pg 30 of 59
www.agiuc.com
Documentation
• Compiled help file (stkPlugins.chm)
–
–
–
–
Plug-in points
Triggering events
Interface methods and properties
7 language syntaxes shown
• VB.NET, VB6, C#
• Managed C++, Unmanaged C++
• VBScript, Perl
AGI
Pg 31 of 59
www.agiuc.com
Evaluate method
AGI
Pg 32 of 59
www.agiuc.com
Evaluate method (cont.)
AGI
Pg 33 of 59
www.agiuc.com
Eval interface
AGI
Pg 34 of 59
www.agiuc.com
SunPosition method
AGI
Pg 35 of 59
www.agiuc.com
SunPosition_Array method
AGI
Pg 36 of 59
www.agiuc.com
IAgUtPluginSite interface
• bool Init( IAgUtPluginSite site)
• Message Viewer
– Write messages to message viewer
• Vector Tool
– Vectors, axes, points, angles, etc
– Ephemeris and attitude of any object expressed in any
components
• Astrogator Calc Objects
AGI
Pg 37 of 59
www.agiuc.com
Building plug-in components
• Scripting languages
– Windows script host
– Text editor
• Compiled languages
– Microsoft Visual Studio (C++, C#, VB.NET)
AGI
Pg 38 of 59
www.agiuc.com
Installation
• Standard COM registration
• Registration in the Windows registry
– GUID
– Regsvr32
• C++ components
• Perl, VBScript, Jscript components
– Regasm
• .NET components (C#, VB.NET)
• Must register on every machine you want to run on
AGI
Pg 39 of 59
www.agiuc.com
Debugging
• Available for compiled plug-ins
– Able to debug plug-in code when running STK
– Must exit STK before re-building the plug-in
• Not available for scripting languages
– Create a log file instead
– Use message viewer (but not too much)
– Advantage: Can edit text file with STK running
• Helps to reduce cycle time
AGI
Pg 40 of 59
www.agiuc.com
TDRS SRP model
• Init()
– Return true to turn plug-in On
• PrePropagate()
– Check whether SRP is On
– Pre-compute some variables
• PreNextStep, PostPropagate(), Free()
– If debug mode, output msgs else do nothing
AGI
Pg 41 of 59
www.agiuc.com
TDRS SRP model (cont.)
• Evaluate()
– Compute SRP based on formula
– Use interface->AddAcceleration()
• PostEvaluate()
– If debug mode, output diagnostic messages to viewer
AGI
Pg 42 of 59
www.agiuc.com
TDRS SRP model (cont.)
• Plug-in parameter data
– Diffuse reflectivity, specular reflectivity
– ‘Debug’ settings (messages sent to MessageViewer)
• IAgUtPluginConfig
– Implement this interface to set / get parameter data
– GetPluginConfig()
• Register parameter data with STK
– VerifyPluginConfig()
• Determine whether user settings are acceptable
AGI
Pg 43 of 59
www.agiuc.com
TDRS SRP model (cont.)
AddBoolDispatchProperty
(
scope,
"DebugMode",
"Turn debug messages on or off",
"DebugMode",
eFlagNone )
AGI
Pg 44 of 59
www.agiuc.com
TDRS SRP model (cont.)
AddDoubleDispatchProperty (
scope,
"Reflectivity_Specular",
"Specular reflectivity coefficient",
"SpecularReflectivity",
eFlagNone )
AGI
Pg 45 of 59
www.agiuc.com
TDRS SRP model (cont.)
AGI
Pg 46 of 59
www.agiuc.com
TDRS SRP model (cont.)
AGI
Pg 47 of 59
www.agiuc.com
Choosing a plug-in language
Language
Speed
Code
complexity
Scripting
Slower
Simple
Automatic
No
C#,
VB.NET
Fast
Medium
Automatic
Yes
Memory
Debug
Manage
C++
AGI
Fastest
Difficult
Pg 48 of 59
yourself
Yes
www.agiuc.com
Using COM in plug-in scripts
• Post STK 7.0
– Migration to use COM based plug-ins
• Able to use COM plug-ins from VBScript
–
–
–
–
–
–
AGI
Restricted to inputs / outputs available
Must use AGI-defined interface
Get handle to the COM component on initialization
Route inputs to the COM component
Have COM component compute values
Return using plug-in script mechanism
Pg 49 of 59
www.agiuc.com
Access constraints
• Constraints are often measures
–
–
–
–
Elevation angle
Range
Ground elevation angle
Sunlight
• Used for visibility and for Figures Of Merit (FOM)
– Coverage: visibility to a grid of points
– FOM: quality of coverage during visibility times
AGI
Pg 50 of 59
www.agiuc.com
Figure of merit
AGI
Pg 51 of 59
www.agiuc.com
Example: image quality
• Sensor taking a picture of ground
–
–
–
–
Oblique geometry of sensor with respect to ground
Sensor properties (focal length, pixel resolution)
Ground properties (sun elevation)
Time effects
• Create an access constraint plug-in
– Use as an image quality metric
AGI
Pg 52 of 59
www.agiuc.com
Ground sampled distance
• Built in GSD constraint
GSD 
pp  range
f
sin 
• pp is the pixel pitch
• range is the slant range
• θ is the ground elevation angle
• f is the focal length
AGI
Pg 53 of 59
www.agiuc.com
Ground spot size and optical ratio
• Ground spot size due to the optics
GSS 
  range
D sin 
• D is the optical diameter
• λ is the wavelength
• The optical ratio
Q
GSS

GSD
AGI
 f
pp  D
Pg 54 of 59
www.agiuc.com
Alternate GSD
GSD 
  range
Q  D  sin 
• Can perform trade studies on GSD as we vary Q
• Create a plug-in constraint
– Implement GSD as function of Q
AGI
Pg 55 of 59
www.agiuc.com
Q Variation Study
Q = 2.000
0.583
0.750
1.000
1.250
1.500
1.750
AGI
Pg 56 of 59
www.agiuc.com
NIIRS
• National Image Interpretability Rating Scale
– “Image quality for remote sensing systems,” Robert
Fiete, Eastman Kodak, Opt. Eng. 38(7), July 1999.
– For electro-optical systems
NIIRS  10.251  a log 10 GSD(in inches )
 b log 10 RER  0.656 H  0.344
G
SNR
• Create a plug-in access constraint
AGI
Pg 57 of 59
www.agiuc.com
NIIRS Results
Q = 2.000
AGI
Pg 58 of 59
www.agiuc.com
Questions & answers
AGI
Pg 59 of 59
www.agiuc.com
Descargar

STK plug-ins using compiled code