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.

error1

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

error 2

 

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

 


Projects by Piyush Misar

Curve fitting using octave
Piyush Misar · 2019-09-21 09:19:12

Objective:     Write code to fit a linear and cubic polynomial for the Cp data.    Introduction:  Curve Fitting:   Curve fitting is process of constructing a curveor mathematical functionswhich posess the closest proximity to Read more

Objective: Write a program to simulate the transient behaviour of a simple pendulum and to create an animation of it\'s motion. Introduction: Simple Pendulum:   A simple pendulum has a small-diameter bob and a string that has a very small mass but is strong en Read more

Otto cycle using matlab
Piyush Misar · 2019-09-05 06:53:03

Introduction:   An Otto cycle is an idealized thermodynamic cycle that describes the functioning of a typical spark ignition engine. The Otto cycle consists of isentropic compression, heat addition at constant volume, isentropic expansion, and rejection of he Read more

Flow over Bycycle
Piyush Misar · 2019-09-03 15:00:32

Objective: 1.Write a programe to plot velocity vs Drag force. 2.Write a programe to plot drag co-efficient vs drag force. Introduction: A drag force is the resistance force caused by the motion of a body through a fluid. A drag force acts opposite to the direction o Read more


Loading...

The End