Week 3.2 - 2R Robotic Arm Challenge
Code:-
clear
close
clc
%% Week 3.2 - 2R Robotic Arm Challenge
%% Inputs
l1=0.8;
l2=0.6;
theta1 = linspace(0,45,10);
theta2 = linspace(0,90,10);
%%theta1 = 45;
%%theta2 = 30;
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 + l1 * cosd(Theta2);
y2= y1 + l2 * sind(Theta2);
%% Calculation of position
%%Plotting
figure(1)
plot([x0 x1],[y0 y1],[x1 x2],[y1 y2],'linewidth',2.5);
axis([0 2 0 2])
grid on
pause(0.05)
M(ct) = getframe(gcf);
ct = ct+1;
end
end
movie(M)
videofile = VideoWriter('forward_kinematics.avi','uncompressed Avi');
open(videofile)
writeVideo(videofile,M)
close(videofile)
Video Link to see animation-
https://we.tl/t-U9LGymHP3v
Report:
Step-wise explanation of your code:-
1) Inputs are considered & declared i.e length of the link 1(l1) & length of link 2(l2) ; Angle of link rotation are deifned using linspace.
2) By using nested loop ensured the repetion of the code
3) Predefined the value of codinates as position of the link 1 & link 2 as X0,y0,x1,y1 & x2 ,y2 using trigometric relations as we have known the initial position & angle of rotation
4) Using plotting , plot the results & ensured the video of animation using video editor commands
Mention the errors faced while programming.
1) Commands using Nested loop to define the repeated Value of I & J
2) To define Video Editor command correctly
3) Downloading video of Animation
Steps taken to overcome those errors.
1) Used the notes and watched videos repeatedly
2) Used Debugging
3) Used online Matalb demo for how to download the videos