Challenge

Week 2- 2R Robotic Arm Challenge

Program in Matlab to simulate the forward kinematics of a 2R Robotic Arm

%Input parameters

% l1=length of first link in robotic arm

%l2=length of second link of robotic arm

%theta1=angle made by base and link1 of robotic arm

%theta2=angle made by horrizondal axis in base of link 2 starts and the link2 of robotic arm

l1=4;

l2=3;

theta1=linspace(0,90,40);

theta2=linspace(0,90,40);

ct=1; % contour

%applying for loop to each value of theta1 and theta2

for i=1:length(theta1)

THETA1=theta1(i)

for j=1:length(theta2)

THETA2=theta2(j)

%the coordinates are

x0=0;

y0=0;

x1=l1*cosd(THETA1);

y1=l1*sind(THETA1);

x2=x1+l2*cosd(THETA2);

y2=y1+l2*sind(THETA2);

%plotting with the coordinates with a linewidth2

plot([x0 x1],[y0 y1],[x1 x2],[y1 y2],'linewidth',2)

axis([-0.1 8 -0.1 8])

pause(0.1)

m(ct)=getframe(gcf);

ct=ct+1

end

end

%to create a video filein AVI

movie(m)

videofile=videoWriter('forward kinematics of 2R robotic arm','un compressed AVI');

open(videofile)

writeVideo(videofile,m)

close(videofile)

% NOTE

I HAVE DONE THIS PROGRAM FOLLOWING THE AUTHORS VIDEO WITH MY OWN VALUES, NO ERRORS ARE DETECTED SINCE I HAVE DONE IT VERY CAREFULLY FOLLOWING THE AUTHOR, SO THE SCREENSHOT OF ERROR IN COMMAMD WINDOW IS NOT ATTACHING WITH THIS,SINCE I DOESN'T HAVE AN ERROR THOUGH

THE UPLOADED VIDEO IN YOUTUBE IS ATTACHING HERE : https://youtu.be/NO3Y984H67w

https://youtu.be/NO3Y984H67w

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.