Week 2- 2R Robotic Arm Challenge
% Forward kinnematics of 2R Robotic Arm Manupulator
%Inputs
L1=1;-----------------------------------Input for length of Link 1
L2=0.5;----------------------------------Input for length of Link 2
theta1=linspace(0,90,4); ----------------------------------array to have set of 4 values between 0 to 90
theta2=linspace(0,90,4); ----------------------------------array to have set of 4 values between 0 to 90
ct=1; -------------for incremental loop
for i=1:length(theta1) ----------------i= 1:4 (for each vaulue of thetha 1)
THETA1= theta1(i) ---------------------Single variable for thetha 1 (which has 4 values)
for j= 1:length(theta2)-----------------j= 1:4 (for each vaulue of thetha 1)
THETA2= theta2(j) ---------------------Single variable for thetha 2 (which has 4 values)
%Coordinates
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)---------------------------plot
axis([-0.1 1.5 0 1.5])---------------------to change X limits and Y limits
pause(0.03)----------------------------for interval between results
m(ct)= getframe(gcf)------for frame
ct=ct+1; -------------for incremental loop
end
end
movie(m)-------------------to generate movie
videofile=VideoWriter('forward kinamatics.avi','Uncompressed AVI'); to create video and name of file with format
open(videofile) ------------------open video file
writeVideo(videofile,m)--------------write video
close(videofile)----------close video
i have collected snapshot but forgot to save, anyways i can just explain the errors,
VideoWrite - I wrote videowrite
After creating movie still i forgot remove hold on command. but later on i removed since i was getting all the plots in single vindow.