Project

Simulation of 2R robotic arm

Aim:- Simulate the forward kinematic motion of 2R robotic arm

Discription:-

2R robotic arm is an mechanism having two links where the first link is attacthed to base with a pivot in between while the secounf and first link are attacthed together with a pivot in between.

Image credit:- Skill-lync, rosesana.com

Method:-

The motion of the arm is considered to be in a graph representing co-ordinates for each point(the points between the links and base in our case). The motion is simulated by tracking the three points in graph:

1) Point O:- point between base and link1

2) Point A:- point between link 1 and link 2

3) Point B:- point of end of link 2

Claculations:-

l1= length of link 1

l2= length of link 2

`theta`1= angle made by link 1 with base

`theta`2= angle made by link 2 with base

x co-ordinate of pt. O= 0

y co-ordinate of pt. O= 0

x co-ordinate of pt. A= l1*cos(`theta`1)

y co-ordinate of pt. A= l1*sin(`theta`1)

x co-ordinate of pt. B= l1*cos(`theta`1) + l2*cos(`theta`2)

y co-ordinate of pt. B= l1*sin(`theta`1) + l2*sin(`theta`2)

Assumptions:-

--> length of link 1 and link 2 is 1 meter.

--> values of theta1 =(0, 10, 20, ... 90)

--> values of theta2 =(0, 4.7368, 9.4737, ... 90)

Matlab program for simulation:-

clear
close all
clc

%Program to simulate the forward kinematics of 2R robotic arm

%Inputs
l1=1;                                         %length of link 1 in meters
l2=1                                          %length of link 2 in meters
theta1=linspace(0,90,10)                      %values of theta 1 (0, 10, 20,... 90)
theta2=linspace(0,90,20)                      %values of theta 2 (0, 4.73, 9.47,... 90)
x0=0                                          %x co-ordinate of pt. O
y0=0                                          %y co-ordinate of pt. O
a=1                                           %variable to count the frame number

%using for loop to execute all motions

for i=1:length(theta1)                         %iterate for each value of theta 1
    for j=1:length(theta2)                     %iterate for each value of theta 1
        x1=l1*(cosd(theta1(i)))                %x co-ordinate of pt. A
        y1=l1*(sind(theta1(i)))                %y co-ordinate of pt. A
        x2=x1+(l2*cosd(theta2(j)))             %x co-ordinate of pt. B
        y2=y1+(l2*sind(theta2(j)))             %y co-ordinate of pt. B

        %plot a graph of frame of motion of arm

        plot([x0 x1],[y0 y1],[x1 x2],[y1 y2],'linewidth',1);
        axis([0 2 0 2])
        Frame(a)=getframe(gcf)                 %Assigns all frames to array Frame
        a=a+1
    end
end

%Create an video file of all the frames gathered

videofile=VideoWriter('robotic_arm_kinematic.avi','Uncompressed AVI')     %creats file
open(videofile)                                                           %open file
writeVideo(videofile,Frame)                                               %write frames
close(videofile)                                                          %close file
        

Output:-

--> Image showing a frame of motion

-->Video of full motion of arm

Motion

Conclusion:-

We saw how to simulate an forward kinematic of a 2R robotic arm in matlab.

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.