-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathGloveTest.m
74 lines (59 loc) · 2.17 KB
/
GloveTest.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
classdef GloveTest < handle
%UNTITLED Summary of this class goes here
% Detailed explanation goes here
properties
imuObj
end
methods
function obj = GloveTest()
end
function PlayData(obj,din)
acc = din.acc;
gyro = din.gyro;
obj.imuObj = GloveIMU();
nItems = size(acc,1);
obj.imuObj.ResetGlove();
obj.UpdateGlove();
tStart = tic;
for x = 1:nItems
obj.imuObj.Update(gyro(x,:),acc(x,:),1/40);
obj.UpdateGlove();
pause(1/40);
end
tElapsed = toc(tStart);
display(sprintf('Total time is %f Time per item is %f', tElapsed,tElapsed/nItems));
obj.imuObj = [];
end
function UpdateGlove(obj)
eAngles = obj.imuObj.EulerAngles();
for x = 1:6
rpq = eAngles(x,[3 1 2]).*[-1 0 -1];
%GyroGloveClient(x-1,[0 0 1 -yaw roll -pitch],0);
GyroGloveClient(x-1,[0 0 1 rpq],0);
end
end
function plotAlignData(obj,n)
% Debug function to allow me to look at some of the data used
% for the alignment. I wanted a quick way to examine the data
% to insure I had approprate ranges and also to get a feel for
% if the data was what I would expect, based on knowledge of
% how the glove was moved during that time.
figure;
for x = 1:2
start = obj.alignRanges(x,1);
stop = obj.alignRanges(x,2);
accData = obj.accFactor*double(obj.theData(start:stop,obj.accIndexes));
% Plot the hand
subplot(2,2,x);
plot(accData(:,1:3));
title(['hand ' x]);
grid;
% Plot other item
subplot(2,2,x+2);
plot(accData(:,4+(n-1)*3:6+(n-1)*3));
title(['FT ' x]);
grid;
end
end
end
end