Simulating the forward kinematics of a 2R Robotic arm using MATLAB Programming
Aim: Simulating the forward kinematics of a 2R Robotic arm using MATLAB Programming.
Theory:
Forward Kinematics:refers to the use of the kinematic euations of a robot to compute the position of the end-effector from specified values for the joint parameters.
joint angles are the inputs, the outputs would be the co-ordinates of end-effectors.
Assuming Input variables:
let L1 = Length of the link 1
L2 = Length of the link 2
theta1 = angle of the linkage 1
theta2 = angle of the linkage 2
Software Used: MATLAB
Program:
% Forward Kinematis of a Robotic Arm manipulator
clear all
close all
clc
% Inputs
% L1 = length of link 1
% L2 = length of link 2
% theta1 = Angle of link 1
% theta2 = Angle of link 2
L1 = 1;
L2 = 0.5;
theta1 = linspace(0,90,10)
theta2 = linspace(0,90,10)
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);
% Ploting
plot([x0 x1],[y0,y1],[x1 x2],[y1 y2],'linewidth',3)
axis([-0.1 1.5 0.1 1.5])
pause(0.03)
M(ct) = getframe(gcf);
ct = ct+1;
end
end
movie(M)
videofile = VideoWriter('robotlinkage5','uncompressed AVI')
open(videofile)
writeVideo(videofile,M)
close(videofile)
Output:
theta1 =
0 10 20 30 40 50 60 70 80 90
theta2 =
0 10 20 30 40 50 60 70 80 90
videofile =
VideoWriter
General Properties:
Filename: 'robotlinkage5.avi'
Path: 'C:UsersRehamanDesktopSkill LyncPractice Matlab'
FileFormat: 'avi'
Duration: 0
Video Properties:
ColorChannels: 3
Height: []
Width: []
FrameCount: 0
FrameRate: 30
VideoBitsPerPixel: 24
VideoFormat: 'RGB24'
VideoCompressionMethod: 'None'
Animation Video Link:
https://drive.google.com/file/d/1cY22RNgRlHp8CG68cbLp0a5ahDtziJPm/view?usp=sharing