STK一次性计算所有可见性access

在使用STK中,计算access的过程是,点击一颗星,选择计算对象,计算access。这样当星座中卫星数或地面站数量比较多时,要计算星座中所有卫星之间或与所有地面站之间的可见性时,需要点击的次数比较多,比较麻烦。

解决办法是,利用STK的Object Model,通过MATLAB编程扩展STK功能。主要部分的MATLAB代码如下:

    uiApplication = actxGetRunningServer('STK11.application');
    root = uiApplication.Personality2;
    scenario = root.CurrentScenario;
    
    %waitbar
    hWait = waitbar(0,'Please Wait~');
    
    %scenario start time
    startTime = scenario.StartTime;
    formatIn = 'dd mmm yyyy HH:MM:SS';
    startTimeNum = datenum(startTime,formatIn);
    
    
    % allChildren includes satellites and facilities
    allChildren = scenario.Children;
    
    allSatellites = allChildren.GetElements('eSatellite');
    allFacilities = allChildren.GetElements('eFacility');
    
    
    satNum = allSatellites.Count;
    for i=0:1:satNum-1
        % eg: sat0=allSatellites.Item(cast(0,'int32'));
        eval(['sat',num2str(i),'=allSatellites.Item(cast(i,''int32''));'])
    end
    
    facNum = allFacilities.Count;
    for i=0:1:facNum-1
        eval(['fac',num2str(i),'=allFacilities.Item(cast(i,''int32''));'])
    end
    
    % all access in Time(day month year...)
    allAccessIntervals=[];
    % all access in Seconds
    allAccessIntervalsSec=[];
    
    % only ISL
    if(var1==1)
        
        for from=0:1:satNum-1
            waitbar(from/satNum,hWait);
            for to=from+1:1:satNum-1
                eval(['fromSat=sat',num2str(from),';']);
                eval(['toSat=sat',num2str(to),';']);
                
                access = fromSat.GetAccessToObject(toSat);
                access.ComputeAccess;
                
                accessIntervals = access.ComputedAccessIntervalTimes;
                if(accessIntervals.Count~=0)
                    
                    computedIntervals = accessIntervals.ToArray(0, -1);
                    
                    temp=cell(accessIntervals.Count,2);
                    for i=1:1:accessIntervals.Count
                        temp{i,1}=from+1;
                        temp{i,2}=to+1;
                    end
                    allAccessIntervals = [allAccessIntervals;temp,computedIntervals];
                    
                end
                
            end
        end
    end

    % transfer Time(day month year time) to Seconds
    [rows,cols] = size( allAccessIntervals);
    for row=1:1:rows
        intervalStart =  allAccessIntervals{row,3};
        intervalEnd =  allAccessIntervals{row,4};
        
        %in day
        intervalStartNum = datenum(intervalStart,formatIn);
        intervalEndNum = datenum(intervalEnd,formatIn);
        
        %in sceconds
        intervalSatrtSec = (intervalStartNum-startTimeNum)*24*60*60;
        intervalEndSec = (intervalEndNum-startTimeNum)*24*60*60;
        
        allAccessIntervalsSec =    [allAccessIntervalsSec;allAccessIntervals{row,1},allAccessIntervals{row,2},intervalSatrtSec,intervalEndSec];
    end

 

其中,主要涉及到的代码

  1. 利用MATLAB代码得到卫星或地面站的集合,再两两计算access
  2. 得到的access集合中,时间格式需要转换一下使得后续的处理更加方便

这是和access有关的代码,其他方面需要通过MATLAB来扩展自定义STK功能的代码可以参考:

  1. http://help.agi.com/stkdevkit/11.0/index.html?page=source%2FstkObjects%2FObjModMatlabCodeSamples.htm
  2. http://help.agi.com/stkdevkit/Content/DocX/STKObjects~IAgStkObject.html

你可能感兴趣的:(STK)