Natural Finger Movement Matalab Code:
clear all;
clc;
PP = 2.4; IP = 1.5; DP = 1;
a = PP; b = IP; c = DP;
alpha1 = acos((b^2 + c^2 - a^2)/(2*b*c));
alpha3 = asin(c*sin(alpha1)/a);
beta = 0*pi/180;
theta2max = pi - alpha3;
theta3max = pi - alpha1;
theta1max = 2*pi - (theta2max + theta3max) - beta;
lambda0 = theta3max/theta2max;
lambda1 = theta2max/theta1max;
if i == 1
for i = 1: 86
theta1(i) = (i-1)*pi/180;
theta2(i) = theta1(i)*lambda1;
theta3(i) = theta2(i)*lambda1;
phi1(i) = theta1(i) + theta2(i);
phi2(i) = theta1(i) + theta2(i) + theta3(i);
phi3(i) = theta1(i) + theta2(i) + theta3(i) - beta;
origin = [0,0]';
P_A = [a*cos(-theta1(i)) a*sin(-theta1(i))]';
P_B = P_A + [b*cos(-phi1(i)) c*sin(-phi1(i))]';
P_C = P_B + [c*cos(-phi2(i)) c*sin(-phi2(i))]';
figure (1)
filename = 'naturalfinger.gif';
pause(0.01)
plot(origin(1), origin(2), 'ro','linewidth', 2)
hold on
plot(P_A(1), P_A(2), 'ro','linewidth', 2)
plot(P_B(1), P_B(2), 'ro','linewidth', 2)
plot(P_C(1), P_C(2), 'ro','linewidth', 2)
line([origin(1) P_A(1)], [origin(2) P_A(2)], 'linewidth', 2, 'color', [0 0 1])
line([P_A(1) P_B(1)], [P_A(2) P_B(2)], 'linewidth', 2, 'color', [0 0 1])
line([P_B(1) P_C(1)], [P_B(2) P_C(2)], 'linewidth', 2, 'color', [0 0 1])
hold off
axis([-5 5 -5 5]);
title('Natural Finger Movement')
drawnow
frame = getframe(1);
im = frame2im(frame);
[imind,cm] = rgb2ind(im,256);
if i == 1;
imwrite(imind,cm,filename,'gif','loopcount',inf,'DelayTime',0.01);
else
imwrite(imind,cm,filename,'gif','WriteMode','append','DelayTime',0.01);
end
end
Prototype Finger Movement Matlab Code:
clear all;
clc;
a = 2.40; b = 1.50; c = 1.00;
RL1_2 = 1.39; theta1_2 = 23.81*pi/180;
RL2_2 = 0.41; theta2_2 = 63.44*pi/180;
RL2_3 = 0.40; theta2_3 = 36.42*pi/180;
RL3_2 = 0.41; theta3_2 = 7.50*pi/180; theta3_3 = 74.05*pi/180;
L1 = 0.475; theta1 = 56.565*pi/180;
%L2 = 0.9650; theta2 = 13*pi/180;
L3 = 0.290; theta3 = 62.59*pi/180;
alpha1 = acos((b^2 + c^2 - a^2)/(2*b*c));
alpha3 = asin(c*sin(alpha1)/a);
beta = 0*pi/180;
theta2max = pi - alpha3;
theta3max = pi - alpha1;
theta1max = 2*pi - (theta2max + theta3max) - beta;
lambda0 = theta3max/theta2max;
lambda1 = theta2max/theta1max;
filename = 'prototype.gif';
for i = 1:86
th1(i) = (i-1)*pi/180;
th2(i) = th1(i)*lambda1;
th3(i) = th2(i)*lambda1;
phi1(i) = th1(i) + th2(i);
phi2(i) = th1(i) + th2(i) + th3(i);
origin = [0,0]';
P_A_1 = [a*cos(-th1(i)) a*sin(-th1(i))]';
P_A_2 = [RL1_2*cos(-theta1_2-th1(i)) RL1_2*sin(-theta1_2-th1(i))]';
P_B_1 = P_A_1 + [b*cos(-phi1(i)) b*sin(-phi1(i))]';
P_B_2 = P_A_1 + [RL2_2*cos(-theta2_2-phi1(i)) RL2_2*sin(-theta2_2-phi1(i))]';
P_B_3 = P_B_2 + [RL2_3*cos(theta2_3-phi1(i)) RL2_3*sin(theta2_3-phi1(i))]';
P_C_1 = P_B_1 + [c*cos(-theta3_2-phi2(i)) c*sin(-theta3_2-phi2(i))]';
P_C_2 = P_B_1 + [RL3_2*cos(-theta3_3-phi2(i)) RL3_2*sin(-theta3_3-phi2(i))]';
P_A = P_A_2 + [L1*cos(theta1-th1(i)) L1*cos(theta1-th1(i))]';
%P_B = P_A + [L2*cos(-theta2-th1(i)) L2*cos(-theta2-th1(i))]';
P_C = P_B_3 + [L3*cos(theta3-phi1(i)) L3*sin(theta3-phi1(i))]';
pause(0.05)
plot(origin(1), origin(2), 'ro','linewidth', 2)
hold on
plot(P_A_1(1), P_A_1(2), 'ro', 'linewidth', 2)
plot(P_A_2(1), P_A_2(2), 'bo', 'linewidth', 2)
plot(P_B_1(1), P_B_1(2), 'ro', 'linewidth', 2)
plot(P_B_2(1), P_B_2(2), 'bo', 'linewidth', 2)
plot(P_B_3(1), P_B_3(2), 'bo', 'linewidth', 2)
plot(P_C_1(1), P_C_1(2), 'ro', 'linewidth', 2)
plot(P_C_2(1), P_C_2(2), 'bo', 'linewidth', 2)
plot(P_A(1), P_A(2), 'bo', 'linewidth', 2)
%plot(P_B(1), P_B(2), 'bo', 'linewidth', 2)
plot(P_C(1), P_C(2), 'bo', 'linewidth', 2)
line([origin(1) P_A_1(1)], [origin(2) P_A_1(2)], 'linewidth', 2, 'color', [0 0 1])
line([origin(1) P_A_2(1)], [origin(2) P_A_2(2)], 'linewidth', 2, 'color', [0 0 1])
line([P_A_2(1) P_A_1(1)], [P_A_2(2) P_A_1(2)], 'linewidth', 2, 'color', [0 0 1])
line([P_A_1(1) P_B_1(1)], [P_A_1(2) P_B_1(2)], 'linewidth', 2, 'color', [0 1 0])
line([P_A_1(1) P_B_2(1)], [P_A_1(2) P_B_2(2)], 'linewidth', 2, 'color', [0 1 0])
line([P_B_1(1) P_B_2(1)], [P_B_1(2) P_B_2(2)], 'linewidth', 2, 'color', [0 1 0])
line([P_B_1(1) P_C_1(1)], [P_B_1(2) P_C_1(2)], 'linewidth', 2, 'color', [1 0 1])
line([P_B_1(1) P_C_2(1)], [P_B_1(2) P_C_2(2)], 'linewidth', 2, 'color', [1 0 1])
line([P_C_1(1) P_C_2(1)], [P_C_1(2) P_C_2(2)], 'linewidth', 2, 'color', [1 0 1])
line([P_A_2(1) P_A(1)], [P_A_2(2) P_A(2)], 'linewidth', 2, 'color', [1 0 0])
line([P_A(1) P_B_2(1)], [P_A(2) P_B_2(2)], 'linewidth', 2, 'color', [1 0 0]) %Need this length
line([P_B_3(1) P_C(1)], [P_B_3(2) P_C(2)], 'linewidth', 2, 'color', [1 0 0])
line([P_C(1) P_C_2(1)], [P_C(2) P_C_2(2)], 'linewidth', 2, 'color', [1 0 0])
axis([-3 5 -5 1]);
hold off;
title('Prototype')
drawnow
frame = getframe(1);
im = frame2im(frame);
[imind,cm] = rgb2ind(im,256);
if i == 1;
imwrite(imind,cm,filename,'gif','loopcount',inf,'DelayTime',0.01);
else
imwrite(imind,cm,filename,'gif','WriteMode','append','DelayTime',0.01);
end
end