Week 2- 2R Robotic Arm Challenge
Aim-Simulation of forward kinematic of 2R robotic arm.
Governing Equation- x1=l1*cosd(THETA1) and x2=x1+l2*cosd(THETA2) These are the equations used to find vertical and horizonatal components of that theta.
Objective- Animation of forward kinematic of 2R robotic arm.Maximum reach of robot we can see through animation.
Body Content-We have taken inputs for the Lenght of both links.after that we have taken intial condition that are 0,0.We have have created array of 10 points between 0 to 90 degree angle.With the help of for loop we have taken valvue for l1 inside that we have taken another for loop for l2 axis so that we can find out various positions of l2 at one postion of l1.with help of this we have calculated the stage 1 and stage 2 points for l1 and l2.we have plotted the graph and given the axis range with pause of 0.2 sec so we can able to see the ploting.
For movie we have taken the M array for storing the each frame after that created the AVI file for movie and given the name.
Conclusion - We can see through movie Maximum reach of 2r robotic arm.Screen shot also provided here and For movie youtube link provided.
%Forward kinematics
close all
clear all
clc
%inputs
l1=1;
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);
%Inntial stage
x0=0;
y0=0;
%Firststage
x1=l1*cosd(THETA1);
y1=l1*sind(THETA1);
%second stage
x2= x1+l2*cosd(THETA2);
y2=y1+l2*sind(THETA2);
%Plotting
plot([x0 x1],[y0 y1],[x1 x2],[y1 y2],'linewidth',3);
axis([-0.1 1.5,0 1.5]);
pause(0.2);
%Making array for movie
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)
