Ski boot walking attachment appendix

From DDL Wiki

Jump to: navigation, search

Contents

Code

Logarithmic Decrement

readenct.m

Reads in the text file generated by the MSE Rectilinear apparatus.


function [t,f,val]=readenct(filename,vd,encnum)

a=textread(filename,'','headerlines',23);
if strcmp(vd,'d') 
    val=-a(:,encnum+1);
end
if strcmp(vd,'v') 
    val=-a(:,encnum+5);
end
t=a(:,1);
f=a(:,2);

num4.m

Using the data returned by readenct, allows determination of physical constants using logarithmic decrament analysis.


[time,force,displacement]=readenct('medium_natural.txt','d',1);
figure(1)
plot(time,displacement+0.1198);
axis([10.6 11.4 -4 4.2])


a=ginput
c=max(a)

figure(2)
plot(time,displacement+0.1198);
axis([10.6 11.4 -4 4.2])


b=ginput
d=max(b)

prompt={'Number of Peaks in between','X Coordinate First MAX.','X Coordinate Second MAX.'}
name='Get User Input';
numlines=1;
defaultanswer={'0','0','0'};
answer=inputdlg(prompt,name,numlines,defaultanswer);
n=str2double(answer{1});
x1=str2double(answer{2});
x2=str2double(answer{3});

T=(x2-x1)/(n);
dampingRatio=((1/(n-1))*(log(c(1,2)/d(1,2))))/sqrt((4*pi^2)+((1/(n-1))*(log(c(1,2)/d(1,2))))^2)
naturalFrequency=((1/(n-1))*log(c(1,2)/d(1,2)))/(dampingRatio*T)
dampedNaturalFrequency=naturalFrequency*sqrt(1-dampingRatio^2)
m=0.79;
k=naturalFrequency^2*m
CoefficientOfDamping=dampingRatio*2*sqrt(k*m)

MATLAB model

gmodel

The core code; calls for construction of a physical model, which is then iterated through the time of a step.


function gmodel

clear all
close all

%layerconfigs(:,1) = [1 1 1 5 1 4 5 1 4 5 1 4 1 5 1 1 5 1 4 1 5 1 5 4 1 1 1 1 4 1 1 1 4 1 1 4 1 1 4 1 1 4 1 1 4 1 1 4 1];
layerconfigs(:,1) = [1 1 1 5 1 4 5 1 4 5 1 4 1 5 1 1 5 1 1 4 1 1 5 1 4 1 1 1 4 1 1 1 4 1 1 4 1 1 4 1 1 4 1 1 4 1 1 4 1];
%heel is zero

xlen = .3;
xres = .0075;
zlen = .075;
ddstep = [0 0];
compression_modifier = [0 0];

xpos = 0:xres:xlen;

y0 = spline([0 4 6 10 12],[.8,1.3,1.6,1.3,.8],xpos); %initial height
%convert to meters
y0 = .0254*y0;
body_mass = 70; %kg


for j = 1:1

    dd = zeros(size(y0)); %deflection
    rubber_layers = makelayers(layerconfigs(:,j));

    %begin step!

    %step takes time, gets cblocked by gait... so:
    %start each step, add other elems as they contact, but cblock as foot
    %rolls?
    %[foot_theta foot_length ankle_x ankle_y hip_x hip_y lint] = flexdata_cd_dat;
    [foot_theta foot_length ankle_x ankle_y hip_x hip_y_nod lint all_y] = flexdata_cd_dat;
    
    %Convert inches to metric
    ankle_x = .0254*ankle_x;
    ankle_y = .0254*ankle_y;
    hip_x = .0254*hip_x;
    hip_y_nod = .0254*hip_y_nod;
    all_y = .0254*all_y;
    
    
    hip_y = all_y(:,1)-mean(all_y(:,1));
    
    
    step_time = .50;
    theta = linspace(-pi/6,pi/6,round(length(lint)*step_time));
    time = linspace(0,step_time,length(theta));

    %make subsets of everything (we care about foot contact only here)
    foot_theta = foot_theta(1:length(theta));
    ankle_x = ankle_x(1:length(theta));
    ankle_y = ankle_y(1:length(theta));
    hip_x = hip_x(1:length(theta));
    hip_y_nod = hip_y_nod(1:length(theta))-mean(hip_y_nod(1:length(theta)));
    hip_y = hip_y(1:length(theta));

    theta = foot_theta; %LOL
    
    hip_y = smooth(hip_y,100,'sgolay',3);
    hip_y_adj = hip_y;

    for i = 3:length(theta)

        stepsecs = time(i)-time(i-1);

        clearfornext = 0;

        %while clearfornext < 1

            %find lengths
            theta(i)
            
            lens = -((xpos-mean(xpos))*sin(theta(i)))+abs(y0*cos(theta(i)))-abs(dd*cos(theta(i)));

            [lens_sort lens_sort_ix] = sort(lens);
            incontact = sum(lens>=lens_sort(end)-ddstep(i-1)*compression_modifier(i-1))
            contact_indexes = lens_sort_ix(end-incontact+1:end)
            lens
            
            numcontact(i) = incontact;

            ddstep(i) = lens_sort(end) - lens_sort(end-incontact);

            hip_dely_dumb = hip_y(i) - hip_y(i-1);
            hip_dy_dumb(i) = hip_dely_dumb/stepsecs; %dumb calc of hip y velocity
            hip_dy2_dumb(i) = (hip_dy_dumb(i) - ((hip_y(i-1) - hip_y(i-2))/stepsecs))/stepsecs;



            %force applied
            k = rubber_layers(1,contact_indexes); 
            c = rubber_layers(2,contact_indexes);

            f_expected = hip_dy2_dumb(i) * body_mass;
            fex(i) = f_expected;
            
            w0 = (sum(k)/body_mass)^.5;
            gamma = sum(c)/(2*(sum(k)*body_mass)^.5);
            wd = w0*(1-gamma^2)^.5;
            wdi(i) = wd;
            
            compression_modifier(i) = stepsecs/wd*8200;

            dd(contact_indexes) = dd(contact_indexes) + ddstep(i)*compression_modifier(i);

            dd(dd>y0*.5) = y0(dd>y0*.5)*.5;
            
            f_app_k = sum(k ./ body_mass .* dd(contact_indexes));
            f_app_c = f_expected - f_app_k;
            hip_dy_adj(i) = -f_app_c/sum(c/body_mass)/25400;
            if hip_dy_adj(i) < -10
                hip_dy_adj(i) = -10;
            end
            
            hip_y_adj(i) = hip_y_adj(i-1) + hip_dy_adj(i) * stepsecs;
            
            
          

    end %for i

    figure(3)
   % plot(time,'k')
    hold on
    %plot(time,hip_dy2_dumb/1000)
    plot(time(1:round(.9*end)+1),hip_y_nod(round(.1*end):end)*.7,'r')
    %plot(time,hip_y+hip_y_adj/10)
    plot(time,hip_y-hip_y_adj+hip_y_adj(1))
    
    figure(2)
    %plot(time,hip_y)
    %plot(time,hip_dy_adj)
end %for j
    hold on
    plot(time,-hip_y_adj/25.4)
    title('Device deformation during step')
    xlabel('Time [s]')
    ylabel('Displacement [m]')
    x = 1;
    

flexdata_cd_dat

Provides the kinesiological data behind normal walking as well as walking in ski boots.


function [foot_theta foot_length ankle_x ankle_y hip_x hip_y lint all_y_device] = flexdata_cd_dat

lint = linspace(0,1000,1000);

hip_height = -10*cos(lint*2*3.1516/1000);

%hip_theta = [162 162 170 178 185 193 183 170 160 156 158 162];
hip_theta = [157 164 170 178 185 193 183 170 160 154 156 157];
hip_time = [0 100 200 300 400 500 600 700 800 850 900 1000];
hip_theta_cubic = interp1(hip_time,hip_theta,lint,'spline');


knee_theta = [10 5 15 5 7 45 70 20 10];
knee_time = [0 100 250 450 500 600 750 950 1000];
knee_theta_cubic = interp1(knee_time,knee_theta,lint,'spline');

%ankle_theta = [0 -5 0 22 0 -8 8 0];
%ankle_time =  [0 25 50 250 440 600 900 1000];
ankle_theta = [15 15];
ankle_time = [0 1000];
ankle_theta_cubic = interp1(ankle_time,ankle_theta,lint,'spline');

foot_length = 28;

shin_length = 56;

thigh_length = 70;
%{
figure(1)
%plot(hip_time,hip_theta)
plot(lint,hip_theta_cubic)

figure(2)
%plot(knee_time,knee_theta)
plot(lint,knee_theta_cubic)

figure(3)
%plot(ankle_time,ankle_theta)
plot(lint,ankle_theta_cubic)

figure(5)
plot(lint,hip_height)

%}

%
%
% %% That's the data. Now for the motion.
%
%
pi = 3.1416;
twopi = 2*pi;

hip_theta_rad = (180-hip_theta_cubic)*pi/180;
knee_theta_rad = knee_theta_cubic*pi/180;
ankle_theta_rad = ankle_theta_cubic*pi/180;


%hip_x(1:1000) = 0;
hip_x = linspace(1,170,1000);
hip_y = hip_height;

knee_x = hip_x + thigh_length.*sin(hip_theta_rad);
knee_y = hip_y - thigh_length.*cos(hip_theta_rad);

ankle_x = knee_x + shin_length.*sin(hip_theta_rad-knee_theta_rad);
ankle_y = knee_y - shin_length.*cos(hip_theta_rad-knee_theta_rad);

toe_x = ankle_x + foot_length.*sin(hip_theta_rad-knee_theta_rad+(1.9-ankle_theta_rad));
toe_y = ankle_y - foot_length.*cos(hip_theta_rad-knee_theta_rad+(1.9-ankle_theta_rad));


device_y = [.3 2 .3];
device_x = [0 .5 1];
device_y_cubic = interp1([0 .3 .5 .8 1],[1,1.5,2,1.6,1.2],linspace(0,1,100),'spline');
%device_y_cubic = interp1(device_x, device_y,linspace(0,1,100),'spline');

foot_theta = (hip_theta_rad-knee_theta_rad+(1.9-ankle_theta_rad))'-pi/2;

[device_theta, device_phi, device_r] = cart2sph(linspace(0,foot_length,100),-device_y_cubic,zeros(1,100));
device_theta_rot = repmat(device_theta,1000,1) + repmat(foot_theta,1,100);
device_r_rot = repmat(device_r,1000,1);
[device_x_rot device_y_rot dummy2] = sph2cart(device_theta_rot,zeros(1000,100),device_r_rot);
device_y_contact = min(device_y_rot,[],2);
device_y_add = min([device_y_rot(:,1) device_y_rot(:,100)],[],2)-device_y_contact;
device_y_add(600:1000) = zeros(1,401);
%hip_y = hip_y + device_y_add' - device_y_add(10);

%figure(9)
%plot(lint,device_y_add)



all_x = [hip_x' knee_x' ankle_x' toe_x'];
all_y_raw = [hip_y' knee_y' ankle_y' toe_y'];

ankle_low = ankle_y.*(ankle_y<toe_y);
toe_low = toe_y.*(toe_y<ankle_y);
all_y_adjustment = repmat(ankle_low' + toe_low',1,4);

all_y = all_y_raw - all_y_adjustment;
all_y(600:1000,:) = all_y_raw(600:1000,:) - repmat(linspace(all_y_adjustment(600,1),all_y_adjustment(1000,1),401)',1,4);

all_y_device = all_y + repmat(device_y_add,1,4);


figure(4)
clf
step = 40;
hold on
i = 1;
k = 1;
while k < 600
plot(all_x(k,:),all_y_device(k,:))
i = i + 1;
k = k + step;
end

Personal tools