Advertisement
Guest User

Untitled

a guest
Feb 19th, 2023
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. function cartesian_coords = forward_kinematics(thetas)
  2.  
  3. theta1 = thetas(1);
  4. theta2 = thetas(2);
  5. theta3 = thetas(3);
  6. theta4 = thetas(4);
  7. theta5 = thetas(5);
  8.  
  9. % Transformation matrices
  10. A1 = create_roation_matrix(0,90,10.5,theta1);
  11. A2 = create_roation_matrix(13.5, 0, 0, theta2);
  12. A3 = create_roation_matrix(16, 0, 0, theta3);
  13. A4 = create_roation_matrix(5.5, -90, 0,-(theta2+theta3));
  14. A5 = create_roation_matrix(0, 0, -7, theta5);
  15.  
  16. % Multiply them all together
  17. homogenous_transformation_matrix = A1*A2*A3*A4*A5
  18.  
  19. % Get x,y,z
  20. x = homogenous_transformation_matrix(1,4);
  21. y = homogenous_transformation_matrix(2,4);
  22. z = homogenous_transformation_matrix (3,4);
  23.  
  24. cartesian_coords = [x,y,z];
  25.  
  26. end
  27.  
  28. % Create transformation from dh parameters
  29. % alpha and theta in degrees
  30. % r and d in cms
  31. function A = create_roation_matrix(r, alpha, d, theta)
  32. A = [cos(theta), -sin(theta)*cos(alpha), sin(theta)*sin(alpha), r*cos(theta);
  33. sin(theta), cos(theta)*cos(alpha), -cos(theta)*sin(alpha), r*sin(theta);
  34. 0, sin(alpha), cos(alpha), d;
  35. 0, 0, 0, 1];
  36. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement