Week 2- 2R Robotic Arm Challenge
Please refer attachment for Code Explanation and Error fixing
Youtube link for Forward Kinematics: https://youtu.be/iGXQQIef6cI
clear all
close all
clc
%% Write a program to simulate forward kinematics of 2R Robotic Arm
%Assuming Arm Length L1 = 1meter
L1 = 1
%Assuming Arm Length L2 = 1meter
L2 = 0.5
theta1 = linspace(0,90,10);
theta2 = linspace(0,90,10);
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);
plot([X0 X1],[Y0 Y1],[X1 X2],[Y1 Y2],'linewidth',3)
axis([-1 1.5 0 1.5]);
pause(0.03)
M(ct)=getframe(gcf);
ct=ct+1;
end
end
movie(M)
videofile=VideoWriter('Robortic_Arm.avi','uncompressed AVI');
open(videofile)
writeVideo(videofile,M)
close(videofile)