Advertisement
Guest User

Untitled

a guest
Feb 17th, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 1.38 KB | None | 0 0
  1. theta = [0 0 0 0 0 0]; %input theta values to verfiy
  2. theta = theta.*(pi/180); %converting from degrees to radians
  3. dh=[
  4.     theta(1)      290  0   -pi/2;
  5.     -pi/2         0    0    0;
  6.     theta(2)      0    270  0;
  7.     theta(3)      0    70  -pi/2;
  8.     theta(4)      302  0    pi/2;
  9.     theta(5)      0    0   -pi/2;
  10.     theta(6)      72   0    0;
  11.     ]; %inputing dh table values into matrix form
  12.  
  13.  
  14. A=cell(1,length(dh)); %indexing values from array for different n values
  15. for n=1:length(dh)
  16.     A{n} = [
  17.         cos(dh(n,1))    -cos(dh(n,4))*sin(dh(n,1))      sin(dh(n,4))*sin(dh(n,1))   dh(n,3)*cos(dh(n,1));
  18.         sin(dh(n,1))     cos(dh(n,4))*cos(dh(n,1))     -sin(dh(n,4))*cos(dh(n,1))   dh(n,3)*sin(dh(n,1));
  19.         0                sin(dh(n,4))                   cos(dh(n,4))                dh(n,2);
  20.         0                0                              0                           1];
  21. end
  22.  
  23.  
  24. %Transformation Matrices
  25. % A1=A{1}
  26. % A2=A{2}
  27. % A3=A{3}
  28. % A4=A{4}
  29. % A5=A{5}
  30. % A6=A{6}
  31. % A7=A{7}
  32.  
  33.  
  34. %Final Transformation Matrix
  35. A_t = A{1}*A{2}*A{3}*A{4}*A{5}*A{6}*A{7}
  36. %A_t (A_t<0.001 & A_t>-0.001) = 0;
  37.  
  38.  
  39. %Quaternion Calculations
  40. Q1=0.5*sqrt(A_t(1,1)+A_t(2,2)+A_t(3,3)+1)
  41. Q2=0.5*sqrt(A_t(1,1)-A_t(2,2)-A_t(3,3)+1)*sign(A_t(3,2)-A_t(2,3))
  42. Q3=0.5*sqrt(-A_t(1,1)+A_t(2,2)-A_t(3,3)+1)*sign(A_t(1,3)-A_t(3,1))
  43. Q4=0.5*sqrt(-A_t(1,1)-A_t(2,2)+A_t(3,3)+1)*sign(A_t(2,1)-A_t(1,2))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement