-
Notifications
You must be signed in to change notification settings - Fork 11
/
gps.m
54 lines (39 loc) · 1.15 KB
/
gps.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
% Compute the output of gps sensor
function y = gps(uu, P)
% relabel the inputs
NN = 0;
% Va = uu(1+NN);
% alpha = uu(2+NN);
% wn = uu(3+NN);
% wd = uu(4+NN);
NN = NN + 4;
pn = uu(1+NN);
pd = uu(2+NN);
u = uu(3+NN);
w = uu(4+NN);
theta = uu(5+NN);
% q = uu(6+NN);
NN = NN + 6;
t = uu(1+NN);
% persistent variables that define random walk of GPS sensors
persistent eta_n;
persistent eta_h;
if t==0, % initialize persistent variables
eta_n = 0;
eta_h = 0;
else % propagate persistent variables
eta_n = exp(-P.beta_gps*P.Ts_gps)*eta_n + P.sigma_n_gps*randn;
eta_h = exp(-P.beta_gps*P.Ts_gps)*eta_h + P.sigma_h_gps*randn;
end
% construct North, East, and altitude GPS measurements
y_gps_n = pn + eta_n;
y_gps_h = -pd + eta_h;
% construct groundspeed and course measurements
y_gps_Vg = u*cos(theta)+w*sin(theta) + P.sigma_Vg_gps*randn;
% construct total output
y = [...
y_gps_n;...
y_gps_h;...
y_gps_Vg;...
];
end