https://youtu.be/xb7MaJzSoRg
% Forward kinematics of 2R Robot
clear all
close all
clc
% inputs
% Length of the 1st Arm
l1 = 2;
% Length of the 2nd Arm
l2 = 1.5;
% Angle between Base & Arm with 150 Equal Intervels from 0 to 90 Deg
theta1 = linspace(0,90,150);
theta2 = linspace(0,90,150);
ct = 1;
% For loop to check the different Arm Angles
for i = 1:length(theta1) % Arm angle considered from 1 to 90 deg with 150 Equal Intervals
THETA1 = theta1(i);
for j = 1:length(theta2)% Arm angle considered from 1 to 90 deg with 150 Equal Intervals
THETA2 = theta2(j);
x0 = 0; % Start point of 1st Arm
y0 = 0; % Start point of 1st Arm
x1 = l1*cosd(THETA1); % End point of 1st arm / STart point of 2nd arm
y1 = l1*sind(THETA1); % End point of 1st arm / STart point of 2nd arm
x2 = x1 + l2*cosd(THETA2); % End point of 2nd arm
y2 = y1 + l2*sind(THETA2); % End point of 2nd arm
%Plotting of Arm kinematics
% Plotting the 1st arm from the Point X0/y0 to x1/y1 & 2nd arm from
% x1/y1 to x2/y2
plot ([x0 x1],[y0 y1],[x1 x2],[y1 y2],'linewidth',3)
%setting Axis Limits
axis([-0.1 5 0 5])
% Pause the graph
pause(0.1)
%counter Incriment
ct = ct + 1;
end
end