To simulate the forward kinematics of a 2D Robotic Arm.
OBJECTIVE:
To simulate the forward kinematics of a 2D Robotic Arm.
The 2D robotic arm is used in various works like in automation industries. In the simulation of a 2D Robotic Arm we have to get all the workspce covered by the arm in 2D i.e. in x_axis and in y_axis.
In this program assume a robotic arm have 2 linkages and getting motion in 2D with the variation of angle from 0 to 90 degree for 10 equispace angles.
% To simulate the forward kinematics of a 2R Robotic arm.
clear all
close all
clc
%Inputs
l1 = 1; % length of link 1
l2 = 0.5; % length of link 2
theta1 = linspace(0,90,10); % Rotation of link 1 at different angles
theta2 = linspace(0,90,10); % Rotation of link 2 at different angles
ct = 1;
for i = 1:length(theta1)
THETA1 = theta1(i);
for j = 1:length(theta2)
THETA2 = theta2(j);
% X&Y coordinates at different position
x0 = 0; % Start position of link 1
y0 = 0;
x1 = l1*cosd(THETA1); % Joint of link 1&2
y1 = l1*sind(THETA1);
x2 = x1 + l2*cosd(THETA2); % End position of link 2
y2 = y1 + l2*sind(THETA2);
%plot
plot([x0 x1],[y0 y1],[x1 x2],[y1 y2],'linewidth',3)
axis([-0.1 1.5 0 1.5]) % plot limits
pause(0.03)
M(ct) = getframe(gcf);
ct = ct+1;
end
end
movie(M) % Create movie
videofile = VideoWriter('forward_kinematics_for.avi','Uncompressed AVI');
open(videofile)
writeVideo(videofile,M)
close(videofile)
RESULT:
In this the maximum possible workspace of a 2D Robotic arm get covered.
https://drive.google.com/open?id=1ZVYyh9tZIzneoBVXCw3YSbJ-Onb7261t