Project

AIM:  simulate the forward kinematics of a 2R Robotic Arm.

theory:

taken that Q1 ans Q2 are given.

Q1 being theta1,

Q2 being theta2,

step1: calculate position of link1

which has two end points, starting point which is attached, and the end point.

given below respectively,

x0= 0; y0=0,

x1=l1 x cos Q1; y1=l1 x sin Q1

step2: calculate position of link2

x2= x1+l2xcosQ2

y2= y1+l2xsinQ2

lentgh of link 1= l1 = 1,

length of link 2= l2= 0.5,

angle between surface and link 1 = theta1

angle between surface parallel and link2= theta2,

coordinates of starting point of link 1= x0, y0

where x0= 0

y0= 0;

coordinates of end point of link 1= coordinates of starting point of link 2= x1, y1

where x1= l1*cosd(theta1)

y1= l1*sind(theta1);

coordinates of end point of link 2= x2, y2

where x2= x1+l2*cosd(theta2)

y2= y1+l2*sind(theta2);

PROCEDURE:

  1. write down the code accordingly, starting from, clear all, close all and clc.
  2. code down the inputs, including l1,l2,theta1, and theta2. (where theta is taken by linspace)
  3. we code ct, as 1
  4. and then we code for loop, for i=1:length(theta1), THETA1= theta1(i).
  5. in next for loop, we code j= 1:length(theta2), THETA2= theta2(j).
  6. on the next step, we code down the coordinates, x0,y0,x1,y1,x2 and y2.
  7. and then we give the plot commands for l1 aand l2, by coding "plot", give the pause interval and then save the frames by getframe(gcf)
  8. and then we end it with commands for the resulting video.

CODE:

clear all
close all
clc

%inputs
l1= 1;
l2= 0.5

theta1= linspace(0,90,10);
theta2= linspace(0,90,10);

ct=1;
for i=1:length(theta1);
    THETA1= theta1(i);
    
  for  j=1:length(theta2);
    THETA2= theta2(j);
    
   
%coordinates 
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' , 3);
axis([-0.1 1.5 0 1.5]);
pause(0.03)
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) 

RESULT:

the required outcome was achieved.

https://www.youtube.com/watch?v=Qr6Osm7V1DU

ERROR FACED:

1.

to correct this error simpy, "ct=ct+1" had to come after m(ct)=getframe(gcf).

2.

for this error, a simple correction was made in the second line,where instead of "i" j was replaced.

3.

for this the a basic correction was made, the V in "writevideo" was done capital.

END

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.