Challenge

Week 2- 2R Robotic Arm Challenge

Robotic Arm work

close all
clear all
clc

%inputs
%length of link 1 and 2
l1 = 1;
l2 = 0.3;
%arm angle 1 and 2
%here we are using linspace to store the value of theta1 and theta2 to
%store random value of 20 in between angle 0 to 90.
theta1 = linspace(0,90,20);
theta2 = linspace(0,90,20);

% this is a loop counter ct-1 where it means start from 1
ct=1;
for i = 1:length(theta1)
% here i is variable that store theta start from 1 to 20 cause we store
% 20 values in theta1
THETA1 = theta1(i);
%here THETA1 is a variable use loop counter store one value in i every
%time loops run
for j = 1:length(theta2)
% here j is variable that store theta start from 1 to 20 cause we store
% 20 values in theta2
THETA2 = theta2(j);
%here THETA2 is a variable use loop counter store one value in j every
%time loops run
x0 = 0; %x coordinate of base
y0 = 0; %ycoordinate of base
%coordinate of points x1,y1

x1 = l1*cosd(THETA1);
y1 = l1*sind(THETA1);

%coordinates of points x2,y2

x2 = x1 + l2*cosd(THETA2);
y2 = y1 + l2*sind(THETA2);

%plotting graph
plot([x0 x1],[y0 y1],[x1 x2],[y1 y2],'linewidth',3)
%here we plot the graph of links where its co-ordinate lies in between x0
%y0 is the base than the x1 y1 is first joint of link 1 than x2 y2 is the
%free arm of robot
axis([-0.1 1.5 0 1.5]);
%here we define axis
pause(0.001);
% here we define the speed of frame of robot moving from one point to
% another
M(ct) = getframe(gcf);
% now we create a variable M to record frame we getting in every figure
ct = ct+1;
% here is the counter ct+1 to move ahead till the angles we get

end
end
movie(M)
%creation of movie in variable M
videofile = VideoWriter('robotics_arm.avi','Uncompressed AVI');
%create video file and writing it in uncompressed form of avi
open(videofile)
%opening this videofile
writeVideo(videofile,M)
%now writting the video file in M
close(videofile)
%close

Error_and_difficulties (screenshot(6).png)

I was getting error of unreconised files WriteVideo than i realise by surfing in matlab its not the builtin function to write video after that i change it to writeVideo(videofile,m)

its start to work perfectly

final result in screenshot(7).png

code completion in screenshot(8).png

video link - https://youtu.be/kC_Nk4uXnIQ

drive link - https://drive.google.com/file/d/17e8EgVeyyYuv9wij_BoScnoLoWgUxUH8/view?usp=sharing

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.