FORWARD KINEMATICS OF A ROBOTIC ARM
- AIM
To plot robotic arm forward kinematics as per given various angle of theta with 2 links
- GOVERNING EQUATIONS:
Moment of length of Link 1 arm - x1 = l1 * cosd(theta1)
Height of link 1 arm - y1 = l1 * sind(theta1)
Moment of length of Link 2 arm - x2 = x1 + l2 * cosd(theta2)
Height of link 2 arm - y2 = y1 + l2 * sind(theta2)
- OBJECTIVIES:
To simulate the displacement of robotic arm in MATLAB in 2D format to determine the workspace
- BODY OF THE CONTENT:
Language used to write a program is C
Inputs:
Length of Link 1 = 1m
Link 2 = 0.5m
Angle of theta 1 = 45 deg.
Theta 2 = 30 deg.
Written a program with given inputs to solve forward kinematics,
Codes used:
Forward kinematics of link 1:
x1 = l1*cosd(theta1);
y1 = l1*sind(theta1);
Forward kinematics of link 2:
x2 = x1 + l2*cosd(theta2);
y2 = y1 + l2*sind(theta2);
For plotting:
line([x0 x1], [y0 y1],'linewidth',3,'color','b')
line([x1 x2], [y1 y2],'linewidth',3,'color','r')
Color ‘ b ‘ represent arm 1 in blue
Color ‘ r ‘ represent arm 2 in red
Images:
Error found: Wrong syntax.
Error corrected:
Written program for animation with for_loop command:
Inputs:
Length of Link 1 = 1m
Link 2 = 0.5m
Angle of theta 1 = 45 deg.
Theta 2 = 30 deg.
Codes used:
linspace command to generate row vector of n points linearly spaced between and including inputs,
theta1 = linspace(0,90,50)
theta2 = linspace(0,90,50)
for loop command to repeat specified number of times,
for i = 1:length(theta1)
THETA1 = theta1(i);
for j = 1:length(theta2)
THETA2 = theta2(j);
For plotting,
plot([x0 x1],[y0 y1],[x1 x2],[y1 y2],'linewidth',3)
xlabel('Workspace in x direction')
ylabel('Workspace in y direction')
axis([-0.1 1.5 0 1.5])
Movie command for animation,
movie(M)
videofile = VideoWriter('forward_kinematics.avi','Uncompressed AVI');
open(videofile)
writeVideo(videofile,M)
close(videofile)
Error found:
Indicated illegal command found in the program.
Error corrected:
Illegal commend ‘end’ removed and fixed the error.
CONCULATION:
The forward kinetics of 2R Robotic arm manipulator solved in this project, with this 2D plotting method, the swiveled base 2R Robotic arm forward kinematics manipulator can be achieved in 3D view to determine a required workspace.
forward_kinematic.m
clear all
close all
clc
% Inputs
l1 = 1;
l2 = 0.5;
theta1 = 45;
theta2 = 30;
% Coordinates
x0 = 0;
y0 = 0;
x1 = l1*cosd(theta1);
y1 = l1*sind(theta1);
x2 = x1 + l2*cosd(theta2);
y2 = y1 + l2*sind(theta2);
%Plotting
line([x0 x1], [y0 y1],'linewidth',3,'color','b')
line([x1 x2], [y1 y2],'linewidth',3,'color','r')
forward_kinematic_for_loop.m
clear all
close all
clc
% Inputs
l1 = 1;
l2 = 0.5;
theta1 = linspace(0,90,50)
theta2 = linspace(0,90,50)
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],'linewidth',3)
xlabel('Workspace in x direction')
ylabel('Workspace in y direction')
axis([-0.1 1.5 0 1.5])
pause(0.03)
M(ct) = getframe(gcf);
ct = ct+1;
end
end
movie(M)
videofile = VideoWriter('forward_kinematics.avi','Uncompressed AVI');
open(videofile)
writeVideo(videofile,M)
close(videofile);
https://drive.google.com/file/d/1pw4WwLda_itPAu8JvN2AHVsPkzj8u5fD/view?usp=sharing