Week 2- 2R Robotic Arm Challenge
1.Program to simulate the forward kinematics of a 2R Robotic Arm
%forward kinematics with for loop
close all
clear all
clc
% Length of robotic arms
l1 = 1
l2 = 0.5
% Set of angles for the movement of robotic arms
theta1 = linspace(0,90,10)
theta2 = linspace(0,90,10)
ct = 1 % Counter with starting value assigned as 1
for i = 1:length(theta1);
THETA1 = theta1(i);
for j = 1:length(theta2);
THETA2 = theta2(j);
% Coordinates of start point of first arm
x0 = 0
y0 = 0
% Coordinates of end point of 1st arm / start point of 2nd arm
x1 = l1*cosd(THETA1);
y1 = l1*sind(THETA1);
% Coordinates of end point of 2nd arm
x2 = x1 + l1*cosd(THETA2)
y2 = y1 + l1*sind(THETA2)
%plotting
plot([x0 x1],[y0 y1],[x1 x2],[y1 y2],'linewidth',3)
axis([-0.1 2 0 2])
pause(0.05)
ct=ct+1;
m(ct) = getframe(gcf);
end
end
movie(m)
videofile = VideoWriter('forward_kinematics.avi','Uncompressed AVI')
open(videofile)
writeVideo(videofile,m)
close(videofile)
2. Animation link
3.Errors faced while programming
1. While programming,I was not taken 'ct' value in inputs,due to this both links are not moving as shown in picture
solution - I checked my program again & then I realized that I was not taken 'ct' value in inputs.
After that I added 'ct' value in program.

2.As shown in picture while programming error occured in command window due this program is not run.
solution - I Checked error in command window.There is one end missing of for loop command.Then I added one end in programming.
