Week 3.2 - 2R Robotic Arm Challenge
Google Drive Link -
% Forward kinematics of Robotic Arm (For Loop)
% Plot and Create Animation
% Inputs
L1 = 1
L2 = 0.6
L3 = 0.3
theta1 = linspace(0,90,10)
theta2 = linspace(0,90,10)
theta3 = linspace(0,60,10)
ct=1
for i = 1:length(theta1)
THETA1 = theta1(i);
for j = 1:length(theta2)
THETA2 = theta2(j);
for k = 1:length(theta3)
THETA3 = theta3(k);
% Co-Ordinates
X0 = 0
Y0 = 0
% Calculate (X1 Y1 , X2 Y2)
X1 = L1*cosd(THETA1);
Y1 = L1*sind(THETA1);
X2 = X1 + L2*cosd(THETA2);
Y2 = Y1 + L2*sind(THETA2);
X3 = X2 + L3*cosd(THETA3);
Y3 = Y2 + L3*sind(THETA3);
% Plotting
plot([X0 X1], [Y0 Y1], [X1 X2], [Y1 Y2], [X2 X3], [Y2 Y3],'linewidth',3)
axis([0 2 0 2])
pause(0.005)
M(ct) = getframe(gcf);
ct = ct+1
end
end
end
movie(M)
videofile = VideoWriter('forward_kinematic.avi','Uncompressed AVI');
open(videofile)
writeVideo(videofile,M)
close(videofile)