Files

82 lines
2.6 KiB
Matlab

function res = perform_access_analysis(satSim, queryTime, carrierFrequency)
sat = satSim.sat;
ue = satSim.ue;
ac = access(sat,ue);
[status,timeout] = accessStatus(ac);
statusIdx = find(status,1);
if isempty(statusIdx)
disp("Position estimation cannot be performed " + ...
"as there is no access between satellite and UE.")
return
end
delete(ac)
[~,el,r] = aer(ue,sat,queryTime);
res.distanceToSatellite = r;
res.elevationAngleToSatellite = el;
if nargin < 3
carrierFrequency = 2.4e9;
end
[fshift,~,dopplerInfo] = dopplershift( ...
sat,ue,queryTime,Frequency=carrierFrequency);
res.rangeRate = -1*dopplerInfo.RelativeVelocity;
[satPos,satVel] = states(sat,queryTime,CoordinateFrame="ecef");
res.satPos = satPos;
res.satVel = satVel;
res.fshift = fshift;
if ~isfinite(fshift)
res.satelliteVisible = false;
return;
end
res.satelliteVisible = true;
rng(0)
lightspeed = physconst("lightspeed");
frameDurInSeconds = 10e-3;
delayInSeconds = r/lightspeed;
nFrames = ceil(delayInSeconds/frameDurInSeconds) + 1;
carrier = nrCarrierConfig;
pdsch = nrPDSCHConfig;
pdsch.DMRS.DMRSAdditionalPosition = 2;
[txWaveform,waveformInfo] = ...
HelperNRNTNThroughput.generatePDSCHWaveform( ...
carrier,pdsch,struct,eye(pdsch.NumLayers),"double",carrier.SlotsPerFrame*nFrames);
refGridAllSlots = waveformInfo.ResourceGrid;
delayInSamples = delayInSeconds.*waveformInfo.SampleRate;
integDelaySamples = floor(delayInSamples);
fracDelaySamples = (delayInSamples - integDelaySamples);
staticDelay = dsp.Delay(Length=integDelaySamples);
variableFractionalDelay = dsp.VariableFractionalDelay( ...
InterpolationMethod="Farrow", ...
FarrowSmallDelayAction="Use off-centered kernel", ...
MaximumDelay=1);
delayedTx = staticDelay(txWaveform);
delayedTx = variableFractionalDelay(delayedTx,fracDelaySamples);
channel = p681LMSChannel;
channel.SampleRate = waveformInfo.SampleRate;
channel.CarrierFrequency = carrierFrequency;
channel.SatelliteDopplerShift = fshift;
channel.MobileSpeed = 0;
channel.ElevationAngle = el;
channel.RandomStream = "mt19937ar with seed";
rxWaveform = channel(delayedTx);
freqSearch = 0.999*fshift:sign(fshift):1.001*fshift;
[delayEstSamples,fshiftEst] = HelperNRNTNThroughput.jointTimeFreq( ...
carrier,rxWaveform,refGridAllSlots,freqSearch);
res.rangeEst = delayEstSamples*lightspeed/waveformInfo.SampleRate;
res.rangeRateEst = -1*fshiftEst*lightspeed/carrierFrequency;
end