forked from xioTechnologies/Gait-Tracking-With-x-IMU
-
Notifications
You must be signed in to change notification settings - Fork 0
/
liveSensorFromFile.m
115 lines (88 loc) · 2.24 KB
/
liveSensorFromFile.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
%------------------------------------------------------------------------
% Insitute: Salzburg University of Applied Sciences
% Author: Manuel Schmitzberger
% Departement: Information Technology & Systems
%
% Bugs and comments to: [email protected]
%------------------------------------------------------------------------
% Display Mobile device Sensor Live
% accelerometer+","+magneticField+","+gyroscope
clc;
clear;
close all;
addpath('./data');
x = 0;
xMax = 50;
% data
fid = fopen('pipe');
while(1)
x = x+1;
tline = fgets(fid);
disp(tline)
data = strsplit(tline, ',');
% data Acceloremeter
yA1(x) = str2double(data(1));
yA2(x) = str2double(data(2));
yA3(x) = str2double(data(3));
% data Magnetometer
yM1(x) = str2double(data(4));
yM2(x) = str2double(data(5));
yM3(x) = str2double(data(6));
% data Gyroscope
yG1(x) = str2double(data(7));
yG2(x) = str2double(data(8));
yG3(x) = str2double(data(9));
% plot Accelerometer
drawnow;
subplot(3,1,1);
plot(yA1,'r','linewidth',3)
grid on;
hold on;
plot(yA2,'g','linewidth',3)
plot(yA3,'b','linewidth',3)
title('ACCELEROMETER');
xlabel('Time in seconds');
ylabel('Digital Value');
xlim([0 xMax])
% plot Magnetometer
drawnow;
subplot(3,1,2);
plot(yM1,'r','linewidth',3)
grid on;
hold on;
plot(yM2,'g','linewidth',3)
plot(yM3,'b','linewidth',3)
title('MAGNETOMETER');
xlabel('Time in seconds');
ylabel('Digital Value');
xlim([0 xMax])
% plot Gyrometer
drawnow;
subplot(3,1,3);
plot(yG1,'r','linewidth',3)
grid on;
hold on;
plot(yG2,'g','linewidth',3)
plot(yG3,'b','linewidth',3)
title('GYROMETER');
xlabel('Time in seconds');
ylabel('Digital Value');
xlim([0 xMax])
% SHOW
plot3dObject();
if(x > xMax)
x = 0;
yA1 = 0;
yA2 = 0;
yA3 = 0;
yM1 = 0;
yM2 = 0;
yM3 = 0;
yG1 = 0;
yG2 = 0;
yG3 = 0;
clf; %clear figure
hold on; % again hold on after clearing
end
end
fclose(fid);