Challenge

Week 2- 2R Robotic Arm Challenge

% Forward kinematic of 2R robotic arm challenge

% Inputs

l1 = 1;
l2 = 0.5;
theta1 = linspace(0,90,10);
theta2 = linspace(0,90,10);

%linspace command gives direct control over the number of points
%and always includes the endpoints
%0 is starting point,90 is endpoint and 10 is the amount of interval
%between them

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.1);
M(ct) = getframe(gcf);
ct = ct+1;
end
end

% For loop is used above, Hence for every value of 'i' all of the value of
% 'j' will be repeated
%Pause command is used to pause the plot at every 0.1 sec so it can be tun
%smoothly
%Movie commad is used to creat a vedio of showing the plot moving in
%forwared kinematic 2R motion

movie(M)
videofile = VideoWriter('forward_robotic_arm_motion.avi','Uncompressed AVI');
open(videofile)
writeVideo(videofile,M)
close(videofile)

%Video file is created and its named 'forward_robotic_arm_motion.avi'
%open(videofile) command is used to open the video
%Close(videofile) command is use to close the vedio

%Drive link for the forward kinematic robotic arm vedio given below

https://drive.google.com/file/d/1UWWBxWixBSVfOs3jOwzHcecRlXpjGBjc/view?usp=sharing

% Error faced

1) There was some spelling mistake during movie creation which was later corrected

2)Forgot to put 1: in the equation which led to incorrect ploting

3)Forgot to put d after sin and cos, d represent degree because of its absence the plot was wrong

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.