Challenge

Week 2- 2R Robotic Arm Challenge

2R ROBOTIC ARM

The basic working of a 2R Robotic arm is based on the Forward kinematics

for this 2 linked arm and we can name it as

link 1(l1)

link 2(l2)

when we place those link in a graph

thetha1 be the angle between link 1 and its plain

thetha2 be the angle between link 2 and its plain

then link 1 bottom will be (0,0)on aixis

link 1 top and link 2 starting will be at same orgin and it is (x1,y1)

link 2 top will ne at (x2,y2)of axis in graph

we need to calculate postion of link 1 andd link2

x1=l1*cos(thetha1)

y1=l1*sin(thetha1)

x2=x1+l2*cos(thetha2)

y2=y1+l2*sin(thetha2)

then the solution set will be

[x0,y0] [x1,y1] [x2,y2]

during this we will only get an a single lined graph representation

for getting more value we will assing an array for thetha1 and thetha2 by help of linespace command in Matlab

tetha1=linespace(0,90,10)

in the above comment tetha1 will have the values in between 0-90 and have a equal interval of time as mention above is 10

as same the thetha2 value also assinged

after that we make a conditional statmented with help of for loop

and assing new value for THETHA1 and THETA2

then we will give the value of THETHA1 and THETHA2 in above mentioned equation of x1,y1,x2andy2

then we will get number of values for and x1,y1,x2andy2

then we can plot our graph using plot command

plot([x0 x1],[y0 y1],[x1 x2],[y1 y2]

we can assing that the value of x axis and y axis should be in between some values as

axis([-0.1 1.5 0 1.5])

then when we run the program we will get graph of 16 diffrent layers for getting them as a animation we are giving time interval and all

pause(0.03)

this animation we will assing to a variable with help of getframe(gcf)comment

then we will end our for loop and exicute we will get an graphical animation

for saving it in video file we can use movie comment and we can assing the value m to it

then save the video file as per the video formate with help of videoWriter cammond

HERE THE OUTPUT ANIMATED VIDEOS YOUTUBE LINK

https://youtu.be/gqTMFlwdn3g

%forward kinematics of robortic arm

clear all
close all
clc

%input

thetha1=linspace(0,90,10);
thetha2=linspace(0,90,10);
l1=1;
l2=0.5;
ct=1

for i=1:length(thetha1)
    THETHA1=thetha1(i);
for j=1:length(thetha2)
    THETHA2=thetha2(j);
    x0=0;
    y0=0;
    
    x1=l1.*cosd(THETHA1)
    y1=l1.*sind(THETHA1)
    
    x2=x1+l2.*cosd(THETHA2)
    y2=y1+l2.*sind(THETHA2)
 
%ploting

plot([x0 x1],[y0 y1],[x1 x2],[y1 y2],'linewidth',3)
axis([-0.1 1.5 0 1.5])
pause(0.03)
M(ct)=getframe(gcf);
ct=ct+1;
end
end
 movie(M)
videofile=VideoWriter('challenge_5.avi','Uncompressed AVI');
open(videofile)
writeVideo(videofile,M)
close(videofile)


Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.