Challenge

Week 2- 2R Robotic Arm Challenge

report:

  1. First i separated the coding into two parts- 1. static part 2.animation part
  2. In static part i just program for static plot without animation in separate folder
  3. And why do separate folder because to alling the proper arrangement of coding and see the difference to understand clearly
  4. In animation part i have made a mistake, that when start the for loop i have forgotten to finish with 'end' command
  5. The major error in animation part is placing the axis command in right place, it takes time to find out that mistake
  6. That axis command should always under the plot command, but what i did is
  7. So when I did this axis also changing, after i found the mistake and fixed it.

%program for forward kinematics of 2r robotic arm

% static part
theta1 = 45
theta2 = 30
l1 = 2
l2 = 1.5
x0 = 0
y0 = 0
x1 = l1*cosd(theta1);
y1 = l1*sind(theta1);
x2 = x1+l2*cosd(theta2);
y2 = y1+l2*sind(theta2);
% plot
plot([x0 x1],[y0 y1],[x1 x2],[y1 y2],'linewidth',3)
%then i open the new folder for animation and save the movie
% animation
close all
clear all
clc
theta1 = linspace(0,90,10);
theta2 = linspace(0,90,10);
l1 = 2
l2 = 1.5
x0 = 0
y0 = 0
u =1
for i = 1:length(theta1)
tda1 = theta1(i);
for j = 1:length(theta2)
tda2 = theta2(j);
x1 = l1*cosd(tda1);
y1 = l1*sind(tda1);
x2 = x1+l2*cosd(tda2);
y2 = y1+l2*sind(tda2);
% plot
plot([x0 x1],[y0 y1],[x1 x2],[y1 y2],'linewidth',3)
axis([0 4 0 4])
pause(0.2)
f(u) = getframe(gcf)
u = u+1
end
end
movie(f)
myflim = VideoWriter('animationflim','Uncompressed AVI');
open(myflim)
writeVideo(myflim,f)
close(myflim)
% my saved video---https://youtu.be/RMMCfr4ivP0
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.