%% Code to conduct kinematic analysis
%Sarah Farrell
%variable definition:
L1 = 19.14;
L2 = 3.3;
theta1 = 0;
L5 = 11.029;
L6 = 30.42;
Lt = 24.89;
omega2 = (23/60)*2*pi; %radians per second
%positional variable storage
C_x = []; %only moves horizontally
D_x = [];
D_y =[];
E_y = []; %only moves vertically
T2 = [];
%velocity variable storage
C_dot = [];
E_dot = [];
O5 = [];
Ot = [];
i = 1;
for theta2 = 0:1:360
%positional:
%from vector loop 1:
theta3 = atand((L1*sind(theta1) + L2*sind(theta2))/(L1*cosd(theta1) + L2*cosd(theta2)));
L3 = (1/cosd(theta3))*(L1*cosd(theta1) + L2*cosd(theta2));
%from vector loop 2:
L4 = Lt - L3;
theta4 = theta3;
theta5 = acosd((L6 - Lt*cos(theta4))/L5);
L7 = -(Lt*sind(theta4) + L5*sind(theta5));
C_x(i) = L3;
D_x(i) = Lt*cosd(theta3);
D_y(i) = Lt*sind(theta3);
E_y(i) = L7;
T2(i) = theta2;
%velocity:
%from vector loop 1:
numerator = L2*omega2*(cosd(theta2) + tand(theta3)*sind(theta2));
denominator = (tand(theta3)*sind(theta3))*L3;
omega3 = numerator/denominator;
L3_dot = (1/cosd(theta3))*(L3*omega3*sind(theta3) - L2*omega2*sind(theta2));
%from vector loop 2:
omegat = omega3;
thetat = theta3;
omega5 = (1/(L5*sind(theta5)))*(-Lt*omegat*sind(thetat));
L7_dot = -(Lt*omegat*cosd(thetat) + L5*omega5*cosd(theta5));
C_dot(i) = L3_dot;
E_dot(i) = L7_dot;
O5(i) = omega5;
Ot(i) = omegat;
i = i+1;
end
figure(1)
plot(T2, C_x)
title("Horizontal Position of Point C as a Function of Theta 2")
xlabel("Theta 2 (degrees)")
ylabel("X-Position of Point C (cm)")
figure(2)
plot(T2, D_x)
hold on
plot(T2, D_y)
legend("X-Position", "Y-Position")
title("Position of Point D as a Function of Theta 2")
xlabel("Theta 2 (degrees)")
ylabel("Position of Point C (cm)")
ylim([-10 30])
figure(3)
plot(T2, E_y)
title("Vertical Position of Point E as a Function of Theta 2")
xlabel("Theta 2 (degrees)")
ylabel("Y-Position of Point E (cm)")
figure(4)
plot(T2, C_dot)
title("Horizontal Velocity of Point C as a Function of Theta 2")
xlabel("Theta 2 (degrees)")
ylabel("Velocity of Point C (cm/s)")
figure(5)
plot(T2, E_dot)
title("Vertical Velocity of Point E as a Function of Theta 2")
xlabel("Theta 2 (degrees)")
ylabel("Velocity of Point E (cm/s)")
figure(6)
plot(T2, O5)
title("Rotational Velocity of Link 5 as a Function of Theta 2")
xlabel("Theta 2 (degrees)")
ylabel("Velocity of Link 5 (rad/s)")
figure(7)
plot(T2, Ot)
title("Rotational Velocity of Links 3 and 4 as a Function of Theta 2")
xlabel("Theta 2 (degrees)")
ylabel("Velocity of Links 3 and 4 (rad/s)")