My code is not running and i do not know what the problem is.

%Link lengths
L1 = 75;
L2 = 130;
L3 = 125;
L4 = 60;
L5 = 130;
%D-H parameter of the robot
L(1) = Link ([0 L1 0 -pi/2]);
Unrecognized function or variable 'Link'.
L(2) = Link ([0 0 L2 0]);
L(3) = Link ([0 0 L3 0]);
L(4) = Link ([0 0 0 pi/2]);
L(5) = Link ([0 L4+L5 0 0]);
%defining the rotation limits of the links
Q1_Min = 0;
Q1_Max = pi;
Q2_Min = (1/12)*pi;
Q2_Max = (11/12)*pi;
Q3_Min = 0;
Q3_Max = pi;
Q4_Min = 0;
Q4_Max = pi;
Q5_Min = 0;
Q5_Max = pi;
L(1).qlim=[Q1_Min Q1_Max];
L(2).qlim=[Q2_Min Q2_Max];
L(3).qlim=[Q3_Min Q3_Max];
L(4).qlim=[Q4_Min Q4_Max];
L(5).qlim=[Q5_Min Q5_Max];
Kelvin_Assignment = SerialLink(L, 'name', 'Kelvin_Assignment');
title ('workspace of Kelvin Assignment');
%homogenous
syms th1 th2 th3 th4 th5;
syms alhpa1 alpha2 alpha3 alpha4 alpha5;
syms d1 d2 d3 d4 d5;
syms a1 a2 a3 a4 a5;
T01 = [cos(th1) -cos(th1)*sin(th1) sin(alpha1)*sin(th1) a1*cos(th1);
sin(th1) cos(alpha1)*cos(th1) -sin(alpha1)*cos(th1) a1*sin(th1);
0 sin(alpha1) cos(alpha1) d1;
0 0 0 1];
T12 = [cos(th2) -cos(alpha2)*sin(th2) sin(alpha2)*sin(th2) a2*cos(th2);
sin(th2) cos(alpha2)*cos(th2) -sin(alpha2)*cos(th2) a2*sin(th2);
0 sin(alpha2) cos(alpha2) d2;
0 0 0 1];
T23 = [cos(th3) -cos(alpha3)*sin(th3) sin(alpha3)*sin(th3) a3*cos(th3);
sin(th3) cos(alpha3)*cos(th3) -sin(alpha3)*cos(th3) a3*sin(th3);
0 sin(alpha3) cos(alpha3) d3;
0 0 0 1];
T34 = [cos(th4) -cos(alpha4)*sin(th4) sin(alpha4)*sin(th4) a4*cos(th4);
sin(th4) cos(alpha4)*cos(th4) -sin(alpha4)*cos(th4) a4*sin(th4);
0 sin(alpha3) cos(alpha3) d4;
0 0 0 1];
T45 = [cos(th5) -cos(alpha5)*sin(th5) sin(alpha5)*sin(th5) a5*cos(th5);
sin(th5) cos(alpha5)*cos(th5) -sin(alpha5)*cos(th5) a5*sin(th5);
0 sin(alpha5) cos(alpha5) d5;
0 0 0 1];
T05 = T01*T12*T23*T34*T45;
%for the second coordinate
Q1 = 0;
Q2 = 0;
Q3 = 0;
Q4 = pi/2;
Q5 = 0;
%substituting the values of q1,q2,q3 and remembering thsat th1=Q1, th2=Q2
T05_Equations = double(subs(T05, [th1 th2 th3 th4 th5 alpha1 alpha2 alpha3 alpha4 alpha5 a1 a2 a3 a4 a5 d2 d3 d4 d5], ...
[0 0 0 0 0 -pi/2 0 0 0 pi/2 0 130 125 0 0 75 0 0 0 190]));
x_Equations = T05_Equations(1,4);
y_Equations = T05_Equations(2,4);
z_Equations = T05_Equations(3,4);
T05_Equations_SE3 = SE3(T05_Equations);
T05_Fkine_SE3 = Kelvin_Assignment.fkine([Q1 Q2 Q3 Q4 Q5]);
T05_fkine = double(Kelvin_Assignment.fkine([Q1 Q2 Q3 Q4 Q5]));
X_fkine = T05_fkine(1,4);
y_fkine = T05_fkine(2,4);
z_fkine = T05_fkine(3,4);

2 Comments

Thanks for your response. the error below is what i am observing. PLs how di i fix it because i really dont know what the problem is with it at this time.
Unrecognized function or variable 'alpha1'.
Error in homoginustransformation (line 41)
T01 = [cos(th1) -cos(th1)*sin(th1) sin(alpha1)*sin(th1) a1*cos(th1);

Sign in to comment.

 Accepted Answer

There is a typo while defining the variable alpha1.
syms alhpa1
Correct it and you should be good to go. (I assume you have the Peter Corke Robotics Toolbox installed.)

2 Comments

that is the problem i am having. i cant see anything wrong with the code, i have checked again and again and i really dont know what the issues are. and yes i have peter Corke toolbox installed. Can you pls check the above code, maybe you will see what i am not seeing becase i haved checked again and again
I mentioned that there is a typo in the definition of alpha1. Spelling mistake.
syms alhpa1 alpha2 alpha3 alpha4 alpha5;
% ^here

Sign in to comment.

More Answers (0)

Products

Release

R2023a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!