function DH_MatrixTest2(LN);
syms L6 L4
L4=4; L6=0.5; L5=3.5;
%This inputs the form of
[Nx,Ox,Ax,Px;Ny,Oy,Ay,Py;Nz,Oz,Az,Pz;0,0,0,1] into
%the function->
DH_MatrixTest(([Nx,Ox,Ax,Px;Ny,Oy,Ay,Py;Nz,Oz,Az]))
Nx=(LN(1,1));
Ny(LN(1,2));
Nz(LN(1,3));
Ox(LN(1,4));
Oy(LN(1,5));
Oz=(LN(1,6));
Ax=(LN(1,7));
Ay=(LN(1,8));
Az=(LN(1,9));
Px=(LN(1,10));
Py=(LN(1,11));
Pz=(LN(1,12));
T_matrix=[Nx,Ox,Ax,Px; Ny,Oy,Ay,Py; Nz,Oz,Az,Pz;
0,0,0,1]
%display the original T %matrix
theta1=(atan2d(Py,Px))
% theta1=theta1 + pi
theta234=(atan2d(Az,Ax*cosd(theta1)+Ay*sind(theta1)))
%display theta234
%theta234=theta234 + pi
C3=((Px*cosd(theta1)+Py*sind(theta1)-cosd(theta234)*L6)^2
+(Pz-sind(theta234))^2 -L4^2 - L5^2)/(2*L4*L5) %display C3
S3=(1-C3^2)^.5
%display S3
theta3=atan2d(S3,C3)
%display theta3
%display theta2 below:
theta2=atan2d(((C3*L5+L4)*(Pz-sind(theta234)*L6) -
S3*L5*(Px*cosd(theta1)+Py*sind(theta1) - cosd(theta234)*L6)),
((C3*L5+L4)*(Px*cosd(theta1)+Py*sind(theta1) - cosd(theta234)*L6) +
S3*L5*(Pz-sind(theta234)*L6)))
%display theta4 below:
theta4=theta234-theta2-theta3
%display theta5 below:
theta5=atan2d((cosd(theta234)*(cosd(theta1)*Ax +
sind(theta1)*Ay)+sind(theta234)*Az),(sind(theta1)*Ax -
cosd(theta1)*Ay))
%display theta6 below:
theta6=atan2d((-sind(theta234)*(cosd(theta1)*Nx +
sind(theta1)*Ny)+cosd(theta234)*Nz),-sind(theta234)*(cosd(theta1)*Ox
+ sind(theta1)*Oy)+cosd(theta234)*Oz)
%display the UTH matrix from obtaining all thetas
UTH_matrix=[cosd(theta1)*(cosd(theta234)*cosd(theta5)*cosd(theta6)
- sind(theta234)*sind(theta6)) -
sind(theta1)*sind(theta5)*cosd(theta6),
cosd(theta1)*((-cosd(theta234)*cosd(theta5)*sind(theta6)) -
sind(theta234)*cosd(theta6)) ...
+ sind(theta1)*sind(theta5)*sind(theta6),
cosd(theta1)*(cosd(theta234)*sind(theta5))+
sind(theta1)*cosd(theta5), cosd(theta1)*(cosd(theta234)*L6 +
cosd(theta2+theta3)*L5 + cosd(theta2)*L4);...
sind(theta1)*(cosd(theta234)*cosd(theta5)*cosd(theta6) -
sind(theta234)*sind(theta6)) +
cosd(theta1)*sind(theta5)*cosd(theta6), ...
sind(theta1)*((-cosd(theta234)*cosd(theta5)*sind(theta6)) -
sind(theta234)*cosd(theta6)) -
cosd(theta1)*sind(theta5)*sind(theta6),...
sind(theta1)*(cosd(theta234)*sind(theta5)) -
cosd(theta1)*cosd(theta5), sind(theta1)*(cosd(theta234)*L6 +
cosd(theta2+theta3)*L5 + cosd(theta2)*L4);...
sind(theta234)*cosd(theta5)*cosd(theta6) +
cosd(theta234)*sind(theta6),
-sind(theta234)*cosd(theta5)*sind(theta6)+cosd(theta234)*cosd(theta6),
sind(theta234)*sind(theta5), ...
sind(theta234)*L6 + sind(theta2+theta3)*L5 +
sind(theta2)*L4; 0,0,0,1]
%display the UTH matrix after rounding:
%We note that the UTH matrix should be the same as the T matrix
displayed
%at the beginning of the code.
UTH_matrix=round(UTH_matrix);
x1=(cosd(theta1)*(cosd(theta234)*L6 + cosd(theta2+theta3)*L5 +
cosd(theta2)*L4));
y1=(sind(theta1)*(cosd(theta234)*L6 + cosd(theta2+theta3)*L5 +
cosd(theta2)*L4));
z1=(sind(theta234)*L6 + sind(theta2+theta3)*L5 +
sind(theta2)*L4);
z=0:0.02:1;
z1=z1+z;
plot3(x1,y1,z1-1,'*')
grid on;
txt1=' Point A ';
text(1,6,4,txt1);
txt2=' Point B';
text(1,6,5+0.1,txt2);
xlabel('x-axis');
ylabel('y-axis');
zlabel('z-axis');
title('Ideal Trajectory Path of point A to point B of 6-DOF
Manipulator');
WHEN I AM TRYING TO RUN IT I GET
THIS ERROR CAN ANYONE SOLVE IT PLEASE!
it is the function that i calling in the top
function DH_MatrixTest2(LN); THIS ONE
i created it function to Trajectory Path of point A to point B of 6-DOF Manipulator
but it doenst work , when i use it here , it give error i think because i am sending two parameters but i dont know how can i fix it .
i need this Nx=(LN(1,1)); i need to change those in order to make it works
%This inputs the form of
[Nx,Ox,Ax,Px;Ny,Oy,Ay,Py;Nz,Oz,Az,Pz;0,0,0,1] into
%the function->
DH_MatrixTest(([Nx,Ox,Ax,Px;Ny,Oy,Ay,Py;Nz,Oz,Az]))
Nx=(LN(1,1));
Ny(LN(1,2));
Nz(LN(1,3));
Ox(LN(1,4));
Oy(LN(1,5));
Oz=(LN(1,6));
Ax=(LN(1,7));
Ay=(LN(1,8));
Az=(LN(1,9));
Px=(LN(1,10));
Py=(LN(1,11));
Pz=(LN(1,12));
function DH_MatrixTest2(LN);
syms L6 L4
L4=4; L6=0.5; L5=3.5;
%This inputs the form of
[Nx,Ox,Ax,Px;Ny,Oy,Ay,Py;Nz,Oz,Az,Pz;0,0,0,1] into
%the function->
DH_MatrixTest(([Nx,Ox,Ax,Px;Ny,Oy,Ay,Py;Nz,Oz,Az]))
Nx=(LN(1,1));
Ny(LN(1,2));
Nz(LN(1,3));
Ox(LN(1,4));
Oy(LN(1,5));
Oz=(LN(1,6));
Ax=(LN(1,7));
Ay=(LN(1,8));
Az=(LN(1,9));
Px=(LN(1,10));
Py=(LN(1,11));
Pz=(LN(1,12));
T_matrix=[Nx,Ox,Ax,Px; Ny,Oy,Ay,Py; Nz,Oz,Az,Pz; 0,0,0,1]
%display the original T %matrix
theta1=(atan2d(Py,Px))
% theta1=theta1 + pi
theta234=(atan2d(Az,Ax*cosd(theta1)+Ay*sind(theta1))) %display
theta234
%theta234=theta234 + pi
C3=((Px*cosd(theta1)+Py*sind(theta1)-cosd(theta234)*L6)^2
+(Pz-sind(theta234))^2 -L4^2 - L5^2)/(2*L4*L5) %display C3
S3=(1-C3^2)^.5 %display S3
theta3=atan2d(S3,C3) %display theta3
%display theta2 below:
theta2=atan2d(((C3*L5+L4)*(Pz-sind(theta234)*L6) -
S3*L5*(Px*cosd(theta1)+Py*sind(theta1) - cosd(theta234)*L6)),
((C3*L5+L4)*(Px*cosd(theta1)+Py*sind(theta1) - cosd(theta234)*L6) +
S3*L5*(Pz-sind(theta234)*L6)))
%display theta4 below:
theta4=theta234-theta2-theta3
%display theta5 below:
theta5=atan2d((cosd(theta234)*(cosd(theta1)*Ax +
sind(theta1)*Ay)+sind(theta234)*Az),(sind(theta1)*Ax -
cosd(theta1)*Ay))
%display theta6 below:
theta6=atan2d((-sind(theta234)*(cosd(theta1)*Nx +
sind(theta1)*Ny)+cosd(theta234)*Nz),-sind(theta234)*(cosd(theta1)*Ox
+ sind(theta1)*Oy)+cosd(theta234)*Oz)
%display the UTH matrix from obtaining all thetas
UTH_matrix=[cosd(theta1)*(cosd(theta234)*cosd(theta5)*cosd(theta6)
- sind(theta234)*sind(theta6)) -
sind(theta1)*sind(theta5)*cosd(theta6),
cosd(theta1)*((-cosd(theta234)*cosd(theta5)*sind(theta6)) -
sind(theta234)*cosd(theta6)) ...
+ sind(theta1)*sind(theta5)*sind(theta6),
cosd(theta1)*(cosd(theta234)*sind(theta5))+
sind(theta1)*cosd(theta5), cosd(theta1)*(cosd(theta234)*L6 +
cosd(theta2+theta3)*L5 + cosd(theta2)*L4);...
sind(theta1)*(cosd(theta234)*cosd(theta5)*cosd(theta6) -
sind(theta234)*sind(theta6)) +
cosd(theta1)*sind(theta5)*cosd(theta6), ...
sind(theta1)*((-cosd(theta234)*cosd(theta5)*sind(theta6)) -
sind(theta234)*cosd(theta6)) -
cosd(theta1)*sind(theta5)*sind(theta6),...
sind(theta1)*(cosd(theta234)*sind(theta5)) -
cosd(theta1)*cosd(theta5), sind(theta1)*(cosd(theta234)*L6 +
cosd(theta2+theta3)*L5 + cosd(theta2)*L4);...
sind(theta234)*cosd(theta5)*cosd(theta6) +
cosd(theta234)*sind(theta6),
-sind(theta234)*cosd(theta5)*sind(theta6)+cosd(theta234)*cosd(theta6),
sind(theta234)*sind(theta5), ...
sind(theta234)*L6 + sind(theta2+theta3)*L5 + sind(theta2)*L4;
0,0,0,1]
%display the UTH matrix after rounding:
%We note that the UTH matrix should be the same as the T matrix
displayed
%at the beginning of the code.
UTH_matrix=round(UTH_matrix);
x1=(cosd(theta1)*(cosd(theta234)*L6 + cosd(theta2+theta3)*L5 +
cosd(theta2)*L4));
y1=(sind(theta1)*(cosd(theta234)*L6 + cosd(theta2+theta3)*L5 +
cosd(theta2)*L4));
z1=(sind(theta234)*L6 + sind(theta2+theta3)*L5 +
sind(theta2)*L4);
z=0:0.02:1;
z1=z1+z;
plot3(x1,y1,z1-1,'*')
grid on;
txt1=' Point A ';
text(1,6,4,txt1);
txt2=' Point B';
text(1,6,5+0.1,txt2);
xlabel('x-axis');
ylabel('y-axis');
zlabel('z-axis');
title('Ideal Trajectory Path of point A to point B of 6-DOF
Manipulator');
% end of function
When executing the code you are not passing any input to function DH_MatrixTest2, hence it results into an error. Don't Run the function script from the tools, since it accepts input.
Go to command line and run
>> DH_MatrixTest2(<pass the matrix>)
function DH_MatrixTest2(LN); syms L6 L4 L4=4; L6=0.5; L5=3.5; %This inputs the form of [Nx,Ox,Ax,Px;Ny,Oy,Ay,Py;Nz,Oz,Az,Pz;0,0,0,1] into %the...