Forward kinematics of 2R Robotic Arm simulation using MATLAB
AIM:
To simulate the forward kinematics of a 2R Robotic Arm using MATLABhttps://youtu.be/VfQYDpqNTn4
OBJECTIVE:
1.To write the programe in matlab for forward kinematics of a robotic arm
2.To Create an animation file of the plot
3.Upload the animation video in youtube
4.understand the kinematics of the robotic arm
THEORY:
KINEMATICS:
1.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.
2.The reverse process that computes the joint parameters that achieve a specified position of the end-effector is known as inverse kinematics
2R ROBOTIC ARM
It consists of base, two arms or links and two rotational joints. These links will have motion in them when they are programmed.
PROGRAMME:
clear all
close all
clc
%inputs
%length of link 1
l1 = 2;
%length of link 2
l2 = 1;
%angles
theta1 = linspace(0,90,4)
theta2 = linspace(0,90,40)
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',5)
axis([-0.5 3 0 3])
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)
STEPS INVOLVED:
1.Lengths of both the links taken as l1 and l2 with 2 and 1respectively.
2.theta1 is taken for the link1 and theta2 is taken for link2 with different angles to trace them.these are the one used for simulation
3.for loop is used to trace the theta2 with respect to theta1 to obtain different positions uding angle1
4.In the for loop the positions are taken like for the base it is taken (x0,y0) and for first one with (x1,y1) and the last one with (x2,y2)
5.Now the plot is captured with evey frame to create animation
6.The video is created as videofile using videowriter option and then saved,therefore the video is the obtained
RESULT:
The result of the programe is obtained in the form of a video.The video can be accesed through the provided link
https://youtu.be/VfQYDpqNTn4
CONCLUSION:
Hence,The simulation of forward kinematics of 2R robotic arm is done using MATLAB.