MATLAB - Project 3 - 2R Robotic Arm
- AIM
Matlab Code to Simulate the forward kinematics of a 2R Robotic Arm .
- OBJECTIVE
Generate animation to visualize arm workspace .
- ASSUMPTIONS
1) A robotic arm with two links of length L1 and L2 are considered .
2) The links are assumed to have a planar workspace say X-Y
3) Link 1 is connected to the base through joint 1 and link 2 is connected to link one through joint 2
4) Link 1 makes an angle 'Theta1' and Link 2 makes an angle 'Theta2' with respect to +ve X-axis.
5) Base point of link 1 is assumbed to be (0,0) .
- CALCULATIONS OF CO-ORDINATES
- PROBLEMS & SOLUTIONS
SOLUTION
'Movie(M) in line 45 is case sensitive and to be written as movie(M)
- FINAL CODE
%Forward kinematics of a 2R Robotic Arm clear all close all clc %Inputs L1 = 0.5; %lenghts of both the links L2 = 0.5; theta1 = linspace(0 , 90 , 10 ); %taking 10 valuses between (0-90) degree theta2 = linspace(0 , 90 , 10 ); %taking 10 valuses between (0-90) degree %For LOOP operation ct=1 ; for i= 1:length(theta1) ; THETA1 = theta1(i); for j= 1:length(theta2) ; THETA2 = theta2(j); %Co-ordinates x0 = 0 ; y0 = 0; x1 = L1*cosd(THETA1); y1 = L1*sind(THETA1); x2 = x1 + L2*cosd(THETA2); y2 = y1 + L2*sind(THETA2); %Plotting plot([x0 x1],[y0 y1],[x1 x2],[y1 y2] ,'linewidth',2 ) axis([ 0 1 0 1]) pause(0.5); M(ct)= getframe(gcf); ct= ct+ 1 ; end end movie(M) videofile= VideoWriter('Forward_Kinematics.avi ' , 'Uncompressed AVI'); open(videofile) writeVideo(videofile,M) close(videofile)
- Results and Animation The animation shows the entire workspace of a 2R Robotic arm
- ANIMATION
YOUTUBE LINK
IN CASE YOUTUBE VIDEO GOT DELETED PLEASE REFER THE BELOW LINK .
Google Drive Link