82 lines
3.0 KiB
Mathematica
82 lines
3.0 KiB
Mathematica
|
|
%function InitCodePhase=GenerateSatellitesPseudoranges(InitObsTime,DurationTime,LLH,PRNlist,ElevationMask)
|
||
|
|
clear all
|
||
|
|
addpath ..\include % The software receiver functions
|
||
|
|
addpath ..\geoFunctions % Position calculation related functions
|
||
|
|
addpath ..
|
||
|
|
|
||
|
|
load trackingResults_HN.mat
|
||
|
|
%navSolutions = postNavigation(trackResults, settings);
|
||
|
|
%pseudorange=navSolutions.channel.rawP;
|
||
|
|
|
||
|
|
%Gen ephemeris message for every satellite
|
||
|
|
[subFrameStart, activeChnList] = findPreambles(trackResults, settings);
|
||
|
|
|
||
|
|
LLH=[21.004498873852768 105.8435979060256 50.956094086170197];
|
||
|
|
PRNlist=[3 6 13 16 19 23];
|
||
|
|
ElevationMask=10;
|
||
|
|
for channelNr = activeChnList
|
||
|
|
|
||
|
|
%=== Convert tracking output to navigation bits =======================
|
||
|
|
|
||
|
|
%--- Copy 5 sub-frames long record from tracking output ---------------
|
||
|
|
navBitsSamples = trackResults(channelNr).I_P(subFrameStart(channelNr) - 20 : ...
|
||
|
|
subFrameStart(channelNr) + (1500 * 20) -1)';
|
||
|
|
|
||
|
|
%--- Group every 20 vales of bits into columns ------------------------
|
||
|
|
navBitsSamples = reshape(navBitsSamples, ...
|
||
|
|
20, (size(navBitsSamples, 1) / 20));
|
||
|
|
|
||
|
|
%--- Sum all samples in the bits to get the best estimate -------------
|
||
|
|
navBits = sum(navBitsSamples);
|
||
|
|
|
||
|
|
%--- Now threshold and make 1 and 0 -----------------------------------
|
||
|
|
% The expression (navBits > 0) returns an array with elements set to 1
|
||
|
|
% if the condition is met and set to 0 if it is not met.
|
||
|
|
navBits = (navBits > 0);
|
||
|
|
|
||
|
|
%--- Convert from decimal to binary -----------------------------------
|
||
|
|
% The function ephemeris expects input in binary form. In Matlab it is
|
||
|
|
% a string array containing only "0" and "1" characters.
|
||
|
|
navBitsBin = dec2bin(navBits);
|
||
|
|
|
||
|
|
%=== Decode ephemerides and TOW of the first sub-frame ================
|
||
|
|
[eph(trackResults(channelNr).PRN), TOW] = ...
|
||
|
|
ephemeris(navBitsBin(2:1501)', navBitsBin(1));
|
||
|
|
end
|
||
|
|
[tmpx tmpy tmpz]=llh2xyz(LLH(1),LLH(2),LLH(3));
|
||
|
|
userxyz=[tmpx tmpy tmpz];
|
||
|
|
InitObsTime=TOW;
|
||
|
|
DurationTime=360;
|
||
|
|
obsTime=[InitObsTime:0.001:InitObsTime+DurationTime+1];
|
||
|
|
speedOfLight=299792458;
|
||
|
|
lengthOfChips=speedOfLight/1.023e6;
|
||
|
|
idxTTime=1;
|
||
|
|
hwb=waitbar(0,'Please wait');
|
||
|
|
distByChips=zeros(length(obsTime),length(PRNlist));
|
||
|
|
|
||
|
|
for transmitTime=obsTime
|
||
|
|
if rem(idxTTime,10)==0
|
||
|
|
waitbar((transmitTime-obsTime(1))/(obsTime(end)-obsTime(1)),hwb);
|
||
|
|
end;
|
||
|
|
validPRN=[];
|
||
|
|
for PRN=PRNlist;
|
||
|
|
if PRN==24
|
||
|
|
continue;
|
||
|
|
end;
|
||
|
|
[satPosition, satClkCorr] = satpos(transmitTime, ...
|
||
|
|
PRN, ...
|
||
|
|
eph);
|
||
|
|
|
||
|
|
[az, el, tmpDist] = topocent(userxyz', satPosition - userxyz');
|
||
|
|
dist=tmpDist-satClkCorr*speedOfLight;
|
||
|
|
distByChips(idxTTime,PRN)=dist/lengthOfChips;
|
||
|
|
if (el>=ElevationMask)&& (el<=90)
|
||
|
|
validPRN=[validPRN PRN];
|
||
|
|
end;
|
||
|
|
end;
|
||
|
|
idxTTime=idxTTime+1;
|
||
|
|
end;
|
||
|
|
InitCodePhase=distByChips(:,validPRN);
|
||
|
|
close(hwb);
|
||
|
|
save InitCodePhase InitCodePhase
|