-
Notifications
You must be signed in to change notification settings - Fork 2
/
velocity_divergence_vive.m
78 lines (56 loc) · 1.74 KB
/
velocity_divergence_vive.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
%% Velocity Divergence Analysis
% Show the velocity divergence of a static rover.
D = dlmread('ak2_vive_driving_normal_highbay_20171206.csv', ',');
%D = dlmread('ak2_vive_driving_highcentered_highbay_20171206.csv', ',');
%D = dlmread('ak2_vive_driving_stuck_jiggling_highbay_20171206.csv', ',');
t = D(:,1) - D(1,1);
v_wheel = D(:,2:4);
v_vive = D(:,5:7);
v_wheel_mag = zeros(size(D,1), 1);
v_vive_mag = zeros(size(D,1), 1);
for i_D = 1:size(D,1)
v_wheel_mag(i_D, 1) = norm(v_wheel(i_D,:));
v_vive_mag(i_D, 1) = norm(v_vive(i_D,:));
end
%% Divergence Analysis
v_err = v_vive - v_wheel;
v_mag_err = abs(v_vive_mag - v_wheel_mag);
mu_v_err = mean(v_err);
v_err_centered = v_err;
v_err_centered(:,1) = v_err_centered(:,1) - mu_v_err(1,1);
v_err_centered(:,2) = v_err_centered(:,2) - mu_v_err(1,2);
v_err_centered(:,3) = v_err_centered(:,3) - mu_v_err(1,3);
Sigma_v_err = v_err_centered' * v_err_centered / size(v_err,1);
fprintf('err velocity covariance:\n');
disp(Sigma_v_err);
%% Plot
figure(1);
subplot(4, 1, 1);
plot(t, v_err(:,1));
%axis([0, 120, -0.05, 0.05]);
xlabel('t / s');
ylabel('v_x / m/s');
subplot(4, 1, 2);
plot(t, v_err(:,2));
%axis([0, 120, -0.05, 0.05]);
xlabel('t / s');
ylabel('v_y / m/s');
subplot(4, 1, 3);
plot(t, v_err(:,3));
%axis([0, 120, -0.05, 0.05]);
xlabel('t / s');
ylabel('v_z / m/s');
subplot(4, 1, 4);
plot(t, v_mag_err);
hold on;
plot(t, v_wheel_mag);
hold off;
%axis([0, 120, -0.05, 0.05]);
xlabel('t / s');
ylabel('|e_v| / m/s');
suptitle('Velocity Divergence (Rover Driving)');
%% Semi-Gaussian Model Fitting
gauss_mu = mean(v_mag_err); %0.5;
gauss_sigma = (v_mag_err - gauss_mu)' * (v_mag_err - gauss_mu) / size(v_mag_err,1);
fprintf('Gaussian_mu = %f\n', gauss_mu);
fprintf('Gaussian_sigma = %f\n', gauss_sigma);