Week 2- 2R Robotic Arm Challenge
During starting of the program
Program running video link provide in youtube https://youtu.be/OyHhTozpRU8
clear, close, clc commands are used
step 1 : add input such as length l1 and l2 ;
step 2 : add angle of the link theta 1,2 to attend multiple value of theta i have used linspace commands
step 3 : add the counter value for the program to repeat multiple sequence.
step 4: For the loop operation i and j are used where as i = 1: length(theta1) ; j = 1:length (theta2)
step5 : Giving the value of the coordinate of x0,y0,x1,y1,x2,y2
step6 : using the plot command coordinate are been plotted and sequence spped is set to 0.11
step7: saving the file in video format and run it
Error occured
during the axis first i change the value in (-0.25,-0.1,0,0.1,0.25) , then i rectified the mistakes
during save the video command got an issue in lower case and then i changed into upper case then got it correctly.
%forward kinematics of 2R robotic arm motion
clear all
close all
clc
%Inputs
l1 = 1;
l2 = 0.5;
theta1 = linspace(0,90,10);
theta2 = linspace(0,90,10);
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(THETA2);
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.03)
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)