https://youtu.be/HlloDUi420c
clear all
close all
clc
% inputs
L1= 1;
L2=0.6;
theta1=45;
theta2=40;
% coordinates
x0=0;
y0=0;
x1=L1*cosd(theta1);
y1=L1*sind(theta1);
x2=x1+L2*cosd(theta2);
y2=y1+L2*sind(theta2);
% plotting
line([x0 x1],[y0 y1],'linewidth',3,'color','b');
line([x1 x2],[y1 y2],'linewidth',3,'color','r');
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(THETA1);
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)
STEPWISE EXPLANATION
* calculate the position of linl 1 and 2.
* take the length of l1 and l2.
* take the theta1 and theta2.
* take the coordinates. x0 y0 base of robot.
* theta should specified in degrees.
* determine the end point link2. x2 y2
* lets take the inline command.
* list of x coordinates and y coordinates for 2 link.
* open new file. its objective is to take multiple values of theta1 and theta2.
* for each value of theta1 and theta2 to make a plot and creating plot to combine to
make animation.
* linspace command is introduced to take the multiple values.
* to change the values of theta1 and theta2 for that the loop is used.
* for loop is is used to take particular values for theta1 and theta2.
* plot all the described coordinates.
* axis is fixed to performed.
* command to form movie.
* described videofile and videowriter.
* close the videofile.
MENTION ERROR AND STEP TAKEN TO OVERCOME THOSE ERRORS.
* error is occured for not giving same brackets from both sides. after applying brackets from both sides error is resolved.
* error found in loop file. in loop file forgot to type the end in loop file. after applying error is fixed.
* error is found in to perform getframe. there is typing mistake there is given space in between 'get frame' after coorection of typing 'getframe' the error is fixed.
* error of unrecognized during videofile and videowriter.
given the proper name for the videowriter after given specific name the error is
fixed.