Week 2- 2R Robotic Arm Challenge
%R2_arm Kinematic Animation
%Input
L1 = 1;
L2 = 0.5;
theta1 = linspace(0,90,10);
theta2 = linspace(0,90,10);
%Program
ct = 1;
for i=1:length(theta1)
THETA1 = theta1(i);
for j = 1:length(theta2)
THETA2 = theta2(j);
X0 = 0;
Y0 = 0;
X1 = L1*cosd(THETA1);
Y1 = L1*sind(THETA1);
X2 = X1+ L2*cosd(THETA2);
Y2 = Y1+ L2*sind(THETA2);
%Plotting
plot([X0 X1],[Y0 Y1],[X1 X2], [Y1 Y2],'linewidth',3)
axis([-0.1 1.5 0 1.5])
pause(0.3)
M(ct) = getframe(gcf);
ct = ct+1;
end
end
movie(M)
videofile = VideoWriter('Forward_kinematics.avi','Uncompressed AVI');
open(videofile)
writeVideo(videofile,M)
close(videofile)
Aim : To generate 2R robotic arm reachability animation profile
Inputs:
Length of the arm 1 = 1m
Length of the arm 2 = 0.5m
Angular travel of both the arms = 0° to 90°
Process:
Initially generated the code for the end points of both the arms.
X0 Y0, X1 Y1 & X2 Y2.
Processed the code under two for loops
Ie for first angular travel of the Arm1, the Arm 2 should complete its 0 to 90° of rotation.
& generated the animation file with the writevideo command.
Errors faced:
Not enough arguments
Theta1 = linspace(1:90:10)
Rectification: Wrongly framed linspace command
Theta1 = linspace(1,90,10)
Conclusion:
Succesfully generated the 2R_robotic arm reach video file.


Video link: https://www.youtube.com/watch?v=CiaqWlhA2F0