Matlab与STK连接函数库(重新整理).doc
没谱青年重新整理2012年4月12日目 录一、Matlab/Simulink、STK联合仿真的优势1二、mexConnect函数详细介绍22.1 STK服务器命令(STK Server Commands)22.1.1 stkDefaultConID22.1.2 stkDefaultHost22.1.3 stkSetDefaultHost22.2 应用命令(Application Commands)22.2.1 stkAutoSave22.2.2 stkHomeDir22.2.3 stkCurrentDir22.2.4 stkSetCurrentDir22.2.5 stkObjNames22.2.6 stkTimerStart32.2.7 stkTimer32.3 普通对象命令(Generic Object Commands)32.3.1 stkCentralBody32.3.2 stkLoadObj32.3.3 stkSaveObj32.3.4 stkNewObj32.3.5 stkUnload42.3.6 stkUnloadChildren42.3.7 stkRename42.3.8 stkTimePeriod42.3.9 stkTimePeriodInSec52.3.10 stkValidObj52.3.11 stkDescrip52.3.12 stkSetDescrip52.4 场景命令(Scenario Commands)62.4.1 stkAnimTime62.4.2 stkEpoch62.4.3 stkSetEpoch62.4.4 stkSetEpochInSec62.4.5 stkSyncEpoch62.4.6 stkConvertDate62.4.7 stkSetTimePeriod62.4.8 stkSetTimePeriodInSec72.4.9 stkScenFilePath72.4.10 stkValidScen72.5 基本飞行器数据(Basic Vehicle Data)72.5.1 stkTimePeriod72.5.2 stkTimePeriodInSec72.5.3 stkSetTimePeriod72.6 卫星运动属性(Satellite Propagators)82.6.1 stkSetPropCart82.6.2 stkSetPropClassical82.6.3 stkSetPropEqui92.6.4 stkSetPropSGP492.6.5 stkPropagate102.7 飞行器位置与速度(Vehicle Position and Velocity)102.7.1 stkPosVelCBF102.7.2 stkPosVelCBI102.7.3 stkEphemerisCBF102.7.4 stkEphemerisCBI112.7.5 stkSetEphemerisCBF112.7.6 stkSetEphemerisCBI112.7.7 stkLoadEphemeris112.7.8 stkSaveEphemerisCBF122.7.9 stkSaveEphemerisCBI122.7.10 stkSaveDynState122.7.11 stkDynState122.8 飞行器姿态(Vehicle Attitude)122.8.1 stkAttitudeCBF122.8.2 stkAttitudeCBI132.8.3 stkSetAttitudeCBF132.8.4 stkSetAttitudeCBI132.8.5 stkLoadAttitude142.8.6 stkSaveAttitudeCBF142.8.7 stkSaveAttitudeCBI142.9 基本飞行器姿态类型(Basic Vehicle Attitude Types)142.9.1 stkSetAttBasic142.9.2 stkSetAttSpinSun152.9.3 stkSetAttSpinNadir152.9.4 stkSetAttYawNadir152.9.5 stkSetAttSpinning162.9.6 stkSetAttFixed162.9.7 stkAttOffset172.10 飞机,车辆与船舰属性(Aircraft, GroundVehicle and Ship Propagators)172.10.1 stkSetWaypoints172.10.2 stkLoadWaypoints182.10.3 stkSetGreatArcStart182.11 导弹运动属性(Missile Propagators)182.11.1 stkSetPropBallistic182.12 设备与目标(Facilities and Targets)182.12.1 stkPosVelCBF182.12.3 stkSetFacPosCBF182.12.3 stkSetFacPosLLA192.13 区域目标(Area Targets)192.13.1 Area Target boundary192.14 STK工具(STK Tools)192.14.1 stkAccess192.14.2 stkReport192.14.3 stkAccReport202.14.4 stkFindData212.15 连接命令(Connect Commands)212.15.1 stkOpen212.15.2 stkClose212.15.3 stkExec212.15.4 stkConnect22三、aeroToolbox函数详细介绍223.1 坐标系中的历元与数据函数Coordinate System Epoch and Date functions)223.1.1 atbGetEpoch223.1.2 atbSetEpoch223.1.3 atbDateToEpochSec233.1.4 atbEpochSecToDate233.2 坐标系转换(Coordinate Conversions)243.2.1 atbCbfToCbi243.2.2 atbCbfToCbiMtx243.2.3 atbCbfToLhMtx243.2.4 atbCbfToLla243.2.5 atbCbfToLlr253.2.6 atbCbfToVvlhMtx253.2.7 atbCbiToCbf253.2.8 atbCbiToCbi263.2.9 atbCbiToCbiMtx263.2.10 atbLlaToCbf263.2.11 atbLlrToCbf273.2.12 atbCbCoordinates273.2.13 atbCoordXForm273.2.14 atbCoordXFormMtx283.3 转动与四元数(Rotations and Quaternions)283.3.1 atbAlignVecQuat283.3.2 atbEulerToMtx283.3.3 atbEulerToQuat293.3.4 atbMinRotQuat293.3.5 atbMtxToEuler293.3.6 atbMtxToQuat293.3.7 atbMtxToYpr303.3.8 atbQuatToMtx303.3.9 atbQuatXquat303.3.10 atbYprToMtx303.3.11 atbYprToQuat313.3.12 atbInterpQuat313.4 中心对象操作与程序(Central Body Operations and Routines)313.4.1 atbCbEphemeris313.4.2 atbCbGetTangent313.4.3 atbCbGravParam323.4.4 atbCbGrazeAlt323.4.5 atbCbGrazeAngle323.4.6 atbCbIntersect333.4.7 atbCbLclRadCen333.4.8 atbCbLclRadDet333.4.9 atbCbSurfDistCen343.4.10 atbCbSurfDistDet343.4.11 atbCbSurfNormCen343.4.12 atbCbSurfNormDet343.5 指向,星历与姿态文件(Waypoint, Ephemeris and Attitude Files)353.5.1 atbReadAttitudeCBF353.5.2 atbReadAttitudeCBI353.5.3 atbWriteAttitudeCBF353.5.4 atbWriteAttitudeCBI353.5.5 atbReadEphemerisCBF363.5.6 atbReadEphemerisCBI363.5.7 atbWriteEphemerisCBF363.5.8 atbWriteEphemerisCBI363.5.9 atbWriteWaypointFile363.6 位置与速度函数(Position and Velocity Functions)373.6.1 atbGeometry373.6.2 atbGenGreatArc393.6.3 atbCreateDynStateCBF393.6.4 atbCreateDynStateCBI393.6.5 atbLhQuatCen403.6.6 atbLhQuatCBFDet403.6.7 atbFlatten413.7 轨道要素转换(Orbit Element Set Conversions)413.7.1 atbOrbCartToDel413.7.2 atbOrbCartToEqui413.7.3 atbOrbCartToMod423.7.4 atbOrbCartToSphere423.7.5 atbOrbCartToMixedSphere433.7.6 atbOrbDelToCart433.7.7 atbOrbEquiToCart433.7.8 atbOrbModToCart433.7.9 atbOrbSphereToCart433.7.10 atbOrbMixedSphereToCart433.8 轨道根数分量的转换(Orbit Element Parameter Conversions)433.8.1 atbOrbEccToTrue433.8.2 atbOrbTrueToEcc443.8.3 atbOrbMeanToTrue443.8.4 atbOrbTrueToMean443.8.5 atbOrbLanToRaan443.8.6 atbOrbRaanToLan443.8.7 atbOrbPeriRadToPeriod443.8.8 atbOrbPeriodToPeriRad453.8.9 atbOrbPeriRadToSMajAxis453.8.10 atbOrbSMajAxisToPeriRad453.8.11 atbOrbTPANToTrue453.8.12 atbOrbTrueToTPAN453.8.13 atbOrbTPPToTrue463.8.14 atbOrbTrueToTPP463.9 DTED操作(DTED operations)463.9.1 atbCbListDtedTypes463.9.2 atbCbListDted463.9.3 atbCbAddDtedSource473.9.4 atbCbDtedSourceUI473.9.5 atbLoadNimaDted473.9.6 atbCbRemDtedSource473.9.7 atbCbGetDtedSourceForPos473.9.8 atbGetDtedPatch483.9.9 atbClearDtedPatch483.9.10 atbAllDtedPatches483.9.11 atbDtedPatchInfo483.9.12 atbDtedElev483.9.13 atbDtedPatchElev493.9.14 atbAzElMask493.9.15 atbDtedRes493.9.16 atbDtedLOSExist493.10 运动属性(Propagators)503.10.1 atbLambertFixedTime503.10.2 atbLambertMinEnergy503.10.3 atbLambertMinEccen503.10.4 atbKeplerProp503.10.5 atbJ2Prop513.10.6 atbJ4Prop513.10.7 atbLaunchProp523.10.8 atbMissilePropDataFixedTime523.10.9 atbMissilePropDataFixedAlt533.10.10 atbMissilePropDataFixedDelta533.10.11 atbMissilePropDataMinEnergy533.10.12 atbTLERead533.10.13 atbTLEGetAll543.10.14 atbTLEDelete543.10.15 atbTLEProp543.10.16 atbTLEEpoch543.10.17 atbTLEInfo543.11 导航精度(Navigation Accuracy)553.11.1 atbComputeDOP553.12 地图数据(Map Data)563.12.1 atbMapDetails563.12.2 atbPlotMapDetails563.13 覆盖网格(Coverage Grids)563.13.1 atbGetPolyHandle563.13.2 atbInsidePoly563.13.3 atbClearPolyHandle57四、stkExec使用总结574.1 场景动画控制574.1.1 控制按钮57五、示例574.1 卫星编队之构型设计574.2 使用心得58一、Matlab/Simulink、STK联合仿真的优势STK/MATLAB,SIMULINK STK与Matlab联合实现可视化仿真集成,该方案可以适用于航空航天、航海、作战模拟、电子对抗、卫星导航定位、遥感遥测、卫星通信等各个可视化仿真集成案例之中。STK/MATLAB接口为STK和MATLAB提供了双向通讯功能,在MATLAB工作区通过Connect模块以TCP/IP协议打开STK端口。 利用超过150个MATLAB命令增强STK的轨道、弹道、轨迹的分析能力,MexConnect还提供在MATLAB命令行直接使用任意 STK/Connect 命令的功能。MexConnect工具可以建立各种不同级别的STK对象,进行操作并生成报告。所有STK的数据,包括动态位置、速度和姿态数据,可以返 回到MATLAB工作空间,用于数学分析。宇航工具箱让MATLAB用户可以输出多重坐标系,以及符合STK格式的星历和姿态文件用于VO模块的三维可视 化。另外此工具还可以使用STK附加模块的功能如STK/COMM(通信),STK/Coverage (覆盖)和STK/Radar(雷达)。表1 STK模块基本模块 基本版专业版三维显示高级三维显示Satellite Tool Kit(STK)STK/Professioal(STKPRO)STK/Visualization Option(STK/VO)STK/Advanced VO分析模块 轨道机动链路分析通信分析接近分析覆盖分析拦截飞行工具导弹飞行工具精确定轨雷达分析空间环境STKAstrogatorSTKChainsSTKCommSTKConjunction Analysis ToolsSTKCoverageSTKInterceptor Flight Tool(IFT)STKMissile Flight Tool(MFT)STKPrecision Orbit DeterminationSystem(PODS)STKRadarSTKSpace Environment综合数据 高精度数字地图高分辨率地球影像雷达高级环境全球三维地形STKHigh Resolution MapsSTKVO Earth ImagerySTKRadar Advanced Environment(RAE)STKTerrain扩展与接口 连接模块网络实时播放MATlLAB接口分布式仿真地理信息接口程序开发库STKConnect and STKServerSTKWebCastSTKMATLAB InterfaceSTKDistributed Interactive Simulation(DIS)STKGeographic InformationSystems(GIS)STKProgrammer's Library(PL)二、mexConnect函数详细介绍2.1 STK服务器命令(STK Server Commands)2.1.1 stkDefaultConID 作用:返回STK的默认标识2.1.2 stkDefaultHost作用:返回STK的默认地址2.1.3 stkSetDefaultHost作用:设置STK的新地址用法:stkSetDefaultHost('host:port')2.2 应用命令(Application Commands)2.2.1 stkAutoSave作用:自动保存STK用法:stkAutoSave('onOff','directory', period) stkAutoSave('onOff')说明:onOff - 'on' or 'off' directory - string pathname of autosave directory(一连串路径名的自动存储目录) period - seconds between saves2.2.2 stkHomeDir作用:返回STK的安装路径用法:dir = stkHomeDir2.2.3 stkCurrentDir作用:返回STK的当前路径用法:dir = stkCurrentDir2.2.4 stkSetCurrentDir作用:设置STK的当前路径用法:stkSetCurrentDir('directory')2.2.5 stkObjNames作用:返回STK中对象的名字用法:objNames = stkObjNames objNames = stkObjNames(classCell)说明:classCell - optional cell array of STK class names. objNames - cell array of STK object names 2.2.6 stkTimerStart作用:启动计时器用法:stkTimerStart2.2.7 stkTimer作用:返回计时器时间用法:split, total = stkTimer说明:split - elapsed time since last stkTimer command total - elapsed time since last stkTimerStart command2.3 普通对象命令(Generic Object Commands)2.3.1 stkCentralBody作用:返回坐标系的中心体用法:centBody = stkCentralBody('objPath')说明:objPath - String name of object obtained from stkObjNames. If ommitted, the scenario central body is returned.(从stkObjNames获得对象 的字符串名称。如果省略,返回场景的中央机构 ) centBody - String name of object coordinate system central body(对象的坐标系统 的中央机构的字符串名称 ).备注:更多内容参见stkObjNames、aeroToolbox。2.3.2 stkLoadObj作用:导入对象文件用法:stkLoadObj('parentPath', 'class', 'fileName') stkLoadObj('scenarioFileName')说明:parentPath - Valid path(有效路径), may be obtained from stkObjNames. class - Valid class name(有效类名). Consult(查询) STK documentation (文件) for alist of valid classes(有效地类类表). Names are case-sensitive(区分大小写的). fileName - File path of object file (对象文件的文件路径)2.3.3 stkSaveObj作用:将对象保存用法:stkSaveObj('objPath', 'dirName') stkSaveObj('objPath')说明:objPath - Valid path, may be obtained from stkObjNames. dirName - Directory path of object file. When omitted, the default directory is used.(如果省略,则使用默认目录 )2.3.4 stkNewObj 作用:创建一个新对象用法:stkNewObj('parentPath', 'class', 'name')说明:parentPath- Valid path, may be obtained from stkObjNames. class- Valid class name. Consult STK documentation for a list of valid classes. Names are case-sensitive. name - Name of new object备注:创建场景时,语法为stkNewObj('Scenario',' ','Scenario1')2.3.5 stkUnload作用:卸载对象用法:stkUnload('objPath')说明:objPath- Valid path, may be obtained from stkObjNames.2.3.6 stkUnloadChildren作用:卸载对象的所有子对象用法:stkUnloadChildren ('objPath')说明:objPath- Valid path, may be obtained from stkObjNames.2.3.7 stkRename作用:将对象重命名用法:stkRename('objPath', 'newName')说明:objPath- Valid path, may be obtained from stkObjNames. newName - New instance name.2.3.8 stkTimePeriod作用:获取对象起止时间用法:timePeriod = stkTimePeriod('dateFormat') timePeriod = stkTimePeriod('objPath', 'dateFormat')说明: objPath - Valid vehicle object path, defaults to scenario path.timePeriod - Structure array with start and stop fields. Each field contains a string date value.dateFormat - Valid date format. Options are: EPOCHSEC EPOCHSECOND EPOCHMIN EPOCHMINUTE EPOCHHR EPOCHHOUR EPOCHDAY GMT ZULU GMTSYSTEM GREGLCL GREGORIANLOCAL GREGORIANLCL GREGUTC GREGORIANUTC GREGTAI GREGORIANTAI GREGTDT GREGORIANTDT GREGGPSTIME GREGGPS GREGORIANGPSTIME GPSTIME GPS JULDATE JULIANDATE JULLCL JULIANLOCAL JULIANLCL JULUTC JULIANUTC JUL4 JULIAN4 JULIAN4UTC JDATEOFF JDATEOFFSET JULDATEOFFSET JULEPHEMDATE JULIANEPHEMERISDATE JULIANEPHEM JULTAI JULIANTAI MISELAP MISSIONELAPSED MODJULDATE MODIFIEDJULIANDATE YYDDD YYDDD.DDD YYYYDDD YYYYDDD.HHMMSS YYYYMMDD YYYYMMDD.DDD YYYY/MM/DDTIME YYYY/MM/DD 备注:更对内容参见stkConvertDate、stkObjNames2.3.9 stkTimePeriodInSec作用:获取对象起止时间,以s为单位用法:start, stop = stkTimePeriodInSec(objPath) start, stop = stkTimePeriodInSec说明:objPath - valid object path, see stkObjNames. When not provided, the scenario time period is returned(如果不提供,场景一段时 间,则返回 ). start, stop - time in seconds2.3.10 stkValidObj作用:检查对象的有效性用法:result = stkValidObj('path')说明:path- object path name result - 1 if valid, 0 otherwise2.3.11 stkDescrip作用:获取对象的描述用法:description = stkDescrip('objPath', 'shortLong')说明:objPath- Valid path, may be obtained from stkObjNames. shortLong - Type of description to get, 'short' or 'long'.2.3.12 stkSetDescrip作用:设置对象的描述用法:stkSetDescrip('objPath', 'shortLong', 'description')说明:objPath- Valid path, may be obtained from stkObjNames. shortLong - Type of description to set, 'short' or 'long'. description - Description text(说明文本).2.4 场景命令(Scenario Commands)2.4.1 stkAnimTime作用:返回当前动画时间用法:time = stkAnimTime说明:time - current STK animation time (sec)(当前stk动画时间)2.4.2 stkEpoch作用:返回当前场景历元用法:epoch = stkEpoch('dateFormat')说明:dateFormat- Valid date format(有效的日期格式).epoch - string representation of scenario epoch(场景历元的字符串表示形式). 2.4.3 stkSetEpoch作用:设置场景历元用法:stkSetEpoch('epoch', 'dateFormat')说明:dateFormat- Valid date format.epoch - string representation of scenario epoch.2.4.4 stkSetEpochInSec作用:设置场景历元用法:stkSetEpochInSec(newEpoch)说明:newEpoch - number of seconds elapsed between current epoch and the desired epoch(当前历元和所需历元之间经历的秒数).2.4.5 stkSyncEpoch作用:aeroToolbox与STK场景有同样的历元用法:stkSyncEpoch备注:STK and aeroToolbox maintain separate scenario epochs. This function should be called anytime the STK epoch is changed through mexConnect or via the STK GUI.(STK和航空工具箱保持独立的场景历 元。 这个函数应该被调用任何时间更改通过mexConnect或通过STK GUI的 STK历元 )2.4.6 stkConvertDate作用:转换日期格式用法:newDate = stkConvertDate('date', 'format', 'newFormat')2.4.7 stkSetTimePeriod作用:设置场景或卫星的时间周期用法:stkSetTimePeriod('start', 'stop', 'dateFormat') stkSetTimePeriod('satpath', 'start', 'stop', 'dateFormat')说明:satpath - satellite path name, defaults to scenario(卫星的路径名,默认到场景 ) start, stop- string dates(字符串日期)2.4.8 stkSetTimePeriodInSec作用:设置场景的时间周期用法:stkTimePeriodInSec(start, stop)说明:start, stop - time in seconds2.4.9 stkScenFilePath作用:返回场景文件的路径用法:path = stkScenFilePath说明:path - current STK scenario directory(当前STK场景目录)2.4.10