% This exercise refers to the robot described in file % 3dof_robot_relativeAngles.png % ========================================================================= clc clear all % close all % Define parameters % ========================================================================= % Lenghts of links l1 = 0.7; l2 = 1; l3 = 0.4; % Relative angles of joints phi1 = + 0.35 * pi; phi2 = - 0.0 * pi; phi3 = - 0.25 * pi; % Calculate the position of the joints % ========================================================================= % Set P0 in the origin P0 = [ 0 ; 0 ]; % First calculate the vector z1 which corresponds to the 1st link z1 = l1 * [ cos(phi1) ; sin(phi1) ]; % Calculate point P1 P1 = P0 + z1; % Calculate point P2 from point P0 by adding the 2nd link vector z2 z2 = l2 * [ cos(phi1 + phi2) ; sin(phi1 + phi2) ]; P2 = P1 + z2; % Do the same for point P3 by using z3 z3 = l3 * [ cos(phi1 + phi2 + phi3) ; sin(phi1 + phi2 + phi3) ]; P3 = P0 + z1 + z2 + z3; % Display data % ========================================================================= % Now assemble a matrix [2,4] with the positions in space of the joints % P0-P3 jointsPositions = [P0 P1 P2 P3]; % Plot the configuration of the robot % Plot a polyline to represent the robot frame plot(jointsPositions(1,:), jointsPositions(2,:),'r') % Plot the end-effector point hold on plot(P3(1), P3(2), 'bo') daspect([1 1 1]) axis equal