Skip to content

Commit 710cbd8

Browse files
committed
finished gryo and accel model
1 parent 7aa2da6 commit 710cbd8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+68
-31
lines changed
78.4 KB
Binary file not shown.
Binary file not shown.

data/2024-9-28-sensor-noise-test/parse_testing_data.m

+56-31
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
accelY = rawData(:,10);
1212
accelZ = rawData(:,11);
1313

14+
aXbias = mean(accelX); % accelerometer data (m/s^2)
15+
aYbias = mean(accelY);
16+
aZbias = mean(accelZ);
17+
1418
gx = rawData(:,12); % gyrometer data (rad/s)
1519
gy = rawData(:,13);
1620
gz = rawData(:,14);
@@ -19,6 +23,10 @@
1923
magY = rawData(:,16);
2024
magZ = rawData(:,17);
2125

26+
axMean = mean(accelX);
27+
ayMean = mean(accelY);
28+
azMean = mean(accelZ);
29+
2230
gxMean = mean(gx);
2331
gyMean = mean(gy);
2432
gzMean = mean(gz);
@@ -63,43 +71,60 @@
6371
ylabel("freq")
6472

6573
%% Plots using simulink
66-
figure
67-
plot(time,gz,out.tout, out.gz)
68-
legend("real data","simulink model")
69-
xlabel("time (s)")
70-
ylabel("rotation (rad/s)")
7174

72-
figure
73-
[f,amp] = myfft(gz-gzMean, 16);
74-
hold on
75-
[fsim,ampsim] = myfft(out.gz-gzMean, 16);
75+
function compareData(actual, model, actualTime, modelTime)
7676

77-
figure
78-
[tau,AVAR] = allan(time, gz-gzMean);
79-
hold on
80-
[tausim,AVARsim] = allan(out.tout, out.gz-gzMean);
81-
title("Allan Variance Plot")
82-
legend("real data","simulink model")
83-
xlabel("tau")
84-
ylabel("Allan Variance")
77+
figure
78+
plot(actualTime, actual, modelTime, model)
79+
legend("real data","simulink model")
80+
xlabel("time (s)")
81+
ylabel("rotation (rad/s)")
82+
83+
actualMean = mean(actual);
8584

86-
figure
87-
histogram(gz,"BinWidth",.0035)
88-
hold on
89-
histogram(out.gz,"BinWidth",.0035)
90-
title("Histogram of model vs raw")
91-
legend("real data","simulink model")
92-
xlabel("rad/s")
93-
ylabel("freq")
85+
figure
86+
[f,amp] = myfft(actual-actualMean, 16);
87+
hold on
88+
[fsim,ampsim] = myfft(model-actualMean, 16);
89+
90+
figure
91+
[tau,AVAR] = allan(actualTime, actual-actualMean);
92+
hold on
93+
[tausim,AVARsim] = allan(modelTime, model-actualMean);
94+
title("Allan Variance Plot")
95+
legend("real data","simulink model")
96+
xlabel("tau")
97+
ylabel("Allan Variance")
98+
99+
figure
100+
histogram(actual, "BinWidth",.0035)
101+
hold on
102+
histogram(model,"BinWidth",.0035)
103+
xlim([-0.1, 0.1]);
104+
title("Histogram of model vs raw")
105+
legend("real data","simulink model")
106+
xlabel("rad/s")
107+
ylabel("freq")
108+
109+
calcRateNoiseDensity = AVAR(16);
110+
calcRateNoiseDensitysim = AVARsim(16);
111+
112+
fprintf("tau check: %f, %f, calculated RND of sensor: %f, calcRND of sim: %f\n", tau(16),tausim(16), AVAR(16), AVARsim(16))
113+
fprintf("mean of sensor: %f, mean of sim: %f\n", actualMean, mean(model))
114+
fprintf("std of sensor: %f, std of sim: %f\n", std(actual), std(model))
115+
fprintf("ideal mean is 0. ideal RND is .0038\n")
116+
end
117+
118+
compareData(accelZ, out.az, time, out.tout);
94119

95120
% tau(16) at this point, tau is closest to 1
96-
calcRateNoiseDensity = AVAR(16);
97-
calcRateNoiseDensitysim = AVARsim(16);
121+
%calcRateNoiseDensity = AVAR(16);
122+
%calcRateNoiseDensitysim = AVARsim(16);
98123
% ans = .0044. the data sheet says it should be .0038
99-
fprintf("tau check: %f, %f, calculated RND of sensor: %f, calcRND of sim: %f\n", tau(16),tausim(16), AVAR(16), AVARsim(16))
100-
fprintf("mean of sensor: %f, mean of sim: %f\n", gzMean, mean(out.gz))
101-
fprintf("std of sensor: %f, std of sim: %f\n", gzStd, std(out.gz))
102-
fprintf("ideal mean is 0. ideal RND is .0038\n")
124+
%fprintf("tau check: %f, %f, calculated RND of sensor: %f, calcRND of sim: %f\n", tau(16),tausim(16), AVAR(16), AVARsim(16))
125+
%fprintf("mean of sensor: %f, mean of sim: %f\n", gzMean, mean(out.gy))
126+
%fprintf("std of sensor: %f, std of sim: %f\n", gzStd, std(out.gy))
127+
%fprintf("ideal mean is 0. ideal RND is .0038\n")
103128

104129
%% what I did to make the model
105130
% 1. input the static bias into model
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<MF0 version="1.1" packageUris="http://schema.mathworks.com/mf0/SlCache/19700101">
3+
<slcache.FileAttributes type="slcache.FileAttributes" uuid="10f65702-aea3-446f-8990-5ffae52a9180">
4+
<checksum>gsi9CgW0EnoWtKUWbBmL9Rt+SAOtGsyATizvuxdKlIUdGLqsHAB/e5EKio67LIR9y+ZyH53p0GWpqPSkTx+7Kg==</checksum>
5+
</slcache.FileAttributes>
6+
</MF0>
Binary file not shown.
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<MF0 version="1.1" packageUris="http://schema.mathworks.com/mf0/SlCache/19700101">
3+
<slcache.FileAttributes type="slcache.FileAttributes" uuid="241383d9-8c43-4016-9d11-751e8b8ace4a">
4+
<checksum>D8CRXpu7JHBIKR7RK6MDfYu/G3yHAS0xkxmaPaRu8hVfpW1JsyrNdT6Pp3Nsk9sqAFeMeP/mrRmnOSjPCYLxPA==</checksum>
5+
</slcache.FileAttributes>
6+
</MF0>
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)