Pg 1 of 59 AGI Customizing computations with STK Plug-ins using compiled code Dr. Vince Coppola – Analytical Graphics, Inc. October 2005.
Post on 22-Dec-2015
226 Views
Preview:
Transcript
Pg 1 of 59AGI www.agiuc.com
Customizing computations with STK Plug-ins using compiled code
Dr. Vince Coppola – Analytical Graphics, Inc.
October 2005
Pg 2 of 59AGI www.agiuc.com
Outline
• What is an STK plug-in?
• Motivation: TDRS SRP Model
• COM based plug-ins
• Access constraint example
• Questions and answers
Pg 3 of 59AGI 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
Pg 4 of 59AGI 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
Pg 5 of 59AGI 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– Gravity field (solid tides?) (ocean tides?)– Third body gravity (Sun, Moon, others?)– General relativity effect– Solar radiation pressure (SRP)
Pg 6 of 59AGI 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
Pg 7 of 59AGI 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
Pg 8 of 59AGI 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
Pg 9 of 59AGI 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
Pg 10 of 59AGI 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
Pg 11 of 59AGI 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
Pg 13 of 59AGI www.agiuc.com
Performance
143168
329
0
50
100
150
200
250
300
350
C++ C# Jscript
90 days propagation
seco
nds
Pg 14 of 59AGI www.agiuc.com
Plug-in evolution
• STK 4.3 introduced plug-in scripts (2002)– Perl, VBScript, Matlab scripts– AGI-developed interface
• Installation• Calling conventions• Debugging ideas• Troubleshooting
Pg 15 of 59AGI www.agiuc.com
Available plug-in points
• 15 plug-in points– Astrogator– Vector Tool– Access constraint– Attitude simulator– Communications modeling
Pg 16 of 59AGI www.agiuc.com
Plug-in scripts
• Use– Only needed when generic models are insufficient– Several customers rely on this capability
• Limitations– 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 17 of 59AGI 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
Pg 18 of 59AGI 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
Pg 19 of 59AGI 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
Pg 20 of 59AGI 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
Pg 21 of 59AGI 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
Pg 22 of 59AGI 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!
Pg 23 of 59AGI www.agiuc.com
HPOP plug-in events
• Init()
• PrePropagate()
• PreNextStep()
• Evaluate()
• PostEvaluate()
• PostPropagate()
• Free()
Pg 24 of 59AGI www.agiuc.com
Hpop plug-in events (cont.)
PostPropagate()
PrePropagate()
while needing to take another step
{ PreNextStep()
Attempt the step
while haven’t taken a good step
{
Assess whether step is good
}}
Pg 25 of 59AGI www.agiuc.com
Hpop plug-in events (cont.)
Attempt the step:
Evaluate force model :
Evaluate()
Perform preliminary computations
Compute all force model contributions
PostEvaluate()
Add all force model contributions
Pg 26 of 59AGI 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)
Pg 27 of 59AGI 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)
}
Pg 28 of 59AGI 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()
Pg 29 of 59AGI 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
Pg 30 of 59AGI 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
Pg 31 of 59AGI 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
Pg 37 of 59AGI 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
Pg 38 of 59AGI www.agiuc.com
Building plug-in components
• Scripting languages– Windows script host– Text editor
• Compiled languages– Microsoft Visual Studio (C++, C#, VB.NET)
Pg 39 of 59AGI 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
Pg 40 of 59AGI 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
Pg 41 of 59AGI 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
Pg 42 of 59AGI 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
Pg 43 of 59AGI 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
Pg 44 of 59AGI www.agiuc.com
TDRS SRP model (cont.)
AddBoolDispatchProperty (
scope,
"DebugMode",
"Turn debug messages on or off",
"DebugMode",
eFlagNone )
Pg 45 of 59AGI www.agiuc.com
TDRS SRP model (cont.)
AddDoubleDispatchProperty (
scope,
"Reflectivity_Specular",
"Specular reflectivity coefficient",
"SpecularReflectivity",
eFlagNone )
Pg 48 of 59AGI www.agiuc.com
Choosing a plug-in language
Language SpeedCode
complexityMemory Debug
Scripting Slower Simple Automatic No
C#, VB.NET
Fast Medium Automatic Yes
C++ Fastest DifficultManage
yourselfYes
Pg 49 of 59AGI 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– 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 50 of 59AGI 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
Pg 52 of 59AGI 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
Pg 53 of 59AGI www.agiuc.com
Ground sampled distance
• Built in GSD constraint
• pp is the pixel pitch
• range is the slant range
• θ is the ground elevation angle
• f is the focal length
sinf
rangeppGSD
Pg 54 of 59AGI www.agiuc.com
Ground spot size and optical ratio
• Ground spot size due to the optics
• D is the optical diameter
• λ is the wavelength
• The optical ratio
sinD
rangeGSS
Dpp
f
GSD
GSSQ
Pg 55 of 59AGI www.agiuc.com
Alternate GSD
• Can perform trade studies on GSD as we vary Q
• Create a plug-in constraint– Implement GSD as function of Q
sin
DQ
rangeGSD
Pg 56 of 59AGI www.agiuc.com
Q Variation Study
Q = 0.583Q = 0.750Q = 1.000Q = 1.250Q = 1.500Q = 1.750Q = 2.000
Pg 57 of 59AGI 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
• Create a plug-in access constraint
SNR
GHRERb
GSDaNIIRS
344.0656.0log
)(log251.10
10
10
inches in
top related