-
Notifications
You must be signed in to change notification settings - Fork 15
/
compute_double_difference.m
79 lines (62 loc) · 2.3 KB
/
compute_double_difference.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
%% compute_double_difference.m
% Compute double-differenced GNSS observation
% Author: Taro Suzuki
clear; close all; clc;
addpath ../
datapath = "./data/static/";
%% Rover and base position
% Read position from text file
posrllh = readmatrix(datapath+"rover_position.txt");
posbllh = readmatrix(datapath+"base_position.txt");
posr = gt.Gpos(posrllh,"llh");
posb = gt.Gpos(posbllh,"llh");
%% Read RINEX observation/navigation file
obsr = gt.Gobs(datapath+"rover.obs");
obsb = gt.Gobs(datapath+"base.obs");
nav = gt.Gnav(datapath+"base.nav");
%% Mask observation
obsr.mask(obsr.L1.S<35);
%% Synchronize the satellites and time of the two observations
% Satellite and time of the two observations do not match
fprintf('Before commonObs\n');
fprintf('Rover: Nepoch=%d Nsat=%d dt=%.1f\n',obsr.n,obsr.nsat,obsr.dt);
fprintf('Base : Nepoch=%d Nsat=%d dt=%.1f\n',obsb.n,obsb.nsat,obsb.dt);
[obsr2,obsb2] = obsr.commonObs(obsb);
% Satellite and time of the two observations are the same
fprintf('After commonObs\n');
fprintf('Rover: Nepoch=%d Nsat=%d dt=%.1f\n',obsr2.n,obsr2.nsat,obsr2.dt);
fprintf('Base : Nepoch=%d Nsat=%d dt=%.1f\n',obsb2.n,obsb2.nsat,obsb2.dt);
%% Compute residuals (Compensate geometric distance)
satr = gt.Gsat(obsr2, nav); % Compute satellite position
satr.setRcvPos(posr); % Set receiver position
obsr2 = obsr2.residuals(satr); % Compute residuals
satb = gt.Gsat(obsb2, nav); % Compute satellite position
satb.setRcvPos(posb); % Set receiver position
obsb2 = obsb2.residuals(satb); % Compute residuals
%% Single difference (rover-base)
obsrb = obsr2-obsb2;
%% Double difference
% Reference satellite (higest elevation angle)
refsatidx = satb.referenceSat();
% Double difference
obsrb = obsrb.doubleDifference(refsatidx);
%% Plot double-differenced residuals
% DD pseudorange residuals
figure;
plot(obsrb.L1.resPdd);
grid on;
title("DD psedudorange residuals");
xlabel("Epochs");
ylabel("DD pseudorange residuals (m)");
legend(obsrb.satstr,"Location","eastoutside");
% DD carrier phase residuals
resLdd = obsrb.L1.resLdd./obsrb.L1.lam; % m->cycle
% Fractional part of DD carrier phase residuals
f_resLdd = (resLdd-round(resLdd)).*obsrb.L1.lam;
figure;
plot(f_resLdd);
grid on;
title("DD carrier phase residuals");
xlabel("Epochs");
ylabel("DD carrier phase residuals (m)");
legend(obsrb.satstr,"Location","eastoutside");