Project

2R ROBOTIC ARM CHALLENGE

Aim – Write a programe in matlab to simulate the forward kinematics of a 2R robotic arm.

Governing equations-

Figure of 2R robotic arm is shown below –

Let coordinates of

Point A are (x0,y0)

Point B are (x1,y1)

Point c are (x2,y2)

Let `theta1` be the angle subtended by the link 1 with reference to the horizontal axis

`theta2` be the angle subtended by the link 2 with reference to the horizontal axis.

Length of link 1 and link 2 are l1 and l2

Let us suppose link 1 is at origin.thus (x0,y0) is (0,0)

Using trigonometry ,

X1=l1*cos(`theta1`)

Y1=l1*sin(`theta1`)

X2=x1+l2*cos(`theta2`)

Y2=y1+l2*sin(`theta2`)

Objectives –

  • To create an animation file of the plot .
  • To know the workspace .

Procedure –

Theory – kinematics is the branch of mathematics ,physics and classic mechanical engineering . There are mostly used in robotics field . They are –

1.Forward Kinematics

2.Inverse Kinematics

Forward kinematics is frequently used to calculate the position of end effector when we know the degree value of each joint .

Inverse kinematics is used to compute the degree of each joint when we know the position of the end effector .

Robotic arm- Robotic arm is a type of mechanical arm usually programmable. The arm will be one or more than one depending upon the requirement so that they form a mechanism and the links are connected by joints allowing either rotational movement or translational displacement. Links of such are called kinemetics mechanism.

In this we use 2r robotic arm 2 R robotic arm is a robotic arm which has two arms or two kinematic links and has rotational movement .they have two degree of freedom .

Inputs-

MATLAB programe for forward kinematics of a 2R robotic arm manipulator is

%forward kinematics of a 2R robotic arm manupulator
clear all
close all
clc
%inputs
l1=1;
l2=.5;

theta1=linspace(0,90,4);
theta2=linspace(0,90,4);
ct=1;

for i = 1:length(theta1)
  THETA1=theta1(i);
  for j= 1:length(theta2)
    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] )
axis([-.5  2  -.5  2])


xlabel('x axis')
ylabel('y axis')
ct = ct+1;
pause(1)
text=sprintf("roboticarm%d.png",ct)
saveas(1,text);


  endfor
endfor

Explanation –

The software which is used for programming is OCTAVE which is an open source software .

First we have to suppose some values for l1 and l2 .

For taking multiple values for both links we use

theta1=linspace(0,90,4)

theta2=linspace(0,90,4)

Here 0 is the starting value and 90 is the ending value and 4 helps to provide links into 4 different degrees range between 0 and 90.

It is difficult to write code for 4*4 values .to overcome this issue we use for command i.e-

for I = 1:length(theta1)

As theta1 is an array .so we use another value to overcome the issue i.e-

THETA1 = theta1(i);

Which makes it a variable.

For each value of theta1 , theta2 have 4 different values .for this we use another for command

for j=1:length(theta2);

Same as ,we use

THETA2=theta2(j)

Required equations and values has been used as shown in programe

Then plot command is used for plotting the graph.

Axis command is used to provide range of the graph.

Then label the axis using label command

ct is used for changing the file name for every possible graph

Pause command is used to made different graph into one via animation .

As I use octave thus it is difficult to directly save the animation .thus we just save every possible graph with spintf and save as command.

text=sprintf("roboticarm%d.png",ct)

saveas(1,text);

Procedure for making the animation –

As there are different methods to convert picture into video(.png into .mp4 or.gif etc).

I use online convertor to convert it into animation .

https://ezgif.com/ this is the website where I convert the file.

Errors-

  1. ct is undifined .

So I provide the initial value of ct .

ct = 1;

  1. Videowriter mistake .

With this error I come to know that directly saving of animation is not possible .

So I refer instructions and come to know about command

text=sprintf("roboticarm %d.png",4)

saveas(gca,text);

But unfortunately only one .png file has to be saved .

So I refer doubt clearing session and come to know my mistake.

Corrected command is –

text=sprintf("roboticarm%d.png",ct)

saveas(1,text);

Where roboticarm is my file name we can name the file as desired.

Output-

Output in workspace is-

Animation for robortic arm is uploaded on youtube and link is given below-

https://youtu.be/gl2PRgioQuQ

CONCLUSION -

  • For different angles different combinations are possible .
  • we can know about the workspace or span of the robotic arm .
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.