-
Notifications
You must be signed in to change notification settings - Fork 0
/
kalman_filter_attitude_kinematics.m
119 lines (88 loc) · 3.38 KB
/
kalman_filter_attitude_kinematics.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
function kalman_filter_attitude_kinematics()
load sensorlog_20190923_151441.mat...
Orientation AngularVelocity
% load attitude_kinematics_synthetic_data1.mat...
% euler_angles_0 euler_angles_noisy euler_angles_true...
% omega_iee_noisy omega_iee_true...
% std_dev_gyro std_dev_mag time_pts
TT = synchronize(Orientation, AngularVelocity, 'regular', 'spline','TimeStep', seconds(0.01));
orientation = [TT.Z_Orientation*pi/180 TT.Y_Orientation*pi/180 TT.X_Orientation*pi/180]';
rate_gyros = [TT.Z_AngularVelocity TT.Y_AngularVelocity TT.X_AngularVelocity]';
time_pts = TT.Timestamp;
% dt = time_pts(2) - time_pts(1);
% orientation = euler_angles_noisy;
% rate_gyros = omega_iee_noisy;
var_rgy = 0.2932;
var_mag = 2.385*pi/180;
% var_rgy = std_dev_gyro^2;
% var_mag = std_dev_mag^2;
% changes based on problem
n_states = 3;
C = eye(n_states);
% only here if constant
R = var_mag*eye(3);
G = var_rgy*eye(3);
% initialize
psi0 = orientation(1, 1);
theta0 = orientation(2, 1);
phi0 = orientation(3, 1);
omega_aee_t = rate_gyros(:, 1);
x_hat = [psi0; theta0; phi0];
% x_hat = euler_angles_0;
P = R;
dt = 0.01;
% plotting
x_hat_rec = zeros(3, numel(time_pts));