Challenge

2R Robotic Arm Challenge

% Forward kinematics of a 2R robotics arm manipulator

clear all

close all

clc

% input

% lenght

l1 = 2; .................Length of Arm one which is given

l2 = 1; .................Length of Arm two which is given

% Angle

theta1 = 45; ........Angle made between workpiece and arm one

theta2 = 30; ........Angle made between workpiece and arm two

% coordinate

x0 = 0; ...........Starting point of the arm of x axis

y0 = 0; .........Starting point of the arm of y axis

x1 = l1*cosd(theta1); ..........Using trigonomatric formulae we get x1

y1 = l1*sind(theta1); ..........Using trigonomatric formulae we get y1

x2 = x1 + l2*cosd(theta2); ..........Using trigonomatric formulae we get x2

y2 = y1 + l2*sind(theta2); ..........Using trigonomatric formulae we get y2

% plotting

line([x0,x1],[y0,y1],'linewidth',3,'color','b') ..............For arm one we plot x0,x1 and y0,y1 coordinate using array and give width of 3 and color of arm line is blue

line([x1,x2],[y1,y2],'linewidth',3,'color','r') ..............For arm two we plot x1,x2 and y1,y2 coordinate using array and give width of 3 and color of arm line is red

.............in this program arm is not moving its just show diagram of arm therefore we do the new program with same dimensions.

clear all

close all

clc ...................this program for generating the animation and video

% inputs

l1 = 2; .................Length of Arm one which is given

l2 = 1; .................Length of Arm two which is given

theta1 = linspace(0,90,20); .............We use the linspace command for theta 1 getting the equal interval values that 0 to 90 and 20 equal intervals . theta 1 = Angle made between workpiece and arm one.

theta2 = linspace(0,90,20); ............We use the linspace command for theta 2 getting the equal interval values that 0 to 90 and 20 equal intervals. theta 2 = Angle made between workpiece and arm two.

ct=1; ....................for represent each frame

for i = 1:length(theta1) ................we use here for loop for start to end run program. i=1 to length of theta 1

THETA1 = theta1(i); .................. we take (i) variable for represent theta one.

for j = 1:length(theta2) .......................j=1 to length of theta 2

THETA2 = theta2(j); .................. we take (j) variable for represent theta two

x0 = 0; ..........Starting point of the arm of x axis

y0 = 0; ...........Starting point of the arm of y axis

x1 = l1*cosd(THETA1); .........Using trigonomatric formulae we get x1

y1 = l1*sind(THETA1); .........Using trigonomatric formulae we get y1

x2 = x1 + l2*cosd(THETA2); .........Using trigonomatric formulae we get x2

y2 = y1 + l2*sind(THETA2); .........Using trigonomatric formulae we get y2

% plotting

plot([x0,x1],[y0,y1],[x1,x2],[y1,y2],'linewidth',3); ...........here we plot for animation point of arm using above values of [x0,x1], [y0,y1],[x1,x2]and [y1,y2] also use the array command

axis([-0.1 3 0 3]) ..............limit of axis in array of x and y coordinates

pause(0.05) ............pause timing between 2 frame

M(ct) = getframe(gcf);

ct=ct+1; ................for adding frame one after one

end

end ..................... end for loop

Movie(M) ...............for generating movie

videofile = videowriter('forward_kinematics_for_loop.avi','uncompressed_AVI'); ......name of file

open(videofile) ........... for open videofile

writevideo(videofile,M)

close(videofile) ............ for close videofile

Link of google drive: https://drive.google.com/file/d/1y0gLTAxfhkawt2rcPkceXKDDmJa4-30s/view?usp=sharing

Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.