-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprocessSegmentData.m
54 lines (41 loc) · 1.48 KB
/
processSegmentData.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
filename = 'rawData/segmentData.xlsx';
segmentData = xlsread(filename);
%discretize
xi = 0;
xf = 1;
xstep = (xf-xi)/steps;
xnodes = steps + 1;
segmentData(:,1) = segmentData(:,1) * height / 100;
segmentData(:,2) = segmentData(:,2) * mass / 100;
segmentData(:,3) = segmentData(:,3) / 100;
[nRow, nCol] = size(curvedDegData);
emptyArr = [ ((0:steps)*xstep).' zeros(nRow, nCol-1) ];
segmentEndPosX = emptyArr;
segmentEndPosY = emptyArr;
segmentCOMPosX = emptyArr;
segmentCOMPosY = emptyArr;
wholeBodyCOMXY = zeros(nRow, 2);
kneeTorque = zeros(nRow, 1);
for i=1:nRow
x = 0;
y = 0;
for j=2:nCol
segmentLength = segmentData(j-1, 1);
segmentMass = segmentData(j-1, 2);
segmentLtoCOM = segmentData(j-1, 3);
dx = segmentLength * cos(curvedDegData(i, j)*pi/180);
dy = segmentLength * sin(curvedDegData(i, j)*pi/180);
segmentEndPosX(i, j) = x + dx;
segmentEndPosY(i, j) = y + dy;
segmentCOMPosX(i, j) = x + dx * segmentLtoCOM;
segmentCOMPosY(i, j) = y + dy * segmentLtoCOM;
%Start adding up torque
if j > 3
kneeTorque(i) = kneeTorque(i) + (segmentMass * 9.81) * (segmentEndPosX(i, 3) - segmentCOMPosX(i, j));
end
x = x + dx;
y = y + dy;
end
wholeBodyCOMXY(i, 1) = segmentCOMPosX(i,:) * [ 0; segmentData(:,2)] / sum(segmentData(:,2));
wholeBodyCOMXY(i, 2) = segmentCOMPosY(i,:) * [ 0; segmentData(:,2)] / sum(segmentData(:,2));
end