1、1整理者:龚德仁2008 年 10 月 7 日I目 录一、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
2、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
3、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 stkTimePeri
4、od72.5.2 stkTimePeriodInSec72.5.3 stkSetTimePeriod72.6 卫星运动属性(Satellite Propagators) 8II2.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 stkEphemeri
5、sCBF102.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 stkSetAttitudeCBF
6、132.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 st
7、kAttOffset172.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.
8、12.3 stkSetFacPosLLA192.13 区域目标(Area Targets) 19III2.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 函数详细介绍
9、 .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 at
10、bCbfToVvlhMtx253.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 a
11、tbMinRotQuat293.3.5 atbMtxToEuler293.3.6 atbMtxToQuat293.3.7 atbMtxToYpr303.3.8 atbQuatToMtx303.3.9 atbQuatXquat303.3.10 atbYprToMtx303.3.11 atbYprToQuat31IV3.3.12 atbInterpQuat313.4 中心对象操作与程序(Central Body Operations and Routines) 313.4.1 atbCbEphemeris313.4.2 atbCbGetTangent313.4.3 atbCbGravParam32
12、3.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 at
13、bReadAttitudeCBI353.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.
14、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 atbOrbDe
15、lToCart433.7.7 atbOrbEquiToCart433.7.8 atbOrbModToCart433.7.9 atbOrbSphereToCart433.7.10 atbOrbMixedSphereToCart433.8 轨道根数分量的转换(Orbit Element Parameter Conversions) 43V3.8.1 atbOrbEccToTrue433.8.2 atbOrbTrueToEcc443.8.3 atbOrbMeanToTrue443.8.4 atbOrbTrueToMean443.8.5 atbOrbLanToRaan443.8.6 atbOrbRaa
16、nToLan443.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 atbCbListD
17、ted463.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 atbAzElMask4
18、93.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 atbMissilePropDataFixedAl
19、t533.10.10 atbMissilePropDataFixedDelta533.10.11 atbMissilePropDataMinEnergy533.10.12 atbTLERead53VI3.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 atbMapDetai
20、ls563.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 使用心得 581一、Matlab/Simulink、STK 联合仿真的优势STK/MATLAB,SIMULINK STK 与 Matlab 联合实现可视化仿真集成,该方案可以适用于航空航天、航
21、海、作战模拟、电子对抗、卫星导航定位、遥感遥测、卫星通信等各个可视化仿真集成案例之中。STK/MATLAB接口为 STK和 MATLAB提供了双向通讯功能,在 MATLAB工作区通过Connect模块以 TCP/IP协议打开 STK端口。 利用超过 150个 MATLAB命令增强 STK的轨道、弹道、轨迹的分析能力,MexConnect 还提供在 MATLAB命令行直接使用任意 STK/Connect 命令的功能。MexConnect 工具可以建立各种不同级别的 STK对象,进行操作并生成报告。所有 STK的数据,包括动态位置、速度和姿态数据,可以返 回到 MATLAB工作空间,用于数学分析。
22、宇航工具箱让 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分析模块 轨道机动链路分析通信分析接近分析覆盖分析拦截飞行工具导弹飞行工具精确定轨雷达分析空间环境ST
23、KAstrogatorSTKChainsSTKCommSTKConjunction Analysis ToolsSTKCoverageSTKInterceptor Flight Tool(IFT)STKMissile Flight Tool(MFT)STKPrecision Orbit DeterminationSystem(PODS)STKRadarSTKSpace Environment综合数据 高精度数字地图高分辨率地球影像雷达高级环境全球三维地形STKHigh Resolution MapsSTKVO Earth ImagerySTKRadar Advanced Environment
24、(RAE)STKTerrain扩展与接口 连接模块网络实时播放MATlLAB 接口分布式仿真地理信息接口程序开发库STKConnect and STKServerSTKWebCastSTKMATLAB InterfaceSTKDistributed Interactive Simulation(DIS)STKGeographic InformationSystems(GIS)STKProgrammers Library(PL)2二、mexConnect 函数详细介绍2.1 STK服务器命令(STK Server Commands)2.1.1 stkDefaultConID 作用:返回 STK
25、的默认标识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 offdirectory - string pathname of autosave directoryperiod -
26、 seconds between saves2.2.2 stkHomeDir作用:返回 STK 的安装路径用法:dir = stkHomeDir2.2.3 stkCurrentDir作用:返回 STK 的当前路径用法:dir = stkHomeDir2.2.4 stkSetCurrentDir作用:设置 STK 的当前路径用法:stkSetCurrentDir(directory)2.2.5 stkObjNames作用:返回 STK 中对象的名字用法:objNames = stkObjNamesobjNames = stkObjNames(classCell)说明:classCell - op
27、tional cell array of STK class names.objNames - cell array of STK object names 2.2.4 stkSetCurrentDir 32.2.6 stkTimerStart作用:启动计时器用法:stkTimerStart2.2.7 stkTimer作用:返回计时器时间用法:split, total = stkTimer说明:split - elapsed time since last stkTimer commandtotal - elapsed time since last stkTimerStart command
28、2.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.centBody - String name of object coordinate system central body.备注:更多内容参见 stkObjName
29、s、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 o
30、bject 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)说明:parentP
31、ath - Valid path, may be obtained from stkObjNames.class - Valid class name. Consult STK documentation for a list of valid classes. Names are case-sensitive.4name - Name of new object备注:创建场景时,语法为 stkNewObj(Scenario, ,Scenario1)2.3.5 stkUnload作用:卸载对象用法:stkUnload(objPath)说明:objPath - Valid path, may b
32、e 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 st
33、kTimePeriod作用:获取对象起止时间用法: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 form
34、at. Options are:EPOCHSEC EPOCHSECONDEPOCHMIN EPOCHMINUTEEPOCHHR EPOCHHOUREPOCHDAYGMT ZULU GMTSYSTEMGREGLCL GREGORIANLOCAL GREGORIANLCLGREGUTC GREGORIANUTCGREGTAI GREGORIANTAIGREGTDT GREGORIANTDTGREGGPSTIME GREGGPS GREGORIANGPSTIMEGPSTIME GPSJULDATE JULIANDATEJULLCL JULIANLOCAL JULIANLCLJULUTC JULIAN
35、UTCJUL4 JULIAN4JULIAN4UTC5JDATEOFF JDATEOFFSET JULDATEOFFSETJULEPHEMDATE JULIANEPHEMERISDATEJULIANEPHEMJULTAI JULIANTAIMISELAP MISSIONELAPSEDMODJULDATE MODIFIEDJULIANDATEYYDDDYYDDD.DDDYYYYDDDYYYYDDD.HHMMSSYYYYMMDDYYYYMMDD.DDDYYYY/MM/DDTIMEYYYY/MM/DD备注:更对内容参见 stkConvertDate、stkObjNames2.3.9 stkTimePe
36、riodInSec作用:获取对象起止时间,以 s 为单位用法:start, stop = stkTimePeriodInSec(objPath)start, stop = stkTimePeriodInSec说明:objPath - valid object path, see stkObjNames. Whennot provided, the scenario time period is returned.start, stop - time in seconds2.3.10 stkValidObj作用:检查对象的有效性用法:result = stkValidObj(path)说明:pa
37、th - object path nameresult - 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, short
38、Long, description)说明:objPath - Valid path, may be obtained from stkObjNames.shortLong - Type of description to set, short or long.description - Description text.62.4 场景命令(Scenario Commands)2.4.1 stkAnimTime作用:返回当前动画时间用法:time = stkAnimTime说明:time - current STK animation time (sec)2.4.2 stkEpoch作用:返回当
39、前场景历元用法: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作用:设置场景历元用法:stkSet
40、EpochInSec(newEpoch)说明:newEpoch - number of seconds elapsed between current epochand 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 changedthrough mexConn
41、ect or via the STK GUI.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 scenariostart, stop
42、 - string dates72.4.8 stkSetTimePeriodInSec作用:设置场景的时间周期用法:stkTimePeriodInSec(start, stop)说明:start, stop - time in seconds2.4.9 stkScenFilePath作用:返回场景文件的路径用法:path = stkScenFilePath说明:path - current STK scenario directory2.4.10 stkValidScen作用:检查可用的场景用法:result = stkValidScen说明:result - 1 if valid, 0 ot
43、herwise2.5 基本飞行器数据(Basic Vehicle Data)2.5.1 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
44、 string date value.2.5.2 stkTimePeriodInSec作用:获取对象的时间周期用法:start, stop = stkTimePeriodInSec(objPath)start, stop = stkTimePeriodInSec说明:objPath - valid object path, see stkObjNames. Whennot provided, the scenario time period is returned.start, stop - time in seconds2.5.3 stkSetTimePeriod作用:设置场景或对象的时间周
45、期用法:stkSetTimePeriod(start, stop, dateFormat)stkSetTimePeriod(satpath, start, stop, dateFormat)说明:satpath - satellite path name, defaults to scenariostart, stop - string dates82.6 卫星运动属性(Satellite Propagators)2.6.1 stkSetPropCart作用:设置笛卡尔坐标系下卫星运动的参数用法:stkSetPropCart(objPath, propagator, coordSystem,
46、.tStart, tStop, dt, orbitEpoch, pos, vel, coordEpoch)说明:objPath - Valid path, may be obtained from stkObjNames.propagator - TwoBody, J2Perturbation, J4Perturbation, HPOP or PODSThis parameter is case sensitive!coordSystem - string name of coordinate system, valid choices are:Fixed, J2000, MeanOfDate
47、, MeanOfEpoch, TrueOfDate, TrueOfEpoch, B1950,TEMEOfDate, TEMEOfEpoch, AlignmentAtEpoch.This parameter is case sensitive!tStart, tStop - times in epoch seconds.dt - time step in seconds.orbitEpoch - reference time of orbit data, in scenario epoch secondspos - 3x1 vector of positions at reference tim
48、e, metersvel - 3x1 vector of velocity at reference time, meters/seccoordEpoch - coordinate system epoch, required by all .OfEpochcoordinate systems.2.6.2 stkSetPropClassical作用:设置经典轨道根数描述下卫星运动的参数用法:stkSetPropClassical(objPath, propagator, coordSystem, .tStart, tStop, dt, orbitEpoch, semimajorAxis, ec
49、centricity,.inclination, argOfPerigree, RAAN, meanAnomaly, coordEpoch)说明:objPath - Valid path, may be obtained from stkObjNames.propagator - TwoBody, J2Perturbation, J4Perturbation, HPOP or PODSThis parameter is case sensitive!coordSystem - string name of coordinate system, valid choices are:Fixed, J2000, MeanOfDate, MeanOfEpoch, TrueOfDate, TrueOf