目录
一、总体考虑
基于StarLink的快速发射部署现状,采用COM方法可以有效固化场景,实现对分析对象的快速更新。一方面通过获取Celestrak网站上StarLink的TLE数据,通过读取分析目标NORAD编号文件,实现对不同版本(V1.0、V1.5)和不同轨道倾角(53.2°、70°、97.6°)的不同类型StarLink卫星性能指标分析。最终实现单星功率、推进剂消耗,系统级的对地覆盖、通信容量等指标分析。
二、仿真环境构建
首先需要在Matlab软件中打开STK软件,并建立二者连接。
% 建立STK与Matlab的连接
stkInit; % 建立连接
remMachine = stkDefaultHost;
stkClose('all');
conid = stkOpen(stkDefaultHost); % 得到连接句柄(用于发送指令)
% 判断场景是否存在
scen_open = stkValidScen;
if scen_open == 1
rtn = questdlg('Close the current scenario?')
if ~strcmp(rtn,'Yes')
stkClose(conid);
return;
else
stkUnload('/*');
end
end
在STK中建立场景,设置场景的名称、起止时间及单位……
% 新建场景
disp('创建一个场景');
stkNewObj('/','Scenario','StarLink');
% 设定场景时间
disp('设定场景时间');
strBegTime = '25 Jan 2023 00:00:00.000';
strEndTime = '31 Jan 2023 00:00:00.000';
stkSetTimePeriod(strBegTime,strEndTime,'GREGLCL');%北京本地时,协调世界时为GREGUTC
Time_Step=120;%STK 仿真时间步长
% 使aeroToolbox中函数的历元时间与场景一致
stkSetEpoch(strBegTime,'GREGLCL');
stkSyncEpoch;
% 设定场景动画开始时间
strQuteBegTime = ['"' strBegTime '"'];
rtn = stkConnect(conid,'Animate','Scenario/StarLink','SetValues "25 Jan 2023 00:00:00.000" 600 0.1');
% 设定动画时间回到起始点
rtn = stkConnect(conid,'Animate','Scenario/StarLink','Reset');
进行插入卫星的准备工作。
% 新建种子卫星
disp('创建种子卫星');
vehNames = atbTLERead('E:\Starlink\StarLinkTle.txt', '');% 此为读取TLE数据文件
Sat_Number=length(vehNames);%卫星数量
% 读取存储有目标卫星NORAD编号的xlsx文件
strSeedSat = xlsread('E:\Starlink\AnalysisGoal.xlsx');
预处理,读取卫星根数。
% 输入卫星轨道
str3TLEFilePath = 'E:\Starlink\StarLinkTle.txt';%读取文件
nStarCount = size(strSeedSat,1);%卫星数量
% 读入3TLE根数
fidin = fopen(str3TLEFilePath);
nReadNum = 0;% 生成卫星计数
vecTLE = [];
Sat_Name={};
matReadNum = [];
while ~feof(fidin) && nStarCount>nReadNum
% 读取根数
strNameLine = fgetl(fidin);
% 避免空格
if isempty(strNameLine)
continue;
end
% 处理名字
strNameLine = regexp(strNameLine,' ','split');
strName = strNameLine(1);
strTLELine1 = fgetl(fidin);
strTLELine2 = fgetl(fidin);
% 获取NoradID
vecTLELine2 = regexp(strTLELine2,' ','split');
vecTLELine2(strcmp(vecTLELine2,''))=[];
if find(strSeedSat==str2double(vecTLELine2(2)))
% 增加计数
nReadNum = nReadNum+1;
% 获取卫星名称
% nReadNum为循环数
Sat_Name(nReadNum)={strNameLine};
%tmpTLE.Name = [char(strName) cell2mat(Sat_Name{1,nReadNum}) '-' char(vecTLELine2(2))];
tmpTLE.Name = [cell2mat(Sat_Name{1,nReadNum}) '-' char(vecTLELine2(2))];
tmpTLE.Code = str2double(vecTLELine2(2));
tmpTLE.Line1 = strTLELine1;
tmpTLE.Line2 = strTLELine2;
vecTLE = [vecTLE,tmpTLE];
matReadNum = [matReadNum,str2double(vecTLELine2(2))];
end
end
uiapp = actxGetRunningServer('STK11.application');
root = uiapp.Personality2;
checkempty = root.Children.Count;
sc = root.CurrentScenario;
SatData={};%建立存储卫星数据的元胞数组
开始批量创建卫星。对于目标卫星的参数修改,可以用“对象名.get”语句查看对象的属性,可以用“对象名.invoke”查看对象可以使用的操作方法,例如"Sat2D.get"、"Sat2D.Attributes.get",就可以在循环中添加相应的代码对卫星的各项参数进行修改,在后期添加传感器、天线时可照此法操作。
for i = 1:size(vecTLE,2)
tmpStarTLE = vecTLE(i);
strProSat = tmpStarTLE.Name;
fprintf('Create a new satellite %s\n',char(strProSat));
tmpSat = root.CurrentScenario.Children.New('eSatellite',char(strProSat));
strCommendTLE = ['SetState */Satellite/' char(strProSat) ' TLE "' char(tmpStarTLE.Line1) '" "' char(tmpStarTLE.Line2) '"'];
root.ExecuteCommand(strCommendTLE);
propagator = tmpSat.Propagator;
% 二维显示参数修改,同步增加至Main
Sat2D = tmpSat.Graphics;
Sat2D.Attributes.Inherit = 0;
Sat2D.Attributes.IsVisible = 1;
Sat2D.Attributes.Color = 16777215;
Sat2D.Attributes.MarkerStyle = 'E:\Software\STK 11\STKData\Pixmaps\MarkersWin\m010Satellite.bmp';
Sat2D.Attributes.LabelVisible = 0;
Sat2D.Attributes.IsGroundTrackVisible = 0;
Sat2D.Attributes.IsGroundMarkerVisible = 1;
Sat2D.Attributes.IsOrbitVisible = 0;
Sat2D.Attributes.IsOrbitMarkerVisible = 0;
propagator.StartTime = strBegTime;
propagator.StopTime = strEndTime;
propagator.Step = Time_Step;
propagator.Propagate;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 读取数据
% 保存为元胞数组
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
TemSatData = tmpSat.DataProviders.Item('Cartesian Position').Group.Item('Fixed').Exec(sc.StartTime,sc.StopTime,Time_Step);
SatData{i,1} = cell2mat(TemSatData.DataSets.GetDataSetByName('Time').GetValues);%仿真时间,sec
SatData{i,2} = cell2mat(TemSatData.DataSets.GetDataSetByName('x').GetValues);%卫星在笛卡尔坐标系x坐标,km
SatData{i,3} = cell2mat(TemSatData.DataSets.GetDataSetByName('y').GetValues);%卫星在笛卡尔坐标系y坐标,km
SatData{i,4} = cell2mat(TemSatData.DataSets.GetDataSetByName('z').GetValues);%卫星在笛卡尔坐标系z坐标,km
TemSatData = tmpSat.DataProviders.Item('Cartesian Velocity').Group.Item('Fixed').Exec(sc.StartTime,sc.StopTime,Time_Step);
SatData{i,5} = cell2mat(TemSatData.DataSets.GetDataSetByName('x').GetValues);%卫星在笛卡尔坐标系x方向速度,km/sec
SatData{i,6} = cell2mat(TemSatData.DataSets.GetDataSetByName('y').GetValues);%卫星在笛卡尔坐标系y方向速度,km/sec
SatData{i,7} = cell2mat(TemSatData.DataSets.GetDataSetByName('z').GetValues);%卫星在笛卡尔坐标系z方向速度,km/sec
TemSatData = tmpSat.DataProviders.Item('Sun Vector').Group.Item('Fixed').Exec(sc.StartTime,sc.StopTime,Time_Step);
SatData{i,8} = cell2mat(TemSatData.DataSets.GetDataSetByName('x').GetValues);%太阳在笛卡尔坐标系x坐标,km
SatData{i,9} = cell2mat(TemSatData.DataSets.GetDataSetByName('y').GetValues);%太阳在笛卡尔坐标系x坐标,km
SatData{i,10} = cell2mat(TemSatData.DataSets.GetDataSetByName('z').GetValues);%太阳在笛卡尔坐标系x坐标,km
TemSatData = tmpSat.DataProviders.Item('Solar Intensity').Exec(sc.StartTime,sc.StopTime,Time_Step);
SatData{i,11} = cell2mat(TemSatData.DataSets.GetDataSetByName('Intensity').GetValues);
end