Week 2- 2R Robotic Arm Challenge
Challenge:Write a program in Matlab to simulate the forward kinematics of a 2R Robotic Arm, as shown in the video.
Robotic arm :
A robotic arm is a type of mechanical arm, usually programmable, with similar functions to a human arm; the arm may be the sum total of the mechanism or may be part of a more complex robot. The links of such a manipulator are connected by joints allowing either rotational motion (such as in an articulated) or translational (linear) displacement.The links of the manipulator can be considered to form a kinematic chains. The terminus of the kinematic chain of the manipulator is called the end efforts and it is analogous to the human hand. However, the term "robotic hand" as a synonym of the robotic arm is often procisediced.

where, (x0,y0) is initial coordinates of link1,
(x1,y1) is joint coordinates of link1 and link2,
(x2,y2) is initial coordinates of link2,
l1 and l2 are arm lengths of robot,
theta1 and theta2 are angles of robotic links.
MATLAB CODE:-
%A program to simulate the forward kinematics of a 2R robotics arm.
clear all
close all
clc
%inputs
%arm lengths of robotics arms (m)
l1 = 1;
l2 = 0.5;
%the angle formed by link1 and link2 with horizontal
theta1 = linspace(0,90,10);
theta2 = linspace(0,90,10);
%compression ratio (ct)
ct=1;
for i=1:length(theta1)
THETA1 = theta1(i);
for j=1:length(theta2)
THETA2 = theta2(j);
%initial coordinates of link1
x0=0;
y0=0;
%intersection of both links
x1=l1 *cosd(THETA1);
y1=l1 *sind(THETA1);
%final coordinates of link2
x2=x1+l2*cosd(THETA2);
y2=y1+l2*sind(THETA2);
%plotting for animation of 2r robotic arm
plot ([x0 x1],[y0 y1],[x1 x2],[y1 y2],'linewidth',5)
axis([-0.1 2 0 1.5])
pause(0.01)
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)
RESULT:-

No error found in command window and shows figure of stimulation.
Youtube link of stimulation is provided in below:-
https://youtu.be/I00cP1qU_tc