Documente Academic
Documente Profesional
Documente Cultură
Arm Challenge
NOVEMBER 8
1
Code
clear all
close all
clc
l1=10;
l2=5;
x0=0;
y0=0;
alpha=linspace(0,90,10);
beta=linspace(0,90,10);
a=1;
for i=1:length(alpha);
Alpha=alpha(i);
x1=x0+l1*cosd(Alpha);
y1=y0+l1*sind(Alpha);
for j=1:length(beta);
Beta=beta(j);
x2=x1+l2*cosd(Beta);
y2=y1+l2*sind(Beta);
2
end
end
movie(M)
Videofile=VideoWriter('forward_kinematics_challenge.mp4'
,'MPEG-4');
open(Videofile)
writeVideo(Videofile,M)
close(Videofile)
Link to video:-
This is the link to the video https://youtu.be/lcej2NxUA5s
Code Explanation
• Link sizes
• Starting coordinates
• Angle of link #1 "l1" with the base line(y-axis) is alpha
• Angle of link #2 "l2" with the base line(y-axis) is beta
3
4
Errors Explanation & Correction
1-
5
• Plotting not done as expected So after getting to know the errors I figured
out that a variable must be named differently to refer to angles alpha and
beta because MATLAB had only recognized alpha and beta as arrays.
6
7
2-
• Respective indexes “I” and “j” were written on the line other then the “for”
loop. It was corrected by starting the indexes from the same line.
8
3-
• Plotting was being done after all the loops were done. Therefore, it was
corrected using plot in the nested “for” loop.
9
4-
10
5-
• Video was not being written because format of the “open” for opening the
desired file was not right. Equal “=” sign was removed and replaced by the
parenthesis to rectify the error.
11