Challenge

Week 2- 2R Robotic Arm Challenge

clear
clc
%% Robotic arm
% Lengthof first arm
L1=1;
% Length of second arm
L2=0.5;
%%Base end position of First arm
x0=0;y0=0;
i=1;
for theta1=0:5:90
for theta2=0:5:90
%% position of upper end of 1st arm
x1=x0+L1*cosd(theta1);
y1=y0+L1*sind(theta1);
%%position of the upper end of 2nd arm
x2=x1+L2*cosd(theta2);
y2=y1+L2*sind(theta2);
plot([x0 x1],[y0 y1],'r','linewidth',3)
axis([-0.5 1.75 0 1.75])
%% Setting the aspect ratio for the axis
daspect([1 1 1])
hold on
plot ([x1 x2],[y1,y2],'b','linewidth',3)
anim(i)=getframe;
hold off
i=i+1;
end
end
%% creating a movie
movie(anim)
videofile= VideoWriter('Forward kinematics.avi')
%%Creating a video file& adding the movie in it
open(videofile)
writeVideo(videofile,anim)
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.