Challenge

Week 2- 2R Robotic Arm Challenge

Theta1 Is link of robot arm

Theta2 is link 2 of robot arm

Length of link1 is L1

Length of link 2 is L2

clear all

close all

clc

% Inputs

L1 = 1;

L2 = 0.5;

theta1 = linspace(0,90,20);

theta2 = linspace(0,90,20);

ct = 1;

for i = 1:length(theta1)

THETA1 = theta1(i);

for j=1:length(theta2)

THETA2= theta2(j);

X0=0;

Y0=0;

X1=L1*cosd(THETA1);

Y1=L1*sind(THETA1);

X2=X1+L2+cosd(THETA2);

Y2=Y1+L2+sind(THETA2);

%Ploting

plot([X0 X1],[Y0 Y1],[X1 X2],[Y1 Y2],'linewidth',4)

axis([-1 2 0 2])

pause(0.02)

M(ct)=getframe(gcf);

ct=ct+1;

end

end

movie(M)

videofile = videowriter('forward_k.avi','uncompressed AVI');

open(videofile)

writevideo(videofile,M)

close(videofile);

Line command can be sued to visualise the links

For loop is used to change the values and run the program again and again

Linewidth command is to change the width of line in plot is to save

Getframe(cgf) is save figure

clear all
close all
clc

% Inputs

L1 = 1;
L2 = 0.5;
theta1 = linspace(0,90,20);
theta2 = linspace(0,90,20);
ct = 1;
for i = 1:length(theta1)
    THETA1 = theta1(i);
    for j=1:length(theta2)
        THETA2= theta2(j);
        X0=0;
Y0=0;

X1=L1*cosd(THETA1);
Y1=L1*sind(THETA1);

X2=X1+L2+cosd(THETA2);
Y2=Y1+L2+sind(THETA2);

%Ploting

plot([X0 X1],[Y0 Y1],[X1 X2],[Y1 Y2],'linewidth',4)
axis([-1 2 0 2])
pause(0.02)
M(ct)=getframe(gcf); 
 ct=ct+1;

    end
end

movie(M)
videofile = videowriter('forward_k.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.