Week 2- 2R Robotic Arm Challenge
aim-write a matlab program to simulate the forward kinematics of a 2R robotic arm.
objective-
* Write a program to simulate forward kinematics of a 2R robotics arm
* Animating and creating a movie from the plots obtained from the program
theory- A manipulator/end effector movement determine the workspace where the robotic arm can be applicable.Our motive is to animate the movement of robotic arm with the subsequent relative motion between the two comprising links.

inputs-
(x0,y0) = starting point of link1
(x1,y1) = end point of link1/starting point of link2
(x2,y2) = end point of link2
l1=length of link attached to the base
l2=length of link between the frist link and the end effector
theta1=angle made by link1 with x-axis
theta2=angle made by link2 with x-axis
program-
clear all
close all
clc
%input
%length of the robotic arm
l1 = 1;
l2 = 0.5;
% angles for the movement of robotic arm
theta1 = linspace(0,90,10)
theta2 = linspace(0,90,10)
%counter with starting value assigened as 1
ct=1;
%for end loop
for i =1:length(theta1)
THETA1 =theta1(i);
for j = 1:length(theta2)
THETA2 =theta2(j)
%coordinat of start point of frist arm
x0 = 0;
y0 = 0;
%coordinate of end point of frist arm/start point of second arm
x1 = l1*cosd(THETA1);
y1 = l1*sind(THETA1);
%coordinate of end point of second arm
x2 = x1+l2*cosd(THETA2);
y2 = y1+l2*sind(THETA2);
%plotting
plot([x0 x1],[y0 y1],[x1 x2],[y1 y2],'linewidth',3);
% the limits of the x-axis and y-axis
axis([-0.2 1.5 0 1.5]);
% the cease the animation from jumping between subsequent figure
pause(0.03)
M(ct)=getframe(gcf);
ct = ct+1;
end
end
% to make the movie of the collected frame
movie(M)
% saving the movie in '.avi' format
videofile=VideoWriter('kinematics_robotics_arm.avi','uncompressed AVI')
open(videofile)
%writhig the movie in videofile created
writeVideo(videofile,M)
close(videofile)
explanation of program-
* initially we define the length of thr a robotic arm,i.e.l1 and l2.
* set of values for theta1 and theta2 are assigned in and array with linspace command.
* use of for command for iterating the values of the desired variable.
* Again using for command for providing movement to the second robotic arm
* Defining the coordinate of both the robotic arms.
* plotting all the coordinate values and writing commands for changing the appearance of the contours
* All figures are assigned to a variable M,one at a time using ct followed by termination of for loop.
* Lastiy movie command is used to combine all the figures saved in the M file to make an animation/movie and thereafter saving it in .avi format.
animation- This link for the animation has been mentioned below.
conclusion- A practical scenario regarding the functioning of the robotic arm and its workspace has been experienced by simulatiing the forward kinematics with a program in matlab