Challenge

Week 2- 2R Robotic Arm Challenge

AIM:

To stimulate forward kinematics of a 2r robotic arm

EXPLANATION

  • In this forward kinematics of a 2r robotic arm we going to see the movement of robotic arm.
  • There are two link is used in the robotic arm: link-1,linl-2.
  • For the link-1 we denote the length of the link as l1=1.and the length of the link-2 denote a an l2=0.5
  • The angle of the link we denote as theta and theta1 for link-1 and theta-2 for link-2

theta1=linspace(0,60,10);
theta2=linspace(0,30,10);

  • For the movement of the link and created array for theta we used the linspace

for example:

linspace(0,60,10)

0=start value 60=end value 10=value that we need

  • ct command help the for command to jump to the next frame.

Calculating position of link-1

  • The link-1 have two end point i) starting point ii)ending point.
  • The starting point is fixed at the base and it is denote as (x0 y0) and the ending point is connected to the link-2 and it is denoted as (x1 y1).
  • The coordinate of the starting point (0 0), it's the value of x0=0 y0=0 because it fixed at base and it is starting point , the ending point of link-1
  • For forloop and the movement of link we creat length of the THETA1 as i
  • The coordination of the ending point : x1= l1*cosd(THETA1) and y1=l1*sind(THETA1).

Calculating position link-2

  • The link-2 has two end point i)starting point ii)ending point
  • The starting point is jointed with the end of the link-1 is denoted as (x1 y1) and the ending point of the link-2 is (x2 y2)
  • The coordinate of x2=x1+l2*cosd(THETA2) and y2=x1+l2*sind(THETA2)
  • To calculate x2 and y2 is jointed with link-1 so we added (x1)

Plotting

  • The plot command creat the link for the 2r robotic arm

plot([x0 x1],[y0 y1],[x1 x2],[y1 y2],'linewidth',3)

  • The axis is given if we required because it showes the range (or) distance of x and y axis
  • To evaluate the each value we give command as ct=ct+1;
  • And to get the current frame to make movie we give command as M(ct)=getframe(gcf);
  • And finally we end the forloop by giving end command.

Making movie

  • To capture all the these frame movie command is used.
  • To make the animation link as an movie we need to write command videofile=VideoWriter('forward_kinematics.avi',uncompressed AVI);
  • The video is written by the name of forward_kinematics.avi for the above command.
  • The writevideo command says that videofile as movie and it was closed by the closed command.

Main program

%forward kinematic of 2r robotic arm
close all
clear all
clc
%input
l1=1;
l2=0.5;
theta1=linspace(0,60,10);
theta2=linspace(0,30,10);


ct = 1;
for i=1:length(theta1);
THETA1=(i)
for j=1:length(theta2);
THETA2=(j)

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([-1 2 0 1])
pause(0.03);
M(ct)=getframe(gcf);
ct= ct+1;

end
end
videofile = VideoWriter('forward_kinematics.avi','uncompressed AVI')
open(videofile)
writeVideo(videofile,M)
close(videofile)

Output


THETA1 =

1


THETA2 =

1


x0 =

0


y0 =

0


THETA2 =

2


x0 =

0


y0 =

0


THETA2 =

3


x0 =

0


y0 =

0


THETA2 =

4


x0 =

0


y0 =

0


THETA2 =

5


x0 =

0


y0 =

0


THETA2 =

6


x0 =

0


y0 =

0


THETA2 =

7


x0 =

0


y0 =

0


THETA2 =

8


x0 =

0


y0 =

0


THETA2 =

9


x0 =

0


y0 =

0


THETA2 =

10


x0 =

0


y0 =

0


THETA1 =

2


THETA2 =

1


x0 =

0


y0 =

0


THETA2 =

2


x0 =

0


y0 =

0


THETA2 =

3


x0 =

0


y0 =

0


THETA2 =

4


x0 =

0


y0 =

0


THETA2 =

5


x0 =

0


y0 =

0


THETA2 =

6


x0 =

0


y0 =

0


THETA2 =

7


x0 =

0


y0 =

0


THETA2 =

8


x0 =

0


y0 =

0


THETA2 =

9


x0 =

0


y0 =

0


THETA2 =

10


x0 =

0


y0 =

0


THETA1 =

3


THETA2 =

1


x0 =

0


y0 =

0


THETA2 =

2


x0 =

0


y0 =

0


THETA2 =

3


x0 =

0


y0 =

0


THETA2 =

4


x0 =

0


y0 =

0


THETA2 =

5


x0 =

0


y0 =

0


THETA2 =

6


x0 =

0


y0 =

0


THETA2 =

7


x0 =

0


y0 =

0


THETA2 =

8


x0 =

0


y0 =

0


THETA2 =

9


x0 =

0


y0 =

0


THETA2 =

10


x0 =

0


y0 =

0


THETA1 =

4


THETA2 =

1


x0 =

0


y0 =

0


THETA2 =

2


x0 =

0


y0 =

0


THETA2 =

3


x0 =

0


y0 =

0


THETA2 =

4


x0 =

0


y0 =

0


THETA2 =

5


x0 =

0


y0 =

0


THETA2 =

6


x0 =

0


y0 =

0


THETA2 =

7


x0 =

0


y0 =

0


THETA2 =

8


x0 =

0


y0 =

0


THETA2 =

9


x0 =

0


y0 =

0


THETA2 =

10


x0 =

0


y0 =

0


THETA1 =

5


THETA2 =

1


x0 =

0


y0 =

0


THETA2 =

2


x0 =

0


y0 =

0


THETA2 =

3


x0 =

0


y0 =

0


THETA2 =

4


x0 =

0


y0 =

0


THETA2 =

5


x0 =

0


y0 =

0


THETA2 =

6


x0 =

0


y0 =

0


THETA2 =

7


x0 =

0


y0 =

0


THETA2 =

8


x0 =

0


y0 =

0


THETA2 =

9


x0 =

0


y0 =

0


THETA2 =

10


x0 =

0


y0 =

0


THETA1 =

6


THETA2 =

1


x0 =

0


y0 =

0


THETA2 =

2


x0 =

0


y0 =

0


THETA2 =

3


x0 =

0


y0 =

0


THETA2 =

4


x0 =

0


y0 =

0


THETA2 =

5


x0 =

0


y0 =

0


THETA2 =

6


x0 =

0


y0 =

0


THETA2 =

7


x0 =

0


y0 =

0


THETA2 =

8


x0 =

0


y0 =

0


THETA2 =

9


x0 =

0


y0 =

0


THETA2 =

10


x0 =

0


y0 =

0


THETA1 =

7


THETA2 =

1


x0 =

0


y0 =

0


THETA2 =

2


x0 =

0


y0 =

0


THETA2 =

3


x0 =

0


y0 =

0


THETA2 =

4


x0 =

0


y0 =

0


THETA2 =

5


x0 =

0


y0 =

0


THETA2 =

6


x0 =

0


y0 =

0


THETA2 =

7


x0 =

0


y0 =

0


THETA2 =

8


x0 =

0


y0 =

0


THETA2 =

9


x0 =

0


y0 =

0


THETA2 =

10


x0 =

0


y0 =

0


THETA1 =

8


THETA2 =

1


x0 =

0


y0 =

0


THETA2 =

2


x0 =

0


y0 =

0


THETA2 =

3


x0 =

0


y0 =

0


THETA2 =

4


x0 =

0


y0 =

0


THETA2 =

5


x0 =

0


y0 =

0


THETA2 =

6


x0 =

0


y0 =

0


THETA2 =

7


x0 =

0


y0 =

0


THETA2 =

8


x0 =

0


y0 =

0


THETA2 =

9


x0 =

0


y0 =

0


THETA2 =

10


x0 =

0


y0 =

0


THETA1 =

9


THETA2 =

1


x0 =

0


y0 =

0


THETA2 =

2


x0 =

0


y0 =

0


THETA2 =

3


x0 =

0


y0 =

0


THETA2 =

4


x0 =

0


y0 =

0


THETA2 =

5


x0 =

0


y0 =

0


THETA2 =

6


x0 =

0


y0 =

0


THETA2 =

7


x0 =

0


y0 =

0


THETA2 =

8


x0 =

0


y0 =

0


THETA2 =

9


x0 =

0


y0 =

0


THETA2 =

10


x0 =

0


y0 =

0


THETA1 =

10


THETA2 =

1


x0 =

0


y0 =

0


THETA2 =

2


x0 =

0


y0 =

0


THETA2 =

3


x0 =

0


y0 =

0


THETA2 =

4


x0 =

0


y0 =

0


THETA2 =

5


x0 =

0


y0 =

0


THETA2 =

6


x0 =

0


y0 =

0


THETA2 =

7


x0 =

0


y0 =

0


THETA2 =

8


x0 =

0


y0 =

0


THETA2 =

9


x0 =

0


y0 =

0


THETA2 =

10


x0 =

0


y0 =

0


videofile =

VideoWriter

General Properties:

Filename: 'forward_kinematics.avi'
Path: 'C:UsersgowthDesktoppractice of matforward kinematic of a linkages'
FileFormat: 'avi'
Duration: 0

Video Properties:

ColorChannels: 3
Height: []
Width: []
FrameCount: 0
FrameRate: 30
VideoBitsPerPixel: 24
VideoFormat: 'RGB24'
VideoCompressionMethod: 'None'

Methods

Simulation link video

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.