Project

To simulate forward kinematics of 2R robotic arm

Introduction:

Forward kinematics refers to the use of the kinematic equations of a robot to compute the position of the end-effector from specified values for the joint parameters.

Code:

Programe to simulate forward kinematics of 2R robotic arm.

%forward kinematics of 2R robotic arm

clear all
close all
clc

% Input
theta1=linspace(0,90,4);
theta2=linspace(0,90,4);
l1=1;
l2=0.5;
THETA1=45;
THETA2=20;

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);

% Plot
plot([x0 x1],[y0 y1],[x1 x2],[y1 y2],'linewidth',3);
pause(0.6);
axis([-0.1 1 0 1.5])


%q(ct)=getframe(gcf);
text=sprintf("forward_kinematics%d.png",ct+1);
saveas(1,text)
ct=ct+1;


end
end

Explanation of code:

1. In our programe we have considered two links in robotic arm for simulation (x0,y0)&(x1,y1) are start and end possition of link 1 and (x1,y1) & (x2,y2) are start and end possition of link2.

2. THETA1 is angle made by link 1 with x axis and THETA2 is angle made by link 2 with x axis

theta is an array of angle whereas THETA is instantaneous value of angle.

3.Plot the possition of link 1 and link 2 by stating respective co-ordinates.

4.Here in this case we are using octave hence used command sprintf to save file name.

5.To make gif file in octave download and instal image magick and open command prompt window type cd to change directory then type dir to check directory.

6.Now type magick *.png output.gif

means all the files with .png extension will convert to .gif file with file name 'output'.

Error:

1.Image obtained as output are ovelaping.

2.All the images of link 1 and link 2 are obtained in single images.

Steps taken to overcome error:

1.use hold on to get separate images.

2.use pause to pause the code for some interval and will get separate images after specific interval of time.

Link for Youtube :https://youtu.be/UldeMxfLWp0

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.