Week 3.2 - 2R Robotic Arm Challenge
https://youtu.be/yKcOOmCAd4c .... here is the link for my youtube video to the output of this challenge!!!
here I forgot to write one 'end' of for loop, but it was easy to overcome this problem, because command window shows me where is the problem
and here I did mistake in plotting in assigning coordinates.
% as a first step I defined inputs of roboter arms
l1 = 1;
l2 = 0.5;
%after that I defined my angles of these arms using linspace command in order to have angles in gradually changing order
theta_1 = linspace(0,90,10);
theta_2 = linspace(0,90,10);
%as a next step, I used for loop to assign every element of theta_1 array to THETA1 and respetively second for loop of 2nd angle to THETA2 so that we can later use these angles in our calculation
ct = 1;
for i = 1 : length(theta_1)
THETA1 = theta_1(i);
for j = 1 : length(theta_2)
THETA2 = theta_2(j);
%after that I defined my initial points of first arm
x0 = 0;
y0 = 0;
%and the final coordinates of first arm using calculation with cos and sin
x1 = l1 * cosd(THETA1);
y1 = l1 * sind(THETA1);
%and also final coordinates of second arm, initial coordinates of 2nd we already have, because it is connected to 1st arm
x2 = x1 + l2 * cosd(THETA2);
y2 = y1 + l2 * sind(THETA2);
%here I did plottting of these two arms gradually changing with respect to angles with the help of pause command
plot([x0 x1],[y0 y1],[x1 x2],[y1 y2],'linewidth',3)
axis(-0.1 1.5 0 1.5)
pause(0.3)
%and finally in order to animate how the position of two arms changes, I wrote M command
M(ct) = getframe(gcf);
ct = ct + 1;
%I used 'ct' so that I could have chaning order of my for loops
end
end
%now I have to exectue required commands to make video of my animation.
movie(M)
videofile = VideoWriter('forward_kinematics',Uncompressed AVI')
open(videofile)
writeVideo(videofile,M)
close(videofile)