% This exercise is relative to the figure in file scara_3D_absolute.png clc clear all close all % Define parameters % ========================================================================= % Lenghts of links l1 = .3; l2 = .4; l3 = .35; l4 = .15; % Absolute angles of joints phi1 = 0.10 * pi; phi2 = 0.50 * pi; % Calculate the position of the joints % ========================================================================= % Set P0 in the origin P0 = [0 ; 0 ; 0]; % Links vectors % Calculate the vector z1 which corresponds to the 1st link, z1 = l1*[0 ; 0 ; 1]; % ... and so on... z2 = l2*[cos(phi1) ; sin(phi1) ; 0]; z3 = l3*[cos(phi2) ; sin(phi2) ; 0]; z4 = l4*[0 ; 0 ; -1]; % Now calculate the position of nodes and joints P1 = P0 + z1; % Shoulder P2 = P1 + z2; % Elbow P3 = P2 + z3; % Wrist PE = P3 + z4; % End effector % Display data % ========================================================================= % Now assemble a matrix [2,4] with the positions in space of the joints % P0-PE jointsPositions = [P0 P1 P2 P3 PE]; % Plot the configuration of the robot % Plot a polyline to represent the robot frame plot3(jointsPositions(1,:),jointsPositions(2,:),jointsPositions(3,:),'-o') % Plot the end-effector point hold on plot3(PE(1),PE(2),PE(3),'ro') daspect([1 1 1]); grid on xlim([-1 1]) ylim([-1 1]) zlim([0 0.3])