Challenge

Week 2- 2R Robotic Arm Challenge

clear all (it is used to clear variables from the work space)

close all(it is used to clear workspace and closes all figures)

clc(clears all the text from the command window)

linspace(generates linearly spaced values between the given points)

for loop(it is used to execute the given values one by one,or else the function repeats continusoly untill we give end)

plot(it is used the plot the given x and y values on the co ordinate system)

axis(specifies the current limits for the axis)

pause(temporarily stops matlab execution and waits user to press any key)

hold on (retains plots in current axis so that the new plots added to the axis do not delete the existing plots)

getframe (captures the current axes as it apperas on the screen has a movie frame)

open videofile (opens the video )

close videofile(closes the video)

movie (plays the movie )

writevideo(writes data from an array to the video file assosiated with v , you must call open video to write video command)

ERRORS FACED WHILE PROGRAMMING

1. I faced a lot of errors by taking the wrong inputs in the places of l1 and l2.

2. while creating movie you need to open and close videofile otherwise movie doesnt execute.

STEPS TAKEN TO OVERCOME

1. take inputs clearly so that errors doesnt happen.

2. Listen to the lecutres very keenly so that errors dont happen even five seconds of distraction can make the programme error.

clear all
close all
clc

% inputs
L1 = 1;
L2 = 0.5;


theta1 = linspace(0,90,6);
theta2 = linspace(0,90,6);

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);

% plotting


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('robot1.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.